GithubHelp home page GithubHelp logo

commaai / panda Goto Github PK

View Code? Open in Web Editor NEW
1.5K 95.0 726.0 10.83 MB

code powering the comma.ai panda

License: MIT License

Makefile 0.01% C 92.59% Shell 0.13% Assembly 0.82% Python 6.42% Dockerfile 0.03%

panda's Introduction

Welcome to panda

panda tests panda drivers

panda speaks CAN and CAN FD, and it runs on STM32F413 and STM32H725.

Directory structure

.
├── board           # Code that runs on the STM32
├── drivers         # Drivers (not needed for use with Python)
├── python          # Python userspace library for interfacing with the panda
├── tests           # Tests and helper programs for panda

Safety Model

When a panda powers up, by default it's in SAFETY_SILENT mode. While in SAFETY_SILENT mode, the CAN buses are forced to be silent. In order to send messages, you have to select a safety mode. Some of safety modes (for example SAFETY_ALLOUTPUT) are disabled in release firmwares. In order to use them, compile and flash your own build.

Safety modes optionally support controls_allowed, which allows or blocks a subset of messages based on a customizable state in the board.

Code Rigor

The panda firmware is written for its use in conjuction with openpilot. The panda firmware, through its safety model, provides and enforces the openpilot safety. Due to its critical function, it's important that the application code rigor within the board folder is held to high standards.

These are the CI regression tests we have in place:

  • A generic static code analysis is performed by cppcheck.
  • In addition, cppcheck has a specific addon to check for MISRA C:2012 violations. See current coverage.
  • Compiler options are relatively strict: the flags -Wall -Wextra -Wstrict-prototypes -Werror are enforced.
  • The safety logic is tested and verified by unit tests for each supported car variant. to ensure that the behavior remains unchanged.
  • A hardware-in-the-loop test verifies panda's functionalities on all active panda variants, including:
    • additional safety model checks
    • compiling and flashing the bootstub and app code
    • receiving, sending, and forwarding CAN messages on all buses
    • CAN loopback and latency tests through USB and SPI

The above tests are themselves tested by:

  • a mutation test on the MISRA coverage
  • 100% line coverage enforced on the safety unit tests

In addition, we run the ruff linter and mypy on panda's Python library.

Usage

Setup dependencies:

# Ubuntu
sudo apt-get install dfu-util gcc-arm-none-eabi python3-pip libffi-dev git

# macOS
brew install --cask gcc-arm-embedded
brew install python3 dfu-util gcc@13

Clone panda repository and install:

git clone https://github.com/commaai/panda.git
cd panda

# install dependencies
pip install -r requirements.txt

# install panda
python setup.py install

See the Panda class for how to interact with the panda.

For example, to receive CAN messages:

>>> from panda import Panda
>>> panda = Panda()
>>> panda.can_recv()

And to send one on bus 0:

>>> panda.can_send(0x1aa, "message", 0)

Note that you may have to setup udev rules for Linux, such as

sudo tee /etc/udev/rules.d/11-panda.rules <<EOF
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddcc", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddee", MODE="0666"
EOF
sudo udevadm control --reload-rules && sudo udevadm trigger

The panda jungle uses different udev rules. See the repo for instructions.

Software interface support

As a universal car interface, it should support every reasonable software interface.

Licensing

panda software is released under the MIT license unless otherwise specified.

panda's People

Contributors

0x41head avatar adeebshihadeh avatar adhintz avatar appleguru avatar avolmensky avatar bongbui321 avatar briskspirit avatar dek3rr avatar diamondman avatar energee avatar geohot avatar gliptak avatar gregjhogan avatar incognitojam avatar jasonjshuler avatar jenstrange avatar jnewb1 avatar jyoung8607 avatar legonigel avatar martinl avatar n2aws avatar pd0wm avatar rbiasini avatar robbederks avatar royjr avatar samrum avatar sshane avatar sunnyhaibin avatar vanillagorillaa avatar vntarasov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

panda's Issues

Legacy board doesn't work from devel branch

Legacy board doesn't work from devel branch.

Repro:
As soon as boardd from openpilot/devel tries to use legacy board with legacy build firmware from panda/devel, red LED gets stuck in either on or off state. No CAN messages go in or out.

This is blocking me from developing safety changes for Volt.

Latency / Frequency / Scanning rate?

Hi,

according to some reports and advertisements on the Internet, some OBD2 scanners seem to be too slow / too laggy for visualizing things in realtime, i.e. when you use an app that shows the RPMs or the speed or something like that, some OBD2 scanner apparently are better at showing these in realtime because their scan rate is better than others.

Is this true?

Or does it basically depend on the car instead of the OBD2 scanner?

And what about the panda? Will it provide the best scan rate possible, considering that it is being adviced as "panda is the nicest universal car interface ever"?

How to update panda code? How to connect with computer?

Is 'Panda Paw' needed to update the code on the Panda? Can I use a standard USB cord? How do I transfer the code to the board?

To use PandaCAN or SocketCAN with my computer, do I just plug the panda into my computer with a standard USB cord?

Panda firmware fails to compile with arm-none-eabi-gcc 5.4.1 20160919 (default std=gnu11)

Compiling the panda firmware on a Debian Stretch machine (using the debian provided gcc-arm-none-eabi version 5.4.1) fails complaining about inline functions not being available at link time. For example:
undefined reference to 'early'.

This stems from the C standard being used by GCC changing from gnu90 to gnu11 between gcc version 4.9 to 5.1 as detailed here. In short, the semantics around the inline keyword has changed between standards.

It appears that the original developer wrote the firmware using ubuntu's Xenial gcc-arm-none-eabi package which is currently on version 4.9.3. Since Ubuntu will inevitably update to the 5.x line sometime in the future, we should fix this now.

The easiest solution is to explicitly mark the std type as gnu90, thus restoring the default behavior of the older GCC version. No matter what is done, I believe that a C standard should be selected for the project to prevent these types of issues in the future.

But this issue raises a question: why are these functions inline?
The compiler is free to ignore the inline directive, as well as choose to inline a function that is not explicitly marked to be inlined [1]. Furthermore, the firmware is compiled with -O0, and inlining is only done on optimizing compilations: "Inlining of functions is an optimization and it really “works” only in optimizing compilation. If you don't use -O, no function is really inline." [gcc manual].

I argue that most of these inline functions should be stripped of their inline qualifier and split into a header file and a source file, as inlining can still be done across compilation units. This would also allow us to use more modern C semantics in the future.

I am happy to make a PR with either of the proposed changes. What is the preferred way to resolve this issue?

ImportError: No module named panda

Installed pandacan using:
$pip install pandacan

And then ran
$python

from panda import Panda
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named panda


tried python3 instead
$python3

from panda import Panda
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/panda/init.py", line 7, in
import usb1
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/usb1/init.py", line 61, in
from . import libusb1
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/usb1/libusb1.py", line 199, in
libusb = _loadLibrary()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/usb1/libusb1.py", line 173, in _loadLibrary
return dll_loader('libusb-1.0' + suffix, **loader_kw)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libusb-1.0.dylib, 6): image not found

No dataset using panda

Hello,

I have purchased panda and tried to gather information about my car (VW polo 2016) but when I logged into cabana, it couldn't read any data. It said that I need to reverse engineer.

ISO9141 support

can you implement ISO9141 for the panda, or how could I implement it.

Can panda work on BMW F-Chase ?

Would like to know if panda could work on BMW F-Chase car and access the KCAN1/KCAN2 via OBD port ?
How about open the BDC/GW box and hack on that ?

Cheers,

Shawn

Does panda debug board has no corresponding chip?

Could you help me see the process of panda, Do I understand it right?

  1. panda device has two hardware, one is STM32, one is ESP8266
  2. panda inside op, board corresponding to STM32, boardesp corresponds to ESP8266, and then compile accordingly into panda device

I don't know if I understand it right,
In addition: Someone told me panda debug board, it’s just hardware, no software- panda inside op, what is the reason?

How to determine the board type?

void detect_board_type(void) {
  #ifdef PANDA
    // SPI lines floating: white (TODO: is this reliable?)
    if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){
      hw_type = HW_TYPE_WHITE_PANDA;
      current_board = &board_white;
    } else if(detect_with_pull(GPIOA, 13, PULL_DOWN)) { // Rev AB deprecated, so no pullup means black. In REV C, A13 is pulled up to 5V with a 10K
      hw_type = HW_TYPE_GREY_PANDA;
      current_board = &board_grey;
    } else {
      hw_type = HW_TYPE_BLACK_PANDA;
      current_board = &board_black;
    }
  #else
    #ifdef PEDAL
      hw_type = HW_TYPE_PEDAL;
      current_board = &board_pedal;
    #else 
      hw_type = HW_TYPE_UNKNOWN;
      puts("Hardware type is UNKNOWN!\n");
    #endif
  #endif
}

from above,we can get "A4,A5,A6,A7" means HW_TYPE_WHITE_PANDA
and They can get from the file "white.h"

// A4, A5, A6, A7: SPI
set_gpio_alternate(GPIOA, 4, GPIO_AF5_SPI1);
set_gpio_alternate(GPIOA, 5, GPIO_AF5_SPI1);
set_gpio_alternate(GPIOA, 6, GPIO_AF5_SPI1);
set_gpio_alternate(GPIOA, 7, GPIO_AF5_SPI1);

and "A13" means HW_TYPE_GREY_PANDA
but I only find “A13” in the file "white.h" ?
What happened to the process?

Allow more Granular CAN Forwarding

Although there is forwarding for a full bus, there is no simple way to mask CAN ids so that partial messages are forwarded / removed. Would you consider adding files similar to safety_*.h that could be referenced by openpilot for modifying CAN traffic safely with the panda?

It looks like so far, this is required for the Tesla port and Honda CR-V/Hatchback port and would be required for preserving some OEM Toyota and Honda features like automatic lights.

GMLAN sleep mode and wakeup

Hi,
How do you put the panda in sleep mode and wake it up? He drains the car's battery in two days.

Thanks

ODIS Software not fully compatible (Audi/Volkswagon/Skoda/Seat)

Panda is not working 100% with ODIS V9. It connects and you can do some stuff but it is useless because it does not find all ECU's which are available in total at the car. If somebody has time and knowledge how to fix that. A lot of people would be thankful.

the shipping order of panda

hi:
i have placed an order for a panda in 2017/7/24 , until now i don't receive any Logistics information about it.
i have send emails to [email protected]. but no one answer me .
Is it because we are in China, leading us to cann't receive logistics information, or other problems caused .
i really want a panda, can you help me . thank you very much.@geohot @joshenders
my order number is (#102817092)

1.0.8+ appears to break chffr

It looks like when we flash 1.0.8+ manually, it breaks wifi. It results in panda-xxxxx-BROKEN-pair SSID which blocks chffr pairing and probably wifi connections. Latest packaged release is OK.

where can I find the wifi password of panda?

I can scan the wifi of panda when I connect panda with OBD, but this wifi need a password, where can I find this password? The wifi name is panda-a62e6c57f5a2a711 and I hope for some help. Thank you very much!

kline_recv not working

not sure if k line is fully implemented yet, but it just hangs when panda.kline_recv() is called. i'm communicating over wifi and panda.can_recv() works fine. panda is fully up to date according to ios chffr

Bluetooth?

Hi,

why does the panda not feature Bluetooth but only Wi-Fi?

When connecting a phone to the panda via Wi-Fi, the phone will be unable to connect to other access points simultaneously?

With Bluetooth a phone could be connected to the panda via Bluetooth and connect to another Wi-Fi access point simultaneously.

So why did you choose to solely rely on Wi-Fi? Why not Bluetooth in addition?

Does the Wi-Fi chip on the panda support Bluetooth?

Will new versions of the panda support Bluetooth?

Need GMLAN and CAN2 at the same time

Assuming there is something interesting on GMLAN (aka: Low speed GMLAN / aka: Low speed CAN / 33kbit/sec), I need CAN2 and GMLAN to work at the same time. (In response to the PDF saying that they both cannot be used at the same time.)

CAN2 = "Object High Speed GMLAN" on my Chevy Volt gen2 w/front radar. (They call everything a GMLAN, just high speed / low speed.)

I'm not sure if there is something interesting on GMLAN (pin 1), I'll know in a week or two, but this seems like a bit of a mistake on the Panda of not knowing that both would be needed at the same time.

Also, is there a way to hook up to OBD2 pin 1 (GMLAN) on the Neo? (GMLAN / Low speed CAN, non-differential.) I see that a differential CAN driver is used there, is there a schematic for the Panda to know how this hooks in? (Panda feels a bit half-open sourced unless I'm just not finding the repo? And the secret wifi key?) Can I just use one of the differential drivers to talk non-differential CAN?

Also, if I get a Panda one day (I'm up to over a thousand comma points so I hope soon? Not sure if its all time high or weekly high?), how is the CAN data used? Do I have open access to all of that? Are the values for knowing steering already known for GM? Will this turn into a decentralized attempt to de-obscure all PIDs on all makes/models of vehicles, or is it just something Comma can see?

Different CAN bus index from hardware guide (Python)

I used example/can_logger.py to get can log from the ODB port, but it seems that the CAN bus index is in different order from the Hardware Guide which is confusing.

From what I observed:
Bus0 from the log means CAN-2 in Hardware Guide
Bus1 from the log means CAN-1 in Hardware Guide
Bus2 from the log means CAN-3 in Hardware Guide

Does anyone have the same problem?

Panda python api can try to send CAN messages over 8 bytes and garbles the result.

Can is only capable of sending datapackets up to 8 bytes long. There is no limit on the message size that the python code will try to send. The results are messed up data. The following examples are with the CAN loopback enabled.

Correct Behavior

In [22]: from panda import Panda;p = Panda(Panda.list()[0])
opening device .....

In [23]: p.can_send(0x13, b'12345678', 1)
DAT: b'\x01\x00`\x02\x18\x00\x00\x0012345678'

In [24]: p.can_recv()
Out[24]: 
[(19, 47928, bytearray(b'12345678'), 3),
 (19, 47928, bytearray(b'12345678'), 1)]

Too long message

In [22]: from panda import Panda;p = Panda(Panda.list()[0])
opening device .....

In [25]: p.can_send(0x13, b'123456789', 1)
DAT: b'\x01\x00`\x02\x19\x00\x00\x00123456789'

In [26]: p.can_recv()
Out[26]: 
[(448, 25113, bytearray(b''), 2),
 (448, 25113, bytearray(b''), 0),
 (19, 25175, bytearray(b'12345678'), 3),
 (19, 25175, bytearray(b'12345678'), 1)]

can2 on usb using can utils on Linux not working

Can access data using wifi on can2. can0 and can1 work correctly using usb cable with can utils, but can2 does not work.
To reproduce: send can data to can2, connect usb cable then in terminal:
sudo ip link set can2 up
candump can2

On startup Panda sends old can messages

When starting up, Panda sends old can messages.

Steps to reproduce:

  1. Have EON connected to Panda. Have Panda's 12VIN and Ignition pins connected to the car's ignition. This way the Panda only gets power when the car is on. Optionally have a second Panda connected to OBD2 to observe what's on the can bus.
  2. Drive around with EON and OpenPilot.
  3. Turn off the car. This immediately turns off power to the Panda.
  4. Turn on the car.

Expected results: The Panda doesn't send any can bus messages until the EON tells it to.

Actual results: As observed by the second Panda, when the Panda starts up, it sends some can bus messages left over from the previous drive. I'm unsure if these messages are just queued up from the previous run or if some memory structure is somewhat corrupted.

Specs in README.md outdated?

Hi,

the README.md says:

ELM327 (planned)
Windows J2534 (planned)

The online shop says:

Wi-Fi ELM327 (Android and iOS apps)
Windows J2534 (Car manufacturer tools)

Which one is correct?

cannot connect to car

I have the panda hooked up and it's lighting up. it's plugged in with usb wire to my mac with panda installed and 1 of 2 things happens:

➜ panda git:(master) ✗ python3 examples/query_vin_and_stats.py
Traceback (most recent call last):
File "examples/query_vin_and_stats.py", line 4, in
from panda import Panda
File "/usr/local/lib/python3.6/site-packages/panda/init.py", line 11, in
from dfu import PandaDFU
ModuleNotFoundError: No module named 'dfu'

➜ examples git:(master) ✗ python query_vin_and_stats.py
Traceback (most recent call last):
File "query_vin_and_stats.py", line 31, in
panda = Panda()
File "/usr/local/lib/python2.7/site-packages/panda/init.py", line 116, in init
self.connect(claim)
File "/usr/local/lib/python2.7/site-packages/panda/init.py", line 159, in connect
assert(self._handle != None)
AssertionError

Single-wire GMLAN support

I don't have access to create a pull request.

What the attached diff does:

  • Fixes off-by-one error in can bus speed calculation, that was preventing single-wire GMLAN from working on my Chevy Volt gen 2.
  • Makes it easier to understand, debug, and change the can speed configuration code.
  • Enables sending/receiving extended addresses (majority of messages on single-wire GMLAN on my car).

panda.patch.txt

How to implement self-driving through panda, cabana & openpilot?

I am a student. And I have already read many website about comma.ai and openpilot. But I still don't know how to use panda and cabana to make a self-driving car. Can anybody tell me more details? I am already have my panda device and I am also already have some driving records in chffr and cabana. What should I do in next step? How can I use openpilot to control my car?

ModuleNotFoundError: No module named 'dfu' (on python 3.6.5)

[caleb@cmbpr:panda]$ python
Python 2.7.14 (default, Apr  7 2018, 21:31:36)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from panda import Panda
>>>
[caleb@cmbpr:panda]$ python3
Python 3.6.5 (default, Apr  6 2018, 13:56:36)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from panda import Panda
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/panda/__init__.py", line 11, in <module>
    from dfu import PandaDFU
ModuleNotFoundError: No module named 'dfu'
>>>

the method set_power_save_state is never to arrive "disable power savings" in file power_saving.h

I copied the main logic in python

POWER_SAVE_STATUS_DISABLED=0
POWER_SAVE_STATUS_ENABLED=1

power_save_status = POWER_SAVE_STATUS_DISABLED;
def set_power_save_state(state):
    is_valid_state = (state == POWER_SAVE_STATUS_ENABLED) | (state == POWER_SAVE_STATUS_DISABLED);
    if (is_valid_state & (state != power_save_status)):
        if (state == POWER_SAVE_STATUS_ENABLED):
            print("enable power savings\n")
        else:
            print("disable power savings\n")
            
for i in range(-100,100):
    set_power_save_state(i)

Obviously,It's never to arrive "disable power savings"

on Linux what pandacan what version of python should be used

I'm trying to get pandacan working on my linux Lubuntu laptop and get error:

/ur/local/lib/pyhon2.7/dist-packages no theree on the install script
pip install pandacan step

Should I have installed 2.7 instead of python3?
is there another library i should apt-get python 2 libs?
Should this be added to the readme?

pandacan: Connection refused when connecting over WiFi

Hi,

I just got my Panda and tried to use it in my car. I was able to connect to it using your app (chffr) and see the battery voltage but nothing else, then I tried to connect to it using pandacan over WiFi, but I was unable to make a connection - I am always getting an error saying "[Errno 61] Connection refused".

Python 2.7.16 (default, Apr 12 2019, 15:32:52)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from panda import Panda
>>> panda = Panda("WIFI")
192.168.0.10
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/panda/__init__.py", line 128, in __init__
    self.connect(claim)
  File "/usr/local/lib/python2.7/site-packages/panda/__init__.py", line 139, in connect
    self._handle = WifiHandle()
  File "/usr/local/lib/python2.7/site-packages/panda/__init__.py", line 75, in __init__
    self.sock = socket.create_connection((ip, port))
  File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 575, in create_connection
    raise err
socket.error: [Errno 61] Connection refused
>>>
PING 192.168.0.10 (192.168.0.10): 56 data bytes
PING 192.168.0.10 (192.168.0.10): 56 data bytes
64 bytes from 192.168.0.10: icmp_seq=0 ttl=128 time=2.119 ms
64 bytes from 192.168.0.10: icmp_seq=1 ttl=128 time=12.972 ms
64 bytes from 192.168.0.10: icmp_seq=2 ttl=128 time=1.175 ms
64 bytes from 192.168.0.10: icmp_seq=3 ttl=128 time=1.330 ms
64 bytes from 192.168.0.10: icmp_seq=4 ttl=128 time=12.646 ms
64 bytes from 192.168.0.10: icmp_seq=5 ttl=128 time=9.967 ms
^C
--- 192.168.0.10 ping statistics ---
6 packets transmitted, 6 packets received, 0.0% packet loss

What I'm doing wrong here?

example query_vin_and_stats.py need python 3.7

When running the example/query_vin_and_stats.py with python 2.7.12 I got the following error.

Traceback (most recent call last):
File "query_vin_and_stats.py", line 6, in
from isotp import isotp_send, isotp_recv
File "/usr/local/lib/python2.7/dist-packages/isotp/init.py", line 9, in
raise NotImplementedError("Your version of Python does not offer support for CAN ISO-TP protocol. Support have been added since Python 3.7 on Linux build > 2.6.15.")
NotImplementedError: Your version of Python does not offer support for CAN ISO-TP protocol. Support have been added since Python 3.7 on Linux build > 2.6.15.

The incorrect from isotp import ... may cause this problem, it tries to import can-isotp(only supported in python3) instead of the isotp comes with panda

In my opinion, it should be changed to "from panda.isotp import isotp_send, isotp_recv"

windows Python 2.7, having issue when running can_logger.py

I'm running the same code, it works in Ubuntu, but fails in my laptop, which is Windows 10. I cannot understand why. I had every packages installed though.

D:\Projects\panda\venv\Scripts\python.exe D:/Projects/panda/python/can_logger.py
Traceback (most recent call last):
File "D:/Projects/panda/python/can_logger.py", line 6, in
from panda import Panda
File "D:\Projects\panda\venv\lib\site-packages\panda_init_.py", line 7, in
import usb1
File "D:\Projects\panda\venv\lib\site-packages\usb1_init_.py", line 61, in
from . import libusb1
File "D:\Projects\panda\venv\lib\site-packages\usb1\libusb1.py", line 199, in
libusb = _loadLibrary()
File "D:\Projects\panda\venv\lib\site-packages\usb1\libusb1.py", line 173, in loadLibrary
return dll_loader('libusb-1.0' + suffix, **loader_kw)
File "C:\Python27\Lib\ctypes_init
.py", line 366, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

examples

any additional examples for reading diagnostics on moving vehicle

Need some help

When I install the lunux driver of panda at the step of make build, there is a error that binary package for panda: 0.0.1 not found. I have install linux-headers-4.2.0-42 and it is in usr/src/.

LIBUSB_ERROR_IO when using pandacan flash

Problem:

I've been getting a LIBUSB_ERROR_IO during "step 1" when doing the flash via pandacan.

Steps to reproduce:

sudo python -c "import panda; panda.flash_release()"

Result

Using panda with serial 410034000651363038363036
Fetching latest firmware from github.com/commaai/panda-artifacts
Fetching firmware from https://github.com/commaai/panda-artifacts/raw/master/panda-v0.9.7-ac6e0e67-RELEASE.zip
File Name                                             Modified             Size
bootstub.panda.bin                             2017-08-29 11:36:16        12348
panda.bin                                      2017-08-29 11:36:16        18516
user1.bin                                      2017-08-29 11:36:18       246980
user2.bin                                      2017-08-29 11:36:18       246980
boot_v1.5.bin                                  2016-05-20 16:53:08         3232
version                                        2017-08-29 11:36:18           23
0. Preparing to flash v0.9.7-ac6e0e67-RELEASE
1. Entering DFU mode
opening device 410034000651363038363036 0xddcc
connected
LIBUSB_ERROR_IO [-1]
2. Programming bootstub
programming 0 with length 2048
programming 1 with length 2048
programming 2 with length 2048
programming 3 with length 2048
programming 4 with length 2048
programming 5 with length 2048
programming 6 with length 2048
3. Flashing main code
opening device 410034000651363038363036 0xddee
connected
flash: version is v0.9.7-ac6e0e67-RELEASE
flash: unlocking
flash: erasing
flash: flashing
flash: resetting
opening device 410034000651363038363036 0xddcc
connected
4. Flashing ESP (slow!)
opening device 410034000651363038363036 0xddcc
connected
set baud to 230400
Connecting...
Connection timeout.
Running Cesanta flasher stub...
set baud to 230400
Writing 4096 @ 0x0... 4096 (100 %)
Writing 249856 @ 0x1000... 249856 (100 %)
Writing 249856 @ 0x81000... 249856 (100 %)
Writing 4096 @ 0x3fe000... 
5. Verifying version
opening device 410034000651363038363036 0xddcc
connected
dongle id: 4c537e87061caf72
v0.9.7-ac6e0e67-RELEASE should be v0.9.7-ac6e0e67-RELEASE
6. Success!

ELM327 emulation not working

I recently purchased a Panda to use with Torque (among other ELM compatible applications) but I've found the ELM emulation is not working for the most part. After multiple attempts to get Torque to work I installed an application called ELM327 Identifier and a majority of the protocols are not currently supported. My guess this is what is keeping the application from working correctly. Is this something that is actively being developed?

Thanks,

Adam

Cabana looping curiously

I am seeing a curious behavior with cabana. When I click launch realtime streaming then pairs and connect to the panda, it just brings me back to the same welcome to cabana pop up window, same if I click log in to view recorded drive.

screenshot

The panda blinks purple during the test (steady blue light and red light blinking) which I believe is the expected behavior when reading CAN data, it could be useful to update/extend the leds info on the wiki page. The panda is connected to the computer through USB.

This problem is seen on 4 different machines, two running Linux Ubuntu and two running Windows 7. The problem is both seen on Chrome and Chromium.

The panda is up to date according to Chffr. Chffr works okaishly, it receives messages from the panda and the blue led of the wifi board blinks, although the app has a very hard time uploading the recorded drive. As read from the slack discussions, it seems like there is a trick with plane and wifi modes, it could be interesting to add a paragraph about it to the README and/or wiki. I am using an LG G3.

I have probably missed a part that needs to be accomplished prior to using the panda with cabana. Although with the pandacan library installed and the panda up to date, I don't know what it could be, I guess it's mostly a cabana issue. Also, neither socketcan nor ifconfig detect the device as a CAN device.
I have already posted this issue in the cabana slack channel but, it's a slack channel, not the best place to report an issue.

Thank you for your work.

panda hardware design files?

Hello, I just ordered a Panda and I am curious if there a place I can find the Panada hardware design files?

Thanks,
Drew

pandacan doesn't work: USBErrorBusy: LIBUSB_ERROR_BUSY on python 2 and ModuleNotFoundError: No module named 'dfu' on python 3

python 2:

Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from panda import Panda
Panda.list()
[u'480031000551363338383037']
panda = Panda()
opening device 480031000551363338383037 0xddcc
exception LIBUSB_ERROR_BUSY [-6]
Traceback (most recent call last):
File "/home/burningman/.local/lib/python2.7/site-packages/panda/init.py", line 163, in connect
self._handle.claimInterface(0)
File "/home/burningman/.local/lib/python2.7/site-packages/usb1/init.py", line 1300, in claimInterface
libusb1.libusb_claim_interface(self.__handle, interface),
File "/home/burningman/.local/lib/python2.7/site-packages/usb1/init.py", line 133, in mayRaiseUSBError
__raiseUSBError(value)
File "/home/burningman/.local/lib/python2.7/site-packages/usb1/init.py", line 125, in raiseUSBError
raise __STATUS_TO_EXCEPTION_DICT.get(value, __USBError)(value)
USBErrorBusy: LIBUSB_ERROR_BUSY [-6]
connected
panda.can_recv()
CAN: BAD RECV, RETRYING
CAN: BAD RECV, RETRYING
CAN: BAD RECV, RETRYING
CAN: BAD RECV, RETRYING
CAN: BAD RECV, RETRYING

python 3:

Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

from panda import Panda
Traceback (most recent call last):
File "", line 1, in
File "/home/burningman/.local/lib/python3.6/site-packages/panda/init.py", line 11, in
from dfu import PandaDFU
ModuleNotFoundError: No module named 'dfu'

Drivers installed, 11-panda.rules edited, panda connected through USB cable and led indicates ready to work status. What is the problem ?

finish panda linux kernel driver (please)

The linux kernel driver does not support changing the bitrate of the can bus interfaces.
Changing the bitrate is required for this driver to be useful.

When using the Caribou software (which uses the socket can interfaces provided by this driver) to communicate with my car, Caribou reported it failed to initialize a connection, and the car started to display errors. Since the errors vanished after removing the panda, they are likely due to the inability to change the bitrate through the driver, causing the panda to stay active at the wrong bitrate.

After normal operation returned, my car has artifacting on its dashboard display. I will update this post if it goes away after disconnecting the car battery for 5 minutes.

edit : after few days, I noticed that the dash is normal again, without doing nothing.

updating panda over USB fails

From a linux machine (instructions from panda/UPDATING.md)

$ PYTHONPATH="" sudo python -c "import panda; panda.flash_release()"
Using panda with serial 4d003b000651363038363036
Fetching latest firmware from github.com/commaai/panda-artifacts
Fetching firmware from https://github.com/commaai/panda-artifacts/raw/master/panda-v1.0.1-11d45090-RELEASE.zip
File Name                                             Modified             Size
bootstub.panda.bin                             2017-10-15 17:12:00        12348
panda.bin                                      2017-10-15 17:12:00        19260
user1.bin                                      2017-10-15 17:12:02       246980
user2.bin                                      2017-10-15 17:12:02       246980
boot_v1.5.bin                                  2016-05-20 16:53:08         3232
version                                        2017-10-15 17:12:02           23
0. Preparing to flash v1.0.1-11d45090-RELEASE
1. Entering DFU mode
opening device 4d003b000651363038363036 0xddcc
connected
LIBUSB_ERROR_PIPE [-9]
2. Programming bootstub
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "panda/panda/flash_release.py", line 57, in flash_release
    dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(st_serial))
  File "panda/panda/dfu.py", line 28, in __init__
    raise Exception("failed to open "+dfu_serial)
Exception: failed to open 366B368F3036

ultimately I did get it updated by using panda/release/ota_release.sh but even that threw a strange "wrong!" message

$ ./release/ota_release.sh panda-v1.0.1-11d45090-RELEASE.zip
Archive:  panda-v1.0.1-11d45090-RELEASE.zip
  inflating: /tmp/panda_firmware/bootstub.panda.bin
  inflating: /tmp/panda_firmware/panda.bin
  inflating: /tmp/panda_firmware/user1.bin
  inflating: /tmp/panda_firmware/user2.bin
  inflating: /tmp/panda_firmware/boot_v1.5.bin
 extracting: /tmp/panda_firmware/version
<pre>This is your comma.ai panda<br/><br/>It's open source. Find the code <a href="https://github.com/commaai/panda">here</a><br/>Designed to work with our dashcam, <a href="http://chffr.comma.ai">chffr</a><br/><br/>ssid: panda-07f39d76c38bc541<br/><br/>st version:     v1.0.1-11d45090-RELEASE<br/>esp version:    v1.0.1-11d45090-RELEASE<br/>esp flash file: user2.binflashing user1
wrong!
flashing user2
success!
waiting 10s for reboot
flashing st
success!
<pre>This is your comma.ai panda<br/><br/>It's open source. Find the code <a href="https://github.com/commaai/panda">here</a><br/>Designed to work with our dashcam, <a href="http://chffr.comma.ai">chffr</a><br/><br/>ssid: panda-07f39d76c38bc541<br/><br/>st version:     v1.0.1-11d45090-RELEASE<br/>esp version:    v1.0.1-11d45090-RELEASE<br/>esp flash file: user1.bindone

Issue w/ make recover

There is an issue with make recover. Running make recover from older source code resolves the issue once your panda gets in this bad state.

Steps to reproduce issue:

  1. connect panda
  2. checkout master branch
  3. run make recover && make

make recover will succeed and make will hang. below is the output.

this does not appear to be an issue with grey pandas
update - this issue exists on both white and grey panda (must not have run make recover on grey panda previously)

$ make recover && make
echo "const uint8_t gitversion[] = \"v1.0.8-90c64b6c-"DEBUG"\";" > obj/gitversion.h
arm-none-eabi-gcc -g -Wall -mlittle-endian -mthumb -mcpu=cortex-m4 -mhard-float -DSTM32F4 -DSTM32F413xx -I inc -I ../ -nostdlib -fno-builtin -std=gnu11 -O2-Tstm32_flash.ld "-DALLOW_DEBUG" -o obj/bootstub.panda.o -c bootstub.c
arm-none-eabi-gcc -g -Wall -mlittle-endian -mthumb -mcpu=cortex-m4 -mhard-float -DSTM32F4 -DSTM32F413xx -I inc -I ../ -nostdlib -fno-builtin -std=gnu11 -O2-Tstm32_flash.ld "-DALLOW_DEBUG" -o obj/bootstub.panda.elf obj/startup_stm32f413xx.o obj/bootstub.panda.o obj/sha.panda.o obj/rsa.panda.o
arm-none-eabi-objcopy -v -O binary obj/bootstub.panda.elf obj/bootstub.panda.bin
copy from `obj/bootstub.panda.elf' [elf32-littlearm] to `obj/bootstub.panda.bin' [binary]
arm-none-eabi-gcc -g -Wall -mlittle-endian -mthumb -mcpu=cortex-m4 -mhard-float -DSTM32F4 -DSTM32F413xx -I inc -I ../ -nostdlib -fno-builtin -std=gnu11 -O2-Tstm32_flash.ld "-DALLOW_DEBUG" -o obj/main.panda.o -c main.c
arm-none-eabi-gcc -Wl,--section-start,.isr_vector=0x8004000 -g -Wall -mlittle-endian -mthumb -mcpu=cortex-m4 -mhard-float -DSTM32F4 -DSTM32F413xx -I inc -I../ -nostdlib -fno-builtin -std=gnu11 -O2 -Tstm32_flash.ld "-DALLOW_DEBUG" -oobj/panda.elf obj/startup_stm32f413xx.o obj/main.panda.o
arm-none-eabi-objcopy -v -O binary obj/panda.elf obj/code.bin
copy from `obj/panda.elf' [elf32-littlearm] to `obj/code.bin' [binary]
SETLEN=1 ../crypto/sign.py obj/code.bin obj/panda.bin ../certs/debug
signing 25140 bytes
hash: 52be6bff8d49a71a64a6ad54d339af6b3d69223b
PYTHONPATH=../ python -c "from python import Panda; Panda().reset(enter_bootloader=True)"
opening device 4d003b000651363038363036 0xddcc
connected
sleep 1.0
"dfu-util" -d 0483:df11 -a 0 -s 0x08004000 -D obj/panda.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash  "
Downloading to address = 0x08004000, size = 25268
Download        [=========================] 100%        25268 bytes
Download done.
File downloaded successfully
"dfu-util" -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.panda.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash  "
Downloading to address = 0x08000000, size = 11340
Download        [=========================] 100%        11340 bytes
Download done.
File downloaded successfully
Transitioning to dfuMANIFEST state
PYTHONPATH=../ python -c "from python import Panda; Panda().flash('obj/panda.bin')"
opening device 4d003b000651363038363036 0xddcc
connected
reconnecting is taking 1 seconds...
reconnecting is taking 2 seconds...
reconnecting is taking 3 seconds...
(at this point it hangs and panda is flashing a blue light fast)

can't reliably sending first message for reading VIN

I am trying to read the VIN from my 2017 CR-V and after connecting to the panda over USB the first message usually receives no response. If I repeat sending the message it seems to reliably succeed on subsequent calls.

Here is how I can reliably reproduce this with my car:

#!/usr/bin/env python
import time
import struct
from panda import Panda
from isotp import isotp_send, isotp_recv

if __name__ == "__main__":
  panda = Panda()
  panda.set_safety_mode(Panda.SAFETY_ELM327)

  panda.can_clear(0)
  time.sleep(0.1)

  for z in range(0,3):
    addr = 0x18DA10F1
    msg = "\x02\x09\x02".ljust(8, "\x00")
    print "S:", format(addr,'x'), msg.encode("hex")
    panda.can_send(addr, msg, 0)
    more = False
    for x in range(0, 100):
      msgs = panda.can_recv()
      for ids, ts, dat, bus in msgs:
        if bus == 0 and ids == ((addr >> 16 << 16) | (addr << 8 & 0xFFFF) | (addr >> 8 & 0xFF)):
          print "R:", format(ids,'x'), ("".join("%02x" % i for i in dat))
          print dat[5:]
          msg = "\x30\x00\x00".ljust(8, "\x00")
          panda.can_send(addr, msg, 0)
          print "S:", format(addr,'x'), msg.encode("hex")
          more = True
          break

      if more:
        break

    if more:
      for x in range(0, 100):
        msgs = panda.can_recv()
        for ids, ts, dat, bus in msgs:
          #if bus == 0 and ids == ((addr >> 16 << 16) | (addr << 8 & 0xFFFF) | (addr >> 8 & 0xFF)):
          if bus == 0 and ids>>16 == addr>>16:
            print "R:", format(ids,'x'), ("".join("%02x" % i for i in dat))
            print dat[1:]
    else:
      print "failed!"

  print "done"

here is the output (notice that the first iteration of the outer loop says failed! and the next two iterations successfully read the entire VIN):

$ sudo python query_vin_and_stats.py
opening device 4d003b00xxxxxxxxxxxxxxxx 0xddcc
connected
S: 18da10f1 0209020000000000
failed!

S: 18da10f1 0209020000000000
R: 18daf110 1014490201354a36
5J6
S: 18da10f1 3000000000000000
R: 18daf110 2152573248393248
RW2H92H
R: 18daf110 22xxxxxxxxxxxxxx
XXXXXXX

S: 18da10f1 0209020000000000
R: 18daf110 1014490201354a36
5J6
S: 18da10f1 3000000000000000
R: 18daf110 2152573248393248
RW2H92H
R: 18daf110 22xxxxxxxxxxxxxx
XXXXXXX

done

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.