Commit Graph

397 Commits

Author SHA1 Message Date
Willem Melching d5bd81e5b5 fixes for mypy check for return-any 2022-05-12 14:22:58 +02:00
Shane Smiskol eb662e4e50
Make safety param uint16_t (#931)
* change safety param to uint16_t

* accidental paste
2022-05-02 13:36:19 -07:00
Shane Smiskol 326cc2a8db
Toyota: stock longitudinal safety (#927)
* safety for non-longitudinal

* flip around param for easily replaying old logs on new panda

* fix misra: a function parameter should not be modified

* safety

* the toyota tests all share common messages

* fixup tests

* update comment

* same as tesla test

* check if subset

* update comments

update comments
2022-04-28 22:29:29 -07:00
Shane Smiskol cf8fb0b883
safety param: assume uint16_t (#929) 2022-04-28 17:40:50 -07:00
Adeeb Shihadeh d031d6e283
Toyota: add safety param flag for alt brake message (#925)
* Toyota: add safety param flag for alt brake message

* fix misra

* Update board/safety/safety_toyota.h
2022-04-27 11:31:24 -07:00
Comma Device 5eefc3ad62 allow skipping DFU entrance for recover 2022-04-25 17:11:27 -07:00
Shane Smiskol 7dd9493eb1
safety_param: change to unsigned (#910)
* make safety_param unsigned

* final one

* uint32_t

* change flags as well

* Revert "change flags as well"

This reverts commit ed8897dd86.

* unsigned

* update health packet version

update health packet version

* update struct H->I

* bump health version

* actually used
2022-04-20 23:25:03 -07:00
Robbe Derks cc0fdffee6
Calculate interrupt load and add to health packet (#913)
* calculate interrupt load

* forgot to change this

* being cautious about overflows

* utils

* fix bootstub

* cleanup

* also exclude pedal

* fix misra

Co-authored-by: Comma Device <device@comma.ai>
2022-04-11 11:59:47 +02:00
Shane Smiskol 81246fdac1
move alternative experience class to python module (#909)
* move alternative experience class to common python module

* same formatting
2022-04-04 18:49:56 -07:00
Greg Hogan ab693a22d5 UDS DTC number and status helpers 2022-04-04 17:55:11 -07:00
Igor Biletskyy 93863197dd
add safety mode for body (#901)
* safety mode for body

* move to 27

* dmm...

* misra..

* add faw to safety list

* missing safety modes in python lib

* dmm

* change address to 250

* add 0x1 addr for can flasehr

* whitespace
2022-03-31 12:02:19 -07:00
Shane Smiskol 7104818e14
rename unsafeMode to alternativeExperience (#878)
* alternative experiences

* not unsafe

* more renames

more renames

* not yet true

* I think we import from panda now

* update comments and test

* not needed

* bump health pkt version

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-03-24 14:31:31 -07:00
Igor Biletksyy 234e436e93 rename to enable_deepsleep 2022-03-07 14:32:14 -08:00
Igor Biletskyy de7e1e7579
Deep sleep(stop) mode for pandas (#832)
* Add RTC with LSI for BP, GP, WP

* disable jenkins temporarily, REVERT!

* experiments

* cleanup is still needed

* cppcheck unused suppress

* raise deepsleep limit timeout to 120sec

* more experiments on usb_enumerated

* continue

* soft_disconnect

* almost done

* not enough

* no ignition

* still don't like it..

* rename to has_rtc_battery

* clock_source on the way!?

* delay 3 sec

* works on C3, needs test on C2

* And this is for C2

* disable bootkick

* misra 10.4

* ..

* ..

* set power state the right way

* change that

* seems don't need that? check on C2/C3

* partially works on RP...

* comments (will work after rebase)

* change fault name

* switch to manual activation mode

* Revert "disable jenkins temporarily, REVERT!"

This reverts commit 578d425fa7.

* my dear pedal!
2022-03-07 14:24:04 -08:00
Adeeb Shihadeh 2806eecea2 python: add safety param arg to set_safety_mode 2022-02-20 19:38:08 -08:00
Adeeb Shihadeh 9d27011ec2
misc CAN FD fixes (#856)
Co-authored-by: Comma Device <device@comma.ai>
2022-02-20 17:13:22 -08:00
Igor Biletskyy 48f8c5f701
Remove CLOCK_SOURCE_MODE_EXTERNAL_SYNC (#847)
* remove CLOCK_SOURCE_MODE_EXTERNAL_SYNC

* remove from python lib
2022-02-09 07:42:44 -08:00
Adeeb Shihadeh 00138a7f66
Add blocked message counter to health packet (#841)
* Add blocked message counter to health packet

* move that

* update python

* fix struct

Co-authored-by: Comma Device <device@comma.ai>
2022-01-27 17:46:24 -08:00
Shane Smiskol 8ee7b62ea2
Add unsafe mode to health packet (#829)
* add unsafe_mode to health packet

this compiles

update health packet

fixes

ahh forgot to set it!

not actually needed

update indices

* fix struct

Co-authored-by: Willem Melching <willem.melching@gmail.com>
2022-01-25 11:35:57 +01:00
Adeeb Shihadeh 6f95a096e6
safety: add controls heartbeat (#806)
* safety: add controls heartbeat

* one more second

* better comments
2021-12-15 17:28:57 -08:00
Igor Biletskyy 493866d15b
Cleanup Wi-Fi leftovers (#804)
* cleanup python lib

* remove wifi leftovers from firmware

* few spots in firmware

* forgot

* remove usb to wifi test

* linter

* more cleanup in flasher.h

* more found

* check in tests too

* linter
2021-12-06 14:39:28 -08:00
Adeeb Shihadeh c9992a80c0 bosch_harness -> bosch 2021-11-21 14:51:47 -08:00
Robbe Derks ddb3698f9b
Tesla longitudinal safety (#737)
* tesla safety cleanup + long WIP

* more long safety

* longitudinal safety tests

* fix misra

* add safety for main bus DAS_control

* acc_state is not enabled

* fix tests

* we don't want this

* fix Tesla common test
2021-11-18 13:50:10 +01:00
Adeeb Shihadeh fec966d6fd
Honda: handle ACC state consistent with ISO 15622:2018 (#789) 2021-11-17 17:27:24 -08:00
Igor Biletskyy c8b48ec23a
Enable CAN FD support (#772)
* enable CAN FD

* ...
2021-11-15 16:27:16 -08:00
Igor Biletskyy ae26b75d7b
CAN_FIFOMailBox to CANPacket struct + USB dynamic packet size (#739)
* Squashed commits, no cleanup

* Few fixes

* No init = garbage

* Only receive with new canpacket

* Add send with canpacket

* Revert "Add send with canpacket"

This reverts commit 7d06686ddd6d447c714b5289d31af24403d36931.

* Packet must be aligned to word, or bad performance

* Cleaner

* Fix tests

* Tests...

* MISRA 10.4

* More MISRA

* libpandasafety_py

* cffi

* even more tests...

* typo

* ...

* ...

* ...

* Slight cleanup

* MISRA 6.1

* MISRA 17.7

* Bug in bxcan + even style

* MISRA 10.1

* Revert "MISRA 10.1"

This reverts commit 404ae7fcc39556f80f528de9015702e69f4ea0a5.

* ...

* MISRA 10.1 and 10.4 suppress until next PR

* MISRA 20.1

* ...

* test_honda

* ...

* ...

* test_toyota

* test_volkswagen_mqb

* test_volkswagen_pq

* Sketchy thing...

* Revert "Sketchy thing..."

This reverts commit 3b2e5715bdc1954f7b7b3b7469ba3d0eaa06bdf9.

* remove comment

* bxcan extended address bug

* Concept, experimental dynamic usb packet size

* increase each buffer to 10240 bytes

* raise python bulk read/write limits

* ...

* Move packet size to start

* Experimental send, stream-like

* New receive test, stream-like

* cleanup

* cleanup + rebase fixes

* MISRA

* Extra receive method, stream-like, commented out

* type change

* Revert back to buffer for send, stream commented

* forgot ZLP

* lower buffer, add rx failsafe

* ... remove ZLP

* return ZLP back

* Add tx checks to panda fw

* TX stream with counter

* fix counter overflow

* 13 free slots should be enough

* limit tx usb packet

* ...

* Revert max_bulk_msg doubling

* python lib improve speed

* Stream with counter for RX, dirty, needs cleanup

* Increase chunk length to 4096 bytes

* cleanup fdcan.h

* cleanup __init__.py

* MISRA 12.1

* MISRA 10.8

* remove non-streaming usb functions

* more main.c cleanup

* MISRA 15.6

* MISRA 15.5

* MISRA 18.4 and suppress objectIndex

* handling usb pakcets > 63bytes, naming and cleanup

* Cleanup old from tests and update CANPacket_t struct

* Switch to 4 bit DLC instead of 6 bit length

* ops)

* ...

* pylint

* receive python buffer increase

* USB increase receive packet len

* tweak buffers

* No need for so high limits

* MISRA 20.1 workaround

* performance tweaks

* cleanup, dlc to data_len_code naming

* main.c naming

* comments and cleanup for main.c usb

* clean py lib

* pylint

* do not discard good rx messages on stream fail

* cleanups

* naming

* remove bitstruct lib and lower tx limit

* bitstruct lefovers

* fix bug in VW test

* remove adjusting data size and assert on wrong len

* ...

* test new memcpy before merging

* Revert "test new memcpy before merging"

This reverts commit 399465a264835061adabdd785718c4b6fc18c267.

* macros for to/fromuint8_t array

* MISRA hates me!

* tests.c include macros instead

* move CANPacket to can_definitions.h

* vw_pq python test fix

* new memcpy test, REMOVE

* check without alignment

* revert macros for uint8 arrays

* Revert "revert macros for uint8 arrays"

This reverts commit 581a9db735a42d0d68200bd270d87a8fd34e43fe.

* check assert

* Revert "check assert"

This reverts commit 9e970d029a50597a1718b2bb0260196c050fd77f.

* one more variation

* Revert "one more variation"

This reverts commit f6c0528b7ac7e125750dc0d9445c7ce97f6954b5.

* what about read performance

* Revert "what about read performance"

This reverts commit d2610f90958a816fe7f1822157a84f85e97d9249.

* check struct alignment to word

* check for aligned memcpy again

* cleanup

* add CANPacket structure diagram

* update CANPacket and add USB packet struct

* bugfix + refactoring of EP1

* move dlc_to_len to header

* missed include

* typo...

* MISRA

* fk

* lower MAX_CAN_MSGS_PER_BULK_TRANSFER

* bump CAN_PACKET_VERSION to 2

* bump python lib CAN_PACKET_VERSION to 2

* rename parse_can_buffer to unpack_can_buffer

* CANPacket_t const fields

* Revert "CANPacket_t const fields"

This reverts commit cf91c035b7706a14e317550c5f0501ae3fce7c70.

* test.c relative path

* cleanup

* move macros to safety_declarations

* Refactor pack/unpack funcs and add unittest

* usb_protocol.h

* oops

* Update .github/workflows/test.yaml

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* remove print from unittest

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2021-11-12 16:36:34 -08:00
Igor Biletskyy b4b14593a0
Check panda library and firmware for compatibility (#770)
* check panda lib and firmware compatibility

* skip comp check for pedal

* ...

* guard affected funcs and print to stderr

* ...

* ...

* ..

* decorators

* test workaround

* linter

* ...

* ...

* ...

* change request address

* split

* remove compatible variable

* ...

* remove compatibility_check

* get packets versions on connect

* fix linter

* use RuntimeError

Co-authored-by: Willem Melching <willem.melching@gmail.com>
2021-11-11 14:30:52 +01:00
Greg Hogan 605980ea03
CAN calibration protocol (CCP) python library (#640)
* CAN calibration protocol lib

* fix bugs

* allow specifying byte order

* enum for endian

* fix linting issues

* fix linting issues
2021-10-31 15:06:47 -07:00
Adeeb Shihadeh 5f5f30eedc remove forwarding from python lib 2021-10-29 11:18:42 -07:00
Greg Hogan c5adfa4ece
Fix bulk transfer dropping messages sometimes (#729)
* fix max messages per bulk transfer

* retry on partial send

* need 2x the packet size for some reason

* improve bulk write test
2021-10-15 18:14:55 -07:00
Greg Hogan 288cbf65d1
uds: update security access and i/o control services (#738) 2021-10-10 00:45:59 -07:00
Robbe Derks e3dd1622c3 add get_usb_serial() 2021-10-08 12:17:06 +02:00
Robbe Derks d5ddd4a03e added is_internal() 2021-10-08 12:10:28 +02:00
Greg Hogan fcd064345a
python: disable power save by default when setting safety mode (#725)
* python: disable power save by default when setting safety mode

* no need to set power save manually

* Update python/__init__.py

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2021-09-23 23:12:36 -07:00
Greg Hogan 2570770f7b
UDS: add response pending timeout (#723)
* Extend ISO-TP subsequent frame timeout, add response pending timeout and extra debug info

* Change response_pending to local variable, move response_pending_timeout to UdsClient, update ISO-TP debug output

* Set UDS request pending timeout to 6 seconds (ISO 14229-2:2013 section 7.2 recommended value + 1 second latency)

* manage response pending in single location

* more generous response pending timeout

* add tx timeout

* fix lint error

* fix rx addr for 29 bit addrs

* fix linting issue

Co-authored-by: Martin Lillepuu <martin@mlp.ee>
2021-09-23 18:21:21 -07:00
Willem Melching dd22fafc3c
Hyundai longitudinal (#711)
* Hyundai longitudinal

* return right addr checks

* add flag to pythong

* fix define

* check for stock ecu

* add rx check for buttons

* Block FCA11 actuation

* misra

* review 1

* comment about scaling

* clean up buttons

* use define for flag

* more extensive button checking

* check for AEB in scc12

* unsigned

* add knockout tests

* more unsigned

* cleaner
2021-09-13 20:41:10 -07:00
Dange 1befaad8b0
Fix assert error when flashing release (#717) 2021-09-10 08:19:13 -07:00
Igor Biletskyy 1b301600ee
add few mcu config consts, add exports (#704) 2021-08-03 18:26:33 -07:00
Igor Biletskyy ad90646001
Support for STM32H7 and Red Panda (#694)
* H7 drivers

* Include H7 into the code

* fix flash write for H7

* get serial from flasher.h from F4 and H7

* flash.sh and recover.sh for gen3

* add set_data_speed for BRS CAN FD

* build all fws

* gen3 to panda lib

* gen3 name in scons project

* disable fd can and brs

* gen3 to CI tests

* jenkins fix for new tests and build_all

* fix pedal test

* pedal in panda tests again...

* cleanup llfdcan.h

* cleanup clock.h

* Add LDORDY bit check instead of delay

* missing define in stm32h735xx.h lib

* board_id helper

* enable debug detection again

* clean gpio inits

* fix board_id helper, make cleaner

* comment MCUs in stm lib for faster misra

* target MCU

* misra-5.5

* improve headers and misra speed

* cleanup CI tests

* change naming from gen3 to h7

* readable if statement

* cleanup llusb.h

* only cycle one transceifer in bus-off

* move unused funcs to common header

* bus_off_err reset

* misra 10.4 fdcan

* extern to can_data_speed variable

* limit can_data_speed array size to 3

* reinit fd can on data speed change

* Improve test with ELM327 and extaddr check

* bugfix for fdcan

* panda python config naming

* abstracted init request in llfdcan

* misra fdcan

* Improve llusb.h for H7
2021-08-02 20:26:15 -07:00
Igor da8a76f1b3
Deprecate bcdDevice and legacy mode from panda lib and tests (#692) 2021-07-14 13:30:59 -07:00
Adeeb Shihadeh 7f12eb87b7 fix dos identifier 2021-07-08 00:37:14 -07:00
Adeeb Shihadeh b2986180a8 add dos to python lib 2021-07-08 00:36:25 -07:00
Igor f356825443
Add pedal check to panda lib (#678) 2021-07-02 14:27:04 -07:00
robbederks 9ad4ef5556
add baudrate property and flush method for better compatibility (#677) 2021-07-01 15:34:46 +02:00
Willem Melching d7b3ae0282
Extra checks for Honda Bosch Longitudinal (#662)
* only allow tester present

* ensure radar is not sending messages

* cleanup

* add honda flags

* Constrain tester present message exactly

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* little endian

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2021-06-22 15:29:47 +02:00
Adeeb Shihadeh 78c24982a9
Remove non-EON panda build (#671)
* Remove non-EON panda build

* missed that

* fixup readme

* more readme

* simplify ci

* add USB command to disable heartbeat checks in debug mode

* clean that up too

* more cleanup

* fix path

* disable heartbeat in set_safety_mode

* more red

* remove one more EON ref
2021-06-21 13:54:09 -07:00
Adeeb Shihadeh e99d41e6cf
add flag to health inidicate heartbeat loss (#654)
* add flag to health inidicate heartbeat loss

* fix len
2021-06-04 22:07:45 -07:00
Robbe Derks 22556b1ddf fix health in python 2021-05-03 14:59:36 +02:00
Willem Melching a65c45d5e7 uds.py: fix typo in response description 2021-04-17 22:11:30 +02:00
Willem Melching d6225226ac fix panda connect on macOS 2021-04-16 15:32:27 +02:00
Willem Melching ad9ecefe65
Switch panda to scons builder (#635)
* add scons builder

* cleanup 1

* remove building from python code

* add pedal build

* fixup flags

* add EON flag

* change github actions to scons

* fixup automated tests

* move flashing scripts

* fix indent

* remove version.mk

* fix not in git

* fix linker script filename

* untested pedal flashing scripts

* add release option

* better asserts

* swap condition

* enable usb and fix flash script

* usb flash is not supported

* use button to enable dfu mode

* no usb because misra

* remove sleep
2021-03-24 14:44:32 +01:00
Jason Young 3bb0408ee6
Add support for variable UDS RX offsets (#631) 2021-03-07 20:33:55 -08:00
George Hotz e035fa1d09
green led on 0xf7 (#619)
* green led on 0xf7

* add python interface

Co-authored-by: Robbe Derks <robbe.derks@gmail.com>
2021-01-05 14:51:58 +01:00
Robbe Derks 09997428f3 Fixed transceiver spelling 2020-09-28 16:19:09 +02:00
Robbe Derks 229047d7c2 fix flash_release 2020-09-07 10:26:27 +02:00
Adeeb Shihadeh 8b41ed3b81
Deprecate ESP (#592)
* remove unused wifi tests

* remove that one too

* no bootmode from ESP

* clean that up

* remove two more wifi tests

* remove boardesp and esptool

* esp_gps -> gps

* missed those

* remove esptool refs

* remove esp certs

* no more wifi

* that was old

* cleanup jenkins dockerfile

* fix linter

* remove more wifi refs

* clone panda jungle from github

* no copy

* always default esp to off
2020-08-26 15:37:50 -07:00
robbederks 1515ec8bf5
Siren (#594)
* siren

* fix pedal

* update fault rate

Co-authored-by: Tici <robbe@comma.ai>
2020-08-17 15:04:01 +02:00
robbederks c3b02f3a74
Clock source driver (#580)
* Initial clock source implementation

* fix misra?

* Working now. Still need to fix board detection though

* Always stop pulse

* revert board detection bodge

Co-authored-by: Tici <robbe@comma.ai>
2020-08-17 13:02:41 +02:00
Greg Hogan 390b8bce81
k-line 5 baud init (#565)
* k-line slow init

* k-line slow init LED bit blink

* fix misra violations

* better names for k-line methods

* debug prints match names

* switch to timer

* use TIM4 until I figure out TIM5

* tickle faster

* fix bit bug and add stop bit

* TIM5 working

* USB return after addr sent

* fix l-line reset

* fix misra violations

* blink for the ones instead of the zeros

* k-line 5 baud fault type

* lin check

* use TIM5 or wakeup

* better names
2020-07-10 14:18:24 -07:00
Greg Hogan 31f8a0d862
K line fix (#559)
* enable UART RX interrupts

* update debug prints for python3

* improve kline functions and fix checksum

* k-line wake-up conforming to KWP2000 fast init

* fix timing

* toggle k and l line together by default

* k-line wakeup using timer

* k and l were flipped

* fix misra compliance
2020-06-18 11:17:00 -07:00
Greg Hogan 63fe9f73c3 kline_ll_recv return bytes 2020-06-14 09:22:39 -07:00
Adeeb d0442fd1e4
add hyundai legacy safety mode (#554) 2020-06-12 18:03:31 -07:00
openpilot laptop 74c607f79a isotp_send fix bus and add slow mode 2020-06-11 16:42:21 -07:00
Adeeb Shihadeh 6848c7576b use same flake8 config as openpilot 2020-06-03 16:22:30 -07:00
Willem Melching e0a706e4f0
Stricter pylint (#550)
* stricter pylint

* Add as argument
2020-06-02 16:27:07 -07:00
Adeeb d7f7b14118
Enable almost all Flake8 checks (#548)
* fix W391

* E262

* E703

* W293

* some E

* E231

* some more E

* E225

* more E

* E252

* no tabs

* more tabs

* E701

* uds.py

* almost all of them

* only e265 left

* not sure why this is triggering on commented out code

* ignore esptool
2020-06-01 01:49:26 -07:00
Adeeb Shihadeh f70ef291f9 whitespace fix 2020-05-31 17:49:37 -07:00
Adeeb Shihadeh 9102c16118 two spaces before inline comment 2020-05-31 14:07:01 -07:00
Willem Melching b8267341a1
Add pre commit checks + CI (#545)
* Add pre commit checks

* untested but should work

* fix typo in dockerfile

* add sqlite

* add pylintrc to ignore usb1 members

* Typo in stage name

* Move to requirements
2020-05-29 11:52:03 -07:00
Willem Melching a618e64d1a fix typing errors 2020-05-28 14:06:13 -07:00
Willem Melching 5307bf7277 Fix multi message iso tp requests 2020-05-18 19:48:47 -07:00
bkralik c2bea78f6d
Fix python library on Windows (#523)
On Windows, setAutoDetachKernelDriver is not supported (http://libusb.sourceforge.net/api-1.0/group__libusb__dev.html#ga5e0cc1d666097e915748593effdc634a) and causes libusb to get stuck (simple try-catch is not working). This prevents any issues when running both at native windows python and cygwined python...
2020-05-02 12:18:26 -07:00
robbederks ba59ada0e9
No ESP in non-white (#514) 2020-04-20 17:49:52 -07:00
Willem Melching f07a6ee7c5
panda recover should go through bootstub first (#498) 2020-04-13 15:12:06 -07:00
Adeeb 8cc3a35700
remove cadillac (#496) 2020-04-13 14:43:46 -07:00
Greg Hogan da8e00f115
TX message guaranteed delivery (#421)
* wait for tx slots before clearing nak

* fix bootstub

* Fixed misra

* Cleanup

* Added bulk write test to test USB NAK on bulk CAN messages

* Added automated bulk tx test

* Fixed linter

* Fixed latency test influence

* Added timeout to python API

* Disabled can write timeout in bulk write test

Co-authored-by: Robbe <robbe.derks@gmail.com>
2020-04-06 16:49:42 -07:00
Shreyansh Chandak 0c2c149490
Fixing libusb busy error (#174)
Detaching all kernels before attempting to claim the usb
2020-04-02 10:12:03 -07:00
Jason Young 08ef92d585
Safety model for Volkswagen PQ35/PQ46/NMS (#474)
* Align with VW Community port 0.7.4-devel

* Import of PQ35/PQ46/NMS safety work

* Add safety replay drive for PQ35/PQ46/NMS

* Unwind community port hax for upstream, bump Panda ver

* Update comment

* Reduce whitespace diff

* Reduce whitespace diff

* Don't test the drive until it's uploaded

* Propitiate MISRA

* Ixnay on the VERSION LF

* Remove VERSION LF, update safety_replay with PQ drive

* Freshen cereal ref to include fields used in VW PQ test drive

* Remove superfluous return

* Bypass Docker caching issue
2020-04-01 12:38:27 -07:00
rbiasini b2dbb504dc
remove toyota ipas safety code and tests (#460) 2020-03-04 10:54:13 -08:00
rbiasini dfa6b079de
separating subary legacy safety mode from global (#452)
* separating subary legacy safety mode from global

* added explicit tests for subaru legacy, which were absent before
2020-02-27 15:28:24 -08:00
Andre Volmensky db94a5b813
Added Nissan safety (#244)
* Added Nissan safety
2020-02-26 11:11:56 -08:00
Jason Young ccf75c456f
Volkswagen safety updates: Phase 1 (#444)
* Checkpoint Panda refactoring updates

* Rename MQB safety tests in preparation for PQ

* Refactor MQB tests, add missing torque test

* Bring in MQB init without CRC LUT setup

* Fix to ACC_06 test case

* Fix to ACC_06 test case

* Tweak comment for clarity

* Drop superfluous return
2020-02-19 12:37:38 -08:00
Greg Hogan 73a60d5c9c uds: clear rx buffer on drain 2020-02-05 23:34:00 -08:00
Greg Hogan 3b20804b6f uds: rx message buffering 2020-02-05 23:25:34 -08:00
Willem Melching 38fc1d39ff add option to not do a clean st build 2019-12-20 19:39:50 -08:00
Riccardo d19fd3e6bd better differentation of honda safety modes 2019-12-20 15:51:32 -08:00
Riccardo 01244d7557 Fix panda libs 2019-12-20 14:34:59 -08:00
Riccardo 268ab9acf3 send can_rx_errs in health 2019-12-19 18:17:09 -08:00
Willem Melching ad10c8c7ee get_signature return bytes instead of bytearray 2019-12-18 17:03:31 -08:00
Willem Melching ded4b3f743 UDS: handle remote addressing 2019-12-16 15:54:30 -08:00
Willem Melching 7c13bec09f
Command to get signature (#399)
* Commands to get signature from panda

* does this make misra happy?

* Can I do this in misra?

* this works and makes misra happy

* Add jenkins test for get signature

* Remove comments

* Add comment about code size

* Fix firmware file path
2019-12-09 10:54:48 -08:00
Robbe ca39a5d8f6 Added faults integer to health packet 2019-11-26 17:07:51 -08:00
Robbe 22464356c3 Fixed health struct size. We should really get an automated test for this 2019-11-22 16:02:08 -08:00
robbederks f458d67a7c Add uptime counter to the health packet (#391)
* Added uptime counter to the health packet

* fix tests by setting power save on on EON build
2019-11-21 16:47:49 -08:00
rbiasini 1192d934a0
Power saving refactor (#389)
* Exit power saving also for CAN based ingition detection and replace interrup with simple state machine. a bit of delay it's fine

* bug fixes and also CDP set on start

* sorry misra

* move comment

* typo

* remove ignition interrupts

* Power saving state machine should be done by boardd, which also sets safety modes and usb power modes

* typo

* Added usb command for power save state setting

* Added power save enabled packet

* Added power_save_enabled to python lib too
2019-11-21 12:53:00 -08:00
rbiasini 597436d32a
NOOUTPUT safety mode is now SILENT. NOOUTPUT still exists but keeps C… (#388)
* NOOUTPUT safety mode is now SILENT. NOOUTPUT still exists but keeps CAN live

* README mention of 'no output'

* mispelled
2019-11-20 11:56:26 -08:00
Greg Hogan 02d579a537 functional addr handling 2019-11-17 09:30:06 -08:00
Greg Hogan 8138fc14c8 uds: handle function addrs and fw version query example 2019-11-16 18:54:28 -08:00
Robbe 6626a54241 Fixed python health api 2019-11-15 21:01:46 -08:00
Greg Hogan b9b79e8b77 uds zero second timeout 2019-11-15 13:52:25 -08:00
Greg Hogan f239b996db single addr was better 2019-11-14 13:34:25 -08:00
Greg Hogan b3e1a133ae uds: better debug prints 2019-11-12 22:22:49 -08:00
Greg Hogan 68c39fb3e2 uds: no need for threads if you always drain rx 2019-11-12 18:52:41 -08:00
Greg Hogan ff86db6553 improve uds message processing 2019-11-06 13:50:32 -08:00
Greg Hogan 501db8d199 uds drain before send and use has_obd() 2019-11-05 18:40:21 -08:00
Robbe f2cbec161e Added has_obd() to python library 2019-11-05 18:25:42 -08:00
robbederks e0762c2e77
Add Python & USB API for controlling phone power (#313)
* Added interface for phone power

* Add power function in python

* Fixed struct
2019-11-04 17:26:37 -08:00
Robbe ba9fb69f65 New health packet struct also in the python libs 2019-10-31 17:08:02 -07:00
rbiasini a12a148d5f Uno (#274)
* Added uno

* Added usb switch support

* Added PWM and IR power functions

* Implemented bootkick

* Added uno as a new hw type

* Bumped version

* Added fan control and tach readout

* WIP: RTC support

* Working RTC

* Fixed python

* Misra compliance

* Added USB control messages for fan/IR power

* Added USB commands + tests for fan & IR control. Fixed bootstub and pedal compilation

* Added IR and fan to power saving mode

* Changed defaults

* Fix safety considering uno

* passing safety now

* Minor UNO tweaks

* Fixed version

* More minor temporary tweaks

* Removed usb load switch from uno

* Added power control for shutting down the fan completely

* Disable IR LEDs by default

* Fixed linter issue

* Linter fix #2
2019-10-25 16:22:42 -07:00
rbiasini 1102e69652
make ignition logic common for all cars (#303)
* make ignition logic common for all cars

* ignition_can is not a safety thing. move it to can drivers

* bump version

* gm safety passive is deprecated

* move tx 1 on logic into board specific headers.
2019-10-22 15:10:43 -07:00
Greg Hogan 55957d6e4e proper python3 exception inheritance 2019-10-16 00:15:16 -07:00
Greg Hogan 6ba0f47b56 fix linter errors 2019-10-15 23:52:52 -07:00
Greg Hogan 5c49fe050e
Merge pull request #145 from gregjhogan/uds
Unified Diagnostic Services (UDS) panda library (ISO 14229)
2019-10-15 23:42:22 -07:00
Greg Hogan 0f361999bd timeout is float 2019-10-15 23:38:24 -07:00
rbiasini fce38a91d7
Linter python (#299)
* Added pyflakes and Pylint for python

* Actually run linter in CI

* some simple pyflakes changes

* Add flake8 to panda reqs for linter test

* flake8 errors are fixed

* run flake8 in regression tests

* meant to run flake8

* hack to ignore unused import

* bug

* fix bugs in tucan_loopback

* Another fix by using set_safety_mode

* added pylintrc file

* more fixes and enabled pylint as well

* Fix pylint in circleci

* added linter to readme
2019-10-15 14:03:31 -07:00
Greg Hogan 711810d2f0 more uds debug 2019-10-15 12:14:09 -07:00
Greg Hogan 4454e3a6bb better CAN comm abstraction 2019-10-15 12:07:19 -07:00
rbiasini 6b1f28f574
fix more encoding and some bytes cleanup (#300) 2019-10-15 12:05:33 -07:00
Greg Hogan 43adad3116 fix WARNING_INDICATOR_REQUESTED name 2019-10-14 17:32:23 -07:00
Greg Hogan 9c857da379 0x 2019-10-14 17:32:23 -07:00
Greg Hogan b64d6fa5d2 typing 2019-10-14 17:32:23 -07:00
Greg Hogan 768fdf7e19 bytes() > chr().encode() 2019-10-14 17:32:23 -07:00
Greg Hogan 1be15ea934 custom errors from thread 2019-10-14 17:32:23 -07:00
Greg Hogan 68da8315f3 more python3 2019-10-14 17:32:23 -07:00
Greg Hogan 4f288586d5 updates for python3 2019-10-14 17:32:23 -07:00
Greg Hogan 932745f62b support tx flow control for chunked messages 2019-10-14 17:32:23 -07:00
Greg Hogan b1c371292c add timeout param 2019-10-14 17:32:23 -07:00
Greg Hogan cdf2f626ba bug fixes 2019-10-14 17:32:23 -07:00
Greg Hogan b1a3195770 fix rx message filtering bug 2019-10-14 17:32:23 -07:00
Greg Hogan 80fb6a6fa0 convert uds lib to class 2019-10-14 17:32:23 -07:00
Greg Hogan 59cd2b47f9 handle separation time in microseconds 2019-10-14 17:32:23 -07:00
Greg Hogan 4429600d8e fix separation time parsing 2019-10-14 17:32:23 -07:00
Greg Hogan c641e66f72 fix typo 2019-10-14 17:32:23 -07:00
Greg Hogan 48b8dcc6f9 fix flow control delay scale 2019-10-14 17:32:23 -07:00
Greg Hogan 78f413d88f flow control delay 2019-10-14 17:32:23 -07:00
Greg Hogan 33a5167d93 bug fixes 2019-10-14 17:32:23 -07:00
Greg Hogan 8ee89a091d multi-frame tx 2019-10-14 17:32:23 -07:00
Greg Hogan 5e89a9c728 clear rx buffer and numeric error ids 2019-10-14 17:32:23 -07:00
Greg Hogan 9662300632 fix remaining size calculation 2019-10-14 17:32:23 -07:00
Greg Hogan 01ef1fae36 zero pad messages before sending 2019-10-14 17:32:23 -07:00
Greg Hogan 1ddc9735d1 uds can communication 2019-10-14 17:32:23 -07:00
Greg Hogan dca176e717 syntax errors 2019-10-14 17:32:23 -07:00
Greg Hogan 95be4811ef SERVICE_TYPE enum 2019-10-14 17:32:23 -07:00
Greg Hogan 98e73b51d2 more UDS message type implementation 2019-10-14 17:32:23 -07:00
Greg Hogan c1c5b0356b uds lib 2019-10-14 17:32:23 -07:00
rbiasini 162f4853df
fix chr to bytes conversions (#298) 2019-10-13 18:15:04 -07:00
rbiasini f9053f5df4
more Python 3 fixes, attempting to fix jenkins wifi regresison test (#295)
* more Python 3 fixes, attempting to fix jenkins wifi regresison test. Not successful, but closer.
2019-10-10 12:34:52 -07:00
Jason Young 2f9e076289 Panda safety code for Volkswagen, Audi, SEAT, and Škoda (#293)
* Panda safety code for Volkswagen, Audi, SEAT, and Škoda.

* First pass at MISRA compliance.

* Second pass at MISRA compliance.

* Fix scope of violation boolean.

* MISRA doesn't care for implicit cast of unsigned int to boolean.

* Remove superfluous newline.

* Remove unused VW ignition hook code, preserve commentary.

* Add 50% padding to max delta check.

* Add 50% padding to max delta check.

* Add clarity around the origin of our safety constants.

* Update test RT delta to match safety.
2019-10-09 13:54:22 -07:00
rbiasini ffbdb87a8d
python2 -> 3 fixes to pedal flasher (#292)
* python2 -> 3 fixes to pedal flasher

* fix Debug flash as well

* Fixes to wifi-test
2019-10-08 19:07:59 -07:00
Robbe 736c2cbf7b Fixed sending of bytes over PandaSerial 2019-10-07 14:26:44 -07:00
rbiasini af0960ad3d DFU fix (#288)
* DFU fix

* fix test 2

* this should fix all the remaining jenkins test

* Fixed pyenv shim not being a python file, but a sh script
2019-10-03 19:46:28 -07:00
rbiasini 70219d7bb2
match safety enum in cereal (#285)
* match safety enum in cereal

* removing tons of hardcoding

* add pythonpath to safety test

* Fix safety test in Docker
2019-10-02 18:20:32 -07:00
Robbe c4aabae591 Fixed some python3 bugs in the test scripts and PandaSerial 2019-09-27 15:22:13 -07:00
Riccardo d3268690c9 Revert "revert back esptool to python2 and force to build esptools with python2"
This reverts commit 875e76012b.
2019-09-26 17:02:38 -07:00
Riccardo 875e76012b revert back esptool to python2 and force to build esptools with python2 2019-09-26 16:21:47 -07:00
Riccardo 5f2bc44606 better 2019-09-25 16:52:51 -07:00
Riccardo b2a30fdbdf make works! 2019-09-25 16:52:03 -07:00
Riccardo fe727706bd read file as byte and no tab before sleep 2019-09-25 14:34:28 -07:00
Riccardo 2dc34096a0 2to3 applied 2019-09-24 22:33:46 -07:00
Riccardo ffa68ef711 undo unnecessary brackets for print 2019-09-24 18:07:05 -07:00
Riccardo dbc248027e Fix all the prints with 2to3, some need to be undo 2019-09-24 18:02:15 -07:00
Riccardo 5a7aeba0f5 xrange is gone 2019-09-24 17:56:55 -07:00
Riccardo 1e2412a297 env python -> env python3 2019-09-24 17:50:53 -07:00
robbederks 6f532c6d51 Black panda Jenkins (#256)
* Jenkins test refactor and black panda addition

* Added HW types needed by previous commit

* Fixed ignition interrupts when not on EON build

* Added functions for load switches

* More test scripts for black panda

* Added NONE power mode to the code

* Fixed race condition when setting GPIO pins was interrupted.

* Added relay test script

* Fixed flashing with critical sections and GPS load switch

* Fixing critical depth after reboot

* Made the loopback test asserting

* Made critical depth a local variable to avoid race conditions

* Added GPS to power savings mode

* Fixed DFU mode on white panda and bumped version

* Fixed PEDAL_USB compilation error

* Fixed misra compliance of new critical depth code

* Cleaned up heartbeat logic in the testing code. Re-added ALL_CAN_BUT_MAIN_SILENT. Bumped version. Improved critical section code.

* Fixed DFU flashing (once again)

* Fixed VERSION

* Added relay endurance test

* Changed to alloutput on ELM mode for fingerprinting.

* Fixed minor remarks
2019-08-28 12:57:42 -07:00
rbiasini 59f5813173
Black (#254)
* late usb

* Added type support for black panda

* Added harness presence and orientation detection

* harness relay driving code

* Added intercept support in black panda code. Switched around can0 and can2

* Disable ADCs after orientation detection. Ignition interrupts via harness

* WIP: Hardware abstraction layer + black panda bringup

* Fixed bootstub build

* Fixed bootstub for pedal

* Fixed infinite loops

* Got CAN buses working on white again

* Fixed pedal build and black can interfaces

* Got CAN buses working on black panda

* Finished loopback test for black panda

* Erase all flash sectors on the panda. Increased binary limit. Added extra python functions.

* Fixed python

* Made new code MISRA compliant

* Cleaned up ignition. Fixed build

* Fixed health packet

* Fixed CAN mode on black bug. Changed OBD to switch on ELM mode

* Fixes from Github review

* Fixed MISRA issue for pedal

* Fixed failing gmlan tests

* ELM327 safety: allow diagnostic on all buses

* Cleaned up EON relay code

* delete only 3 sectors instead of 11 to allow a new build to be flashed. Much faster to flash

* Removed CAN only can0 output mode. Does not make sense on black panda due to reversibility issues.

* Added heartbeat logic for EON code on panda. Go to NOOUTPUT if EON does not send a heartbeat for 5 seconds.

* Remove all CAN buses live on EON startup. Shouldn't be necessary to have this separate case

* Formatting

* Added file I forgot to push

* Added heartbeat to testing code to make sure EON tests don't fail. Should probably find a better way to do this though. Heartbeat thread didn't work, concurrent USB connection issues...

* Safety: support black panda for Honda Bosch

* Disable OBD2 if setting to NOOUTPUT mode

* Run safety tests for all hw_types

* Fail test if subtest fails

* fix safety tests
2019-07-23 15:07:06 -07:00
dekerr 45d0d286f4 remove whitespace (#255) 2019-07-19 19:35:50 -07:00
Riccardo 3e9469b3ee Fixing tests after min->MIN change 2019-06-30 14:19:31 -07:00
Willem Melching 03d1c8ab3e make dfu.py compatible with latest libusb1 2019-06-26 13:56:02 -07:00
rbiasini a3f65d66e9
capitalize MIN and MAX macros (#220) 2019-06-17 13:48:14 -07:00
George Hotz 3810452a02 WTF WHY WAS THIS SHIT PUT EVERYWHERE 2019-05-23 12:39:54 -07:00
Nigel Armstrong f8ab74a1cc L-line relay (#166)
* Initial version of L-Line Relay

* lline relay fix build, add to health

* Add lline relay to safety

* Lline relay fix build

* Fix tests

* Add lline safety init. Dont fwd with relay closed

* Turn on relay with CAN

* relay hook

* More reliable lline relay

* Longer LLine timeout

* Only turn on wifi if not eon

* Dont disable ESP in early

* Allow CAN to be turned off

 - CAN is turned off via USB.
 - CAN is turned on when either try to transmit or can is received
 - If only transmit is asleep, all messages should send okay
 - If receive is alseep, will miss first message while waking up
 - Sometimes will report error on second message while CAN perif wakes up
 - Saves 130mW!

* Power Saver Mode

 - Gray Panda power consumption 650mw -> 325mW
 - Turns off CAN, GMLAN, LIN, GPS when no activity for 10s
 - No acitvity is no CAN send, CAN Recv, Write to GPS

* Fix power_saving to better turn off can

 - On some cars when the can is turned off, it triggers a wakeup.
 Delaying the automatic wakeup seems to fix this

* Don't save power in pedal

* Fix relay clicking on startup

* Fix duplicate include

* consistent relay setting

* relay_status can be added when needed, as it's started_alt was consumed in other places

* need to skip forwarding only if relay control is claimed

* unneded change

* make lline_relay.h not depending on can.h

* less spaghetti I guess

* less lines

* reset pedal changes

* no unused input

* update version
2019-04-11 21:03:15 -07:00
Nigel Armstrong 1d2f8f0abf
Jenkins (#179)
* Improve panda automated testing

 * begin testing both white and grey panda
 * Improve wifi reliability

* First commit for docker

* Fix usb devices not showing up on reconnect

* Add tests for two pandas, latency and throughput

* Add Jenkinsfile

* Allow flashing release on wifi

* Fix Jenkins stuck in DFU mode and docker container running

* Add pandaextra from xx to docker

* Need more time for ST to restart, sometimes

* Add xml output to tests

* Try making wifi more reliable

* Fix infinite loop in ping

* Check connected after flash

* Cleanup two panda tests

* Try fixing failing test with check after udp

* Try to fix with sleep

* Temporarily run just 5 and 6

* Cleanup

* Desperate times call for desperate measurse

* BUGFIX: power saving when rx only

* Fix failing when white panda is first after udp

* Test both Dev and EON build

* Jenkins test results for both builds

* Better test case naming
2019-04-09 14:09:18 -07:00
Nigel Armstrong 4276c380e6
Additional Power saving (#170)
* Only turn on wifi if not eon

* Dont disable ESP in early

* Allow CAN to be turned off

 - CAN is turned off via timeout
 - CAN is turned on when either try to transmit or can is received
 - If only transmit is asleep, all messages should send okay
 - If receive is alseep, will miss first message while waking up
 - Sometimes will report error on second message while CAN perif wakes up
 - Saves 130mW!

* Power Saver Mode

 - Gray Panda power consumption 650mw -> 325mW
 - Turns off CAN, GMLAN, LIN, GPS when no activity for 10s
 - No acitvity is no CAN send, CAN Recv, Write to GPS

* Fix power_saving to better turn off can

 - On some cars when the can is turned off, it triggers a wakeup.
 Delaying the automatic wakeup seems to fix this

* Don't save power in pedal

* Cleanup power saving
2019-04-01 22:45:00 -07:00
Nigel Armstrong 20c76ad592 Power Saving (#169)
* Only turn on wifi if not eon

* Make sure esp is disabled on eon

* Dont disable ESP in early
2019-03-13 20:58:00 -07:00
rbiasini a6193a8285
Dcp remove (#168)
* No DCP charge mode when building from EON
2019-03-11 23:41:40 -07:00
Nigel Armstrong d7d08892e7 Capture make failure so it can be logged to sentry 2019-02-21 01:48:36 -08:00
Drew Hintz 799c33868d Chrysler safety controls (#130)
* Chrysler safety model and tests.

* fix comments

* when ACC is canceled, disallow controls

* update SAFETY_CHRYSLER value in Python API and add other SAFETY values
2018-11-06 12:28:33 -08:00
George Hotz e7ca587b2b long isotp msgs 2018-06-21 15:59:29 -07:00
George Hotz 4150684aa8 add javascript and bump pandacan version 2018-05-09 13:18:53 -07:00
Chris Vickery 6dbd8c972b
Implement WebUSB and upgrade WinUSB to 2.0 (#107)
* Implement webusb and winusb 2.0 specs

* Add missing constants

* Refactor string system, add support for USB2.1

* Uncapitalize the panda

* Add USB 2.0 extension descriptor and device qualifier getter

* Sleep during reconnect process to be more reliable

* Disable compiler optimizations because they break SPI coms
2018-04-11 10:08:56 -07:00
George Hotz fe15d3fb0f bump pandacan 2018-03-13 15:22:33 -07:00
George Hotz b259e2ae91 can flasher is close to working 2018-03-10 11:22:22 -08:00
George Hotz 7ae7c7961f typo 2018-03-10 10:17:57 -08:00
George Hotz e85cc4758a forgot the selfs 2018-03-10 10:16:53 -08:00
George Hotz f7a0ab09bf pedal usbflash works 2018-03-09 17:47:13 -08:00
George Hotz 585d0f9e6a add way to call isotp 2018-03-09 17:40:03 -08:00
George Hotz be828991ae despite it being bad code, move isotp 2018-03-09 17:37:47 -08:00
gregjhogan 5c7ef9ee43 added bosch safety hooks and forwarding 2018-03-05 18:17:30 -06:00
Jennifer Strange 08f464cffb python 3 bro is bad bro 2018-02-28 17:47:37 -08:00
Jennifer Strange 9390961041 kline checksum algo was broken... 2018-02-28 17:45:54 -08:00
Jennifer Strange 3b7c33b15a add kline debug support 2018-02-28 17:03:04 -08:00
George Hotz 8203cc8e59 add is_grey 2018-02-16 11:07:20 -08:00
George Hotz b68957e666 add pandadebug support 2018-01-23 18:40:53 -08:00
George Hotz 21f8195d4e fix panda serial write 2018-01-19 11:04:21 -08:00
George Hotz aa0cfadb6b fix UART hang 2018-01-08 14:53:38 -08:00
George Hotz 65997ffcf5 add PandaSerial and location panda (aka pigeon) test 2018-01-07 11:31:54 -08:00
George Hotz b74b6f2727 rename panda to python because of git ambiguity 2017-12-06 16:17:57 -08:00