Skip to content
Permalink
Browse files

Merge commit 'dba8e01e540f8b6b231be082ee6d36304aa1997d' as 'panda'

  • Loading branch information...
Vehicle Researcher
Vehicle Researcher committed Jun 28, 2019
2 parents 27803e7 + dba8e01 commit 983120bfed09ad9331fa96be3143a604c9a1a179
Showing 322 changed files with 61,961 additions and 0 deletions.
@@ -0,0 +1,110 @@
version: 2
jobs:
safety:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
name: Build image
command: "docker build -t panda_safety -f tests/safety/Dockerfile ."
- run:
name: Run safety test
command: |
docker run panda_safety /bin/bash -c "cd /panda/tests/safety; ./test.sh"
misra-c2012:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
name: Build image
command: "docker build -t panda_misra -f tests/misra/Dockerfile ."
- run:
name: Run Misra C 2012 test
command: |
mkdir /tmp/misra
docker run -v /tmp/misra:/tmp/misra panda_misra /bin/bash -c "cd /panda/tests/misra; ./test_misra.sh"
- store_artifacts:
name: Store cppcheck test output
path: /tmp/misra/cppcheck_output.txt
- store_artifacts:
name: Store misra test output
path: /tmp/misra/misra_output.txt
- store_artifacts:
name: Store cppcheck safety test output
path: /tmp/misra/cppcheck_safety_output.txt
- store_artifacts:
name: Store misra safety test output
path: /tmp/misra/misra_safety_output.txt


strict-compiler:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
name: Build image
command: "docker build -t panda_strict_compiler -f tests/build_strict/Dockerfile ."
- run:
name: Build Panda with strict compiler rules
command: |
docker run panda_strict_compiler /bin/bash -c "cd /panda/tests/build_strict; ./test_build_strict.sh"
build:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
name: Build image
command: "docker build -t panda_build -f tests/build/Dockerfile ."
- run:
name: Test python package installer
command: |
docker run panda_build /bin/bash -c "cd /panda; python setup.py install"
- run:
name: Build Panda STM image
command: |
docker run panda_build /bin/bash -c "cd /panda/board; make bin"
- run:
name: Build Panda STM bootstub image
command: |
docker run panda_build /bin/bash -c "cd /panda/board; make obj/bootstub.panda.bin"
- run:
name: Build Pedal STM image
command: |
docker run panda_build /bin/bash -c "cd /panda/board/pedal; make obj/comma.bin"
- run:
name: Build Pedal STM bootstub image
command: |
docker run panda_build /bin/bash -c "cd /panda/board/pedal; make obj/bootstub.bin"
- run:
name: Build ESP image
command: |
docker run panda_build /bin/bash -c "cd /panda/boardesp; make user1.bin"
safety_replay:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
name: Build image
command: "docker build -t panda_safety_replay -f tests/safety_replay/Dockerfile ."
- run:
name: Replay drives
command: |
docker run panda_safety_replay /bin/bash -c "cd /openpilot/panda/tests/safety_replay; PYTHONPATH=/openpilot ./test_safety_replay.py"
workflows:
version: 2
main:
jobs:
- safety
- misra-c2012
- strict-compiler
- build
- safety_replay
@@ -0,0 +1,3 @@
.git
.DS_Store
boardesp/esp-open-sdk
@@ -0,0 +1,15 @@
*.pyc
.*.swp
.*.swo
*.o
*.so
*.d
a.out
*~
.#*
dist/
pandacan.egg-info/
board/obj/
examples/output.csv
.DS_Store
nosetests.xml
@@ -0,0 +1,62 @@
FROM ubuntu:16.04
ENV PYTHONUNBUFFERED 1

RUN apt-get update && apt-get install -y \
autoconf \
automake \
bash \
bison \
bzip2 \
curl \
dfu-util \
flex \
g++ \
gawk \
gcc \
git \
gperf \
help2man \
iputils-ping \
libexpat-dev \
libstdc++-arm-none-eabi-newlib \
libtool \
libtool-bin \
libusb-1.0-0 \
make \
ncurses-dev \
network-manager \
python-dev \
python-serial \
sed \
texinfo \
unrar-free \
unzip \
wget \
build-essential \
python-dev \
python-pip \
screen \
vim \
wget \
wireless-tools

RUN pip install --upgrade pip==18.0

COPY requirements.txt /tmp/
RUN pip install -r /tmp/requirements.txt

RUN mkdir -p /home/batman
ENV HOME /home/batman

ENV PYTHONPATH /tmp:$PYTHONPATH

COPY ./boardesp/get_sdk_ci.sh /tmp/panda/boardesp/

RUN useradd --system -s /sbin/nologin pandauser
RUN mkdir -p /tmp/panda/boardesp/esp-open-sdk
RUN chown pandauser /tmp/panda/boardesp/esp-open-sdk
USER pandauser
RUN cd /tmp/panda/boardesp && ./get_sdk_ci.sh
USER root

ADD ./panda.tar.gz /tmp/panda
@@ -0,0 +1,53 @@
pipeline {
agent any
environment {
AUTHOR = """${sh(
returnStdout: true,
script: "git --no-pager show -s --format='%an' ${GIT_COMMIT}"
).trim()}"""

DOCKER_IMAGE_TAG = "panda:build-${env.GIT_COMMIT}"
DOCKER_NAME = "panda-test-${env.GIT_COMMIT}"
}
stages {
stage('Build Docker Image') {
steps {
timeout(time: 60, unit: 'MINUTES') {
script {
sh 'git archive -v -o panda.tar.gz --format=tar.gz HEAD'
dockerImage = docker.build("${env.DOCKER_IMAGE_TAG}")
}
}
}
}
stage('Test Dev Build') {
steps {
lock(resource: "Pandas", inversePrecedence: true, quantity:1){
timeout(time: 60, unit: 'MINUTES') {
sh "docker run --name ${env.DOCKER_NAME} --privileged --volume /dev/bus/usb:/dev/bus/usb --volume /var/run/dbus:/var/run/dbus --net host ${env.DOCKER_IMAGE_TAG} bash -c 'cd /tmp/panda; ./run_automated_tests.sh '"
}
}
}
}
stage('Test EON Build') {
steps {
lock(resource: "Pandas", inversePrecedence: true, quantity:1){
timeout(time: 60, unit: 'MINUTES') {
sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_dev.xml"
sh "touch EON && docker cp EON ${env.DOCKER_NAME}:/EON"
sh "docker start -a ${env.DOCKER_NAME}"
}
}
}
}
}
post {
always {
script {
sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_EON.xml"
sh "docker rm ${env.DOCKER_NAME}"
}
junit "test_results*.xml"
}
}
}
@@ -0,0 +1,7 @@
Copyright (c) 2016, Comma.ai, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,95 @@
Welcome to panda
======

[panda](http://github.com/commaai/panda) is the nicest universal car interface ever.

<a href="https://comma.ai/shop/products/panda-obd-ii-dongle"><img src="https://github.com/commaai/panda/blob/master/panda.png">

<img src="https://github.com/commaai/panda/blob/master/buy.png"></a>

It supports 3x CAN, 2x LIN, and 1x GMLAN. It also charges a phone. On the computer side, it has both USB and Wi-Fi.

It uses an [STM32F413](http://www.st.com/en/microcontrollers/stm32f413-423.html?querycriteria=productId=LN2004) for low level stuff and an [ESP8266](https://en.wikipedia.org/wiki/ESP8266) for Wi-Fi. They are connected over high speed SPI, so the panda is actually capable of dumping the full contents of the busses over Wi-Fi, unlike every other dongle on amazon. ELM327 is weak, panda is strong.

It is 2nd gen hardware, reusing code and parts from the [NEO](https://github.com/commaai/neo) interface board.

[![CircleCI](https://circleci.com/gh/commaai/panda.svg?style=svg)](https://circleci.com/gh/commaai/panda)

Usage (Python)
------

To install the library:
```
# pip install pandacan
```

See [this class](https://github.com/commaai/panda/blob/master/python/__init__.py#L80) 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)
```
Find user made scripts on the [wiki](https://community.comma.ai/wiki/index.php/Panda_scripts)

Usage (JavaScript)
-------

See [PandaJS](https://github.com/commaai/pandajs)


Software interface support
------

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

- [User space](https://github.com/commaai/panda/tree/master/python)
- [socketcan in kernel](https://github.com/commaai/panda/tree/master/drivers/linux) (alpha)
- [ELM327](https://github.com/commaai/panda/blob/master/boardesp/elm327.c)
- [Windows J2534](https://github.com/commaai/panda/tree/master/drivers/windows)

Directory structure
------

- board -- Code that runs on the STM32
- boardesp -- Code that runs on the ESP8266
- drivers -- Drivers (not needed for use with python)
- python   -- Python userspace library for interfacing with the panda
- tests -- Tests and helper programs for panda

Programming (over USB)
------

[Programming the Board (STM32)](board/README.md)

[Programming the ESP](boardesp/README.md)


Debugging
------

To print out the serial console from the STM32, run tests/debug_console.py

To print out the serial console from the ESP8266, run PORT=1 tests/debug_console.py

Safety Model
------

When a panda powers up, by default it's in "SAFETY_NOOUTPUT" mode. While in no output mode, the buses are also forced to be silent. In order to send messages, you have to select a safety mode. Currently, setting safety modes is only supported over USB.

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

Hardware
------

Check out the hardware [guide](https://github.com/commaai/panda/blob/master/docs/guide.pdf)

Licensing
------

panda software is released under the MIT license unless otherwise specified.
@@ -0,0 +1,31 @@
** Projects **

== ELM327 Emulator ==

Write an elm327 emulator in boardesp/elm327.c and make it work with Torque

You'll find a start at this in the "elm327" branch.

== socketcan Kernel Driver ==

Write a kernel driver version of lib/panda.py that exposes the Panda on socketcan and makes it work with those tools.

You may want to switch to interrupt endpoint first. Should LIN be exposed as a serial interface?

== Windows J2534 DLL ==

Write a Windows DLL that exposes the J2534 API.

Will make the Panda work with car diagnostic software.


** Refactors **

== USB Interrupt Endpoint ==

Switch USB to use an interrupt endpoint instead of a bulk endpoint for can recv

== WebSocket Support ==

Add CAN streaming over WebSocket to the ELM code in addition to the UDP pipe.

@@ -0,0 +1,9 @@
# Updating your panda

Panda should update automatically via the [Chffr](http://chffr.comma.ai/) app ([apple](https://itunes.apple.com/us/app/chffr-dash-cam-that-remembers/id1146683979) and [android](https://play.google.com/store/apps/details?id=ai.comma.chffr))

If it doesn't however, you can use the following commands on linux or Mac OSX
`sudo pip install --upgrade pandacan`
` PYTHONPATH="" sudo python -c "import panda; panda.flash_release()"`

(You'll need to have `pip` and `sudo` installed.)
@@ -0,0 +1 @@
v1.4.0
@@ -0,0 +1 @@
from .python import Panda, PandaWifiStreaming, PandaDFU, ESPROM, CesantaFlasher, flash_release, BASEDIR, ensure_st_up_to_date, build_st, PandaSerial

0 comments on commit 983120b

Please sign in to comment.
You can’t perform that action at this time.