Commit Graph

400 Commits

Author SHA1 Message Date
Robbe Derks 2c937656cf
Continuous harness detection (#1402)
* read in mV and make threshold board-dependent

* refactor and add SBU voltages to health

* refactor relay driving

* more refactoring and readout lock

* avoid race condition

* fix misra

* continuous detection

* 1Hz is fine

* another race condition

* use harness detection to trigger bootkick

* update orientation detection test

* more in-depth harness tests

* fix ignition

* fix

* raise threshold
2023-05-08 13:30:23 +02:00
Adeeb Shihadeh ba5c2948e4
python: default to 60s timeout for recover() (#1394) 2023-05-03 14:15:34 -07:00
Adeeb Shihadeh a5718ce5dd
spi: different ack dummy bytes for debugging (#1382)
different ack vals

Co-authored-by: Comma Device <device@comma.ai>
2023-05-01 19:31:13 -07:00
Adeeb Shihadeh 3c75a8bc00
add fan stall count to health (#1355)
* add fan stall count to health

* fix misra

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-20 13:30:56 -07:00
Adeeb Shihadeh cf307348af
CI: run HITL tests on tres (#1326)
* run on tres

* disable those for now

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-18 22:17:11 -07:00
Robbe Derks 237ffedcb3
Dos fan fix (#1335)
* hitl fan test

* enable cooldown on dos as well

* small cleanup

* get expected RPM from panda class

* fix

* overshoot test

* fix max RPM getting

* fix percentage

* revert cooldown fix

* add cooldown for dos fan as well

* remove feedforward from the fan controller to eliminate overshoot

* update clip

* cleanup

* add that back

---------

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2023-04-18 14:15:06 -07:00
Adeeb Shihadeh 9cd01ac263
PandaDFU: retry SPI comms (#1348)
* retry

* set exc

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-16 14:43:58 -07:00
Adeeb Shihadeh 878e0077ac
add tres to internal devices 2023-04-06 20:52:09 -07:00
Adeeb Shihadeh 6f852b44a9
SPI: log checksum errors in health (#1334)
* SPI: log checksum errors in health

* actually send it

* check in hitl teardown

* check that

* fix misra
2023-04-05 22:05:14 -07:00
Adeeb Shihadeh 2e8f27486f spi: bump up to 50MHz 2023-04-05 09:28:04 -07:00
Adeeb Shihadeh b6c378ad02
CI: set PYTHONWARNINGS=error (#1323)
* CI: set PYTHONWARNINGS=error

* update resetter

* fix build warnings

* bump jungle

* fix one more

* fix linter

---------

Co-authored-by: Bruce Wayne <batman@comma.ai>
2023-04-02 09:33:35 -07:00
Adeeb Shihadeh 3e89b7127a
python: fix libusb deprecation warning (#1302)
* update list

* this one too

* update dfu
2023-04-01 23:09:12 -07:00
Shane Smiskol 8efbcf041c
IsoTpMessage: return if consecutive frame last received (#1314)
* what about

* actually this is what we want

* more explicit about this condition

* frame type

* add enum

* use in func
2023-03-31 20:11:53 -07:00
Shane Smiskol a12c0a7956
IsoTpMessage: don't skip a byte when sending consecutive frames to subaddress (#1320)
handle
2023-03-31 19:44:46 -07:00
Shane Smiskol 189f0436ba
IsoTpMessage: check CAN frame length (#1315)
* Revert "Revert "IsoTpMessage: check CAN frame length (#1312)""

This reverts commit 09fee3e7ea.

* need to pad for the check to work

* pass rx_offset up from can client

* detect from internal can_client and just use it for the checks

* move

* revert this for another PR

* fix
2023-03-31 19:22:16 -07:00
Shane Smiskol c92f8ecfde
IsoTpMessage: fix rx_len sanity checks (#1319)
fix a bug
2023-03-31 19:17:16 -07:00
Shane Smiskol 02eb84936b
UdsClient: support sub addresses (#1317)
* UdsClient: support sub addresses

* Update python/uds.py

* Update python/uds.py
2023-03-31 13:59:02 -07:00
Shane Smiskol 09fee3e7ea Revert "IsoTpMessage: check CAN frame length (#1312)"
This reverts commit 9349337ebb.
2023-03-31 12:11:13 -07:00
Shane Smiskol 7933635b54
IsoTpMessage: rx_len sanity checks (#1311)
* add some more sanity checks for _isotp_rx_next

* another PR

* Update python/uds.py

* cannot be bigger than 0xfff
2023-03-30 23:23:42 -07:00
Shane Smiskol 23563cec7c
IsoTpMessage: check not reserved frame (#1313)
* add some more sanity checks for _isotp_rx_next

* another PR

* rever

* can remove return

* add back the space here tho :(

* raise
2023-03-30 22:35:02 -07:00
Shane Smiskol 9349337ebb
IsoTpMessage: check CAN frame length (#1312)
* add some more sanity checks for _isotp_rx_next

* another PR

* revert
2023-03-30 22:14:35 -07:00
Adeeb Shihadeh 7aaca348c2
HITL tests: nose -> pytest (#1301)
* HITL tests: nose -> pytest

* run all

* add back partial tests

* big speed up

* fix skipping

* enable all

* that's expected

* clean up after ourselves

* jungle is fixture

* fix

---------

Co-authored-by: Bruce Wayne <batman@comma.ai>
2023-03-22 21:38:37 -07:00
Shane Smiskol c83d6894ef
Toyota: base LTA safety (#1295)
* part 1 of clean up

* make it work and pass

* remove lta stuff

* remove commented lta tests

* more

* move test back to where it was

* rm line

* rename that

* fix that

* start to add LTA

* angle test

* fix tests and add base stock longitudinal class

* formatting

* clean that up

* convention

* add ALLOW_DEBUG
2023-03-16 22:32:56 -07:00
Adeeb Shihadeh b231281c8b
python: check SPI response length (#1280)
* python: check SPI response length

* fix read bytes

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-03-07 20:12:23 -08:00
Adeeb Shihadeh 79210e8c2b faster timeout for initial connect 2023-03-07 15:18:11 -08:00
Adeeb Shihadeh 2de7140117
SPI support in bootstub (#1227)
* always build spi

* no dos for now

* spi gpio init

* detect bootstub

* cleanup

* revert that

* move fx stuff

* fix linter

* set erase timeout

* fix types

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-03-07 14:55:15 -08:00
Adeeb Shihadeh deaad254d9
python: non-zero default timeout (#1279)
* non-zero default timeout

* respect timeout in spi
2023-03-07 14:44:10 -08:00
Adeeb Shihadeh df7952ec13
python: add helper to check if up to date (#1269)
* python: add helper to check if up to date

* current

* handle is always basehandle

* update that

* Update __init__.py

---------

Co-authored-by: Bruce Wayne <batman@workstation-production.internal>
2023-03-07 13:47:55 -08:00
Adeeb Shihadeh efb36197bb
PandaDFU: SPI support (#1270)
* PandaDFU: SPI support

* get mcu type

* program bootstub

* little cleanup

* more cleanup

* connect by dfu serial

* time to remove that

* none

* fix linter

* little more

* catch

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-03-06 21:52:08 -08:00
Adeeb Shihadeh 18230831f3
PandaDFU: abstract out USB comms (#1274)
* wip

* revert that

* split list + connect

* some more

* mypy fix

* add clear status back

* rename

* cleanup

* cleaner mypy fix

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-03-06 09:24:00 -08:00
Adeeb Shihadeh 946f952aa7
DFU HITL tests (#1276)
* DFU HITL tests

* fix + types

* fix

* clear first
2023-03-05 20:19:27 -08:00
Robbe Derks d6af117c62
Microsecond timer fix (#1236)
* add microsecond timer readout

* add CI test

* fix
2023-02-14 12:16:15 +01:00
Adeeb Shihadeh 14051f9ce3
Chrysler: revert rate limit increase (#1240)
* Revert "Chrysler: add flag for alternate steer limits (#1238)"

This reverts commit d15250cb14.

* Revert "Chrysler: increase torque rate limits (#985)"

This reverts commit ae051c94a3.
2023-02-13 14:13:40 -08:00
Shane Smiskol 17450b277d
Same mypy checks as openpilot (#1233)
* no specific revision for mypy

* bump to ~OP version

* same warnings as openpilot

* ignore

* fix

* rm that

* switch to ignore so mypy lets us know when it's fixed

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2023-02-11 12:25:13 -08:00
Adeeb Shihadeh d15250cb14
Chrysler: add flag for alternate steer limits (#1238) 2023-02-10 22:20:50 -08:00
Shane Smiskol 82151aaffe
usb handle: ignore types (#1234)
ignore types
2023-02-07 20:02:06 -08:00
Adeeb Shihadeh 6ec0c80754
python: common base handle for SPI + USB (#1231)
* base handle

* usb handle

* rm

* more types
2023-01-28 16:01:54 -08:00
Adeeb Shihadeh e7f36a2992
python: assume F4 MCU for bootstubs without bcdDevice set (#1229)
* python: assume F4 MCU for bootstubs without bcdDevice set

* cleanup
2023-01-28 14:41:52 -08:00
Adeeb Shihadeh 6ae5212d6a
python lib: add SPI bootloader support (#1224)
* talk to spi bootloader

* flashing bootstub

* reset

* get mcu type

* little more

* pull out low level panda comms

* lint

* program app

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-01-28 00:32:07 -08:00
Adeeb Shihadeh 76d0459182
cleanup MCU definitions (#1226)
* cleanup MCU definitions

* rename

* enum

* enum

* fix that
2023-01-26 20:54:11 -08:00
Adeeb Shihadeh 2036533670
python: show SPI pandas in list (#1216)
* refactor connect

* spi list

* add back bcd

* couple fixes

* fix

Co-authored-by: Comma Device <device@comma.ai>
2023-01-22 21:49:14 -08:00
Adeeb Shihadeh 0e5a2a47da
python lib: print() -> logging (#1215)
* python lib: print() -> logging

* fstrings are fine
2023-01-15 23:51:25 -08:00
Adeeb Shihadeh 3048760737
SPI: connect by serial/UID (#1213)
* SPI: connect by serial/UID

* cleanup

* not everyone can have spi

* fix that

* move that

* mypy fix

Co-authored-by: Comma Device <device@comma.ai>
2023-01-15 23:30:24 -08:00
Adeeb Shihadeh b8693da342
add comms handler to get MCU UID (#1212)
* cleanup first

* get uid

* add to bootstub and test

* fix pedal

* match that

Co-authored-by: Comma Device <device@comma.ai>
2023-01-15 20:13:26 -08:00
Willem Melching fa678e28fc
MacOS: no spidev package (#1211) 2023-01-15 12:51:22 -08:00
Adeeb Shihadeh e83b2189c1
lock spi device during transfers (#1207) 2023-01-14 23:32:17 -08:00
Shane Smiskol bdf39a451e
Panda: context manager support (#1209)
* add __enter__ & __exit__ to Panda

* some examples

* another example

* even more

* use it here too
2023-01-13 16:17:20 -08:00
Robbe Derks 11d90f9e78
No more magic for the can chunks (#1191)
* no more magic

* bump version

* no need for this

* comment cleanup

* add comms_can_reset tests

* we can't ensure this for compatibility reasons

* add CANPacket_t checksum
2023-01-13 10:59:58 -08:00
Robbe Derks 744b21ef69
Bring back green led mode + fix small python lib bug (#1206)
bring back green led mode

Co-authored-by: Panda Provisioning <panda@comma.ai>
2023-01-10 15:09:51 -08:00
Adeeb Shihadeh 0b58cb9e3c lower spi ack timeout 2022-12-20 23:05:04 -08:00
Adeeb Shihadeh 5486eb3845
python lib: add SPI ACK timeout (#1199)
* python lib: add SPI ACK timeout

* fix that

Co-authored-by: Comma Device <device@comma.ai>
2022-12-20 22:07:24 -08:00
Robbe Derks 1d732d4747
F4: Cleanup clock src, second try (#1193)
* F4: cleanup clock source

* little more

* void

* restore the timer setup

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Comma Device <device@comma.ai>
2022-12-14 15:30:04 +01:00
Adeeb Shihadeh 4edd1a6021
Hyundai: alt steering limits (#1186)
* Hyundai: alt steering limits

* parans
2022-12-02 23:34:06 -08:00
Robbe Derks 288e14cde9
Simple CAN chunking (#1011)
* simple chunking

* make pylint happy

* misra happy?

* good practice anyways since we cast to a uint32_t later

* fix bug dropping packets

* minor fixes + prepare for shared lib testing

* working library now

* first queue test

* can send test

* fix running in github actions?

* add big rx test and fix it

* don't complain about empty buffers

* disable for now

* comment

* test runs

* some cleanup

* merge those

* test works

* rm that

* comment

* proper logging

* makes things too slow

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-11-30 23:38:00 -08:00
Adeeb Shihadeh 88b30e1a84
CAN comms test (#1181)
* CAN comms test

* remove those

* cleanup

* little more
2022-11-30 22:12:28 -08:00
Adeeb Shihadeh c075050d5d Revert "F4: cleanup clock source (#1160)"
This reverts commit f0f67ccf85.
2022-11-21 20:31:01 -08:00
Adeeb Shihadeh 2e90b6f308 cleanup python lib imports 2022-11-21 16:59:21 -08:00
Adeeb Shihadeh 3df9099660
Misc cleanup (#1161)
* unused python stuff

* green led

* docs cleanup

* little more
2022-11-17 11:46:43 -08:00
Robbe Derks 5aa5f855e4
setup UART for SOM debugging (#1151)
* cleanup external debug serial

* wip: bring up uart7

* more wip

* this does something

* this works

* increase fifo size

* fix misra

* cleanup

* fix misra again

* add SOM debug enum

* reduce SOM buffer on F4

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-11-17 17:59:11 +01:00
Adeeb Shihadeh f0f67ccf85
F4: cleanup clock source (#1160)
* F4: cleanup clock source

* little more

* void
2022-11-17 07:49:26 -08:00
Adeeb Shihadeh 966f7e0539
SPI: fixes + fake bulk transfers (#1150)
* check spi checkusm

* ugh, fix control handler

* fake bulk xfer

* cleanup

* one more

* unused

* fix linter

* some typing

Co-authored-by: Comma Device <device@comma.ai>
2022-11-10 21:34:43 -08:00
Shane Smiskol ca681ff829
Hyundai: CAMERA_SCC works on both safety modes (#1139)
* Make camera SCC work on both safety modes

* update in safety

* move to common
2022-11-07 22:13:17 -08:00
Adeeb Shihadeh 0b86dfa5fb python lib: only import spidev as necessary 2022-11-04 11:35:40 -07:00
Adeeb Shihadeh a42b104c35
SPI handle in python lib (#1131)
* SPI handle in python lib

* add spidev

* unify those

* clean up connect

* clean that up

Co-authored-by: Robbe Derks <robbe.derks@gmail.com>
2022-11-03 22:18:12 -07:00
Adeeb Shihadeh 49e2034098
tres (#1130)
* tres

* pull out chiplet

* add to python lib
2022-11-03 16:34:18 -07:00
Jason Shuler cf4aa6bb30
GM: longitudinal support for camera-integrated cars (#1014)
* Allow brake TX on PT bus

* Initial Panda GM cam harness support
 * Complete rewrite / simplification
 * Add param for cam harness (default is OBD2)
   - Forward btw 0 and 2
   - Filter LKAS and optionally ACC from cam
 * Add param for stock ACC
   - Allows ACC on PT bus when set, not otherwise
   - Allows ACC from cam when set, not otherwise
 * Add temporary WIP EPS timing workaround in ifdef

* Remove keepalive; regen == braking

* Fix MISRA violations

* EPS timing opt-in by param

* Minor clean up

* remove timing code for readability

fix and formatting

* we only need to send one message if cam harness and stock long

* Simplify params

* Removed dup brake msg

* revised params, split 3-ways

* add test

* clean up a bit, no need to send ACC yet

like this

* split out button enable and pcm enable into seperate tests

* some formatting

some formatting

* GM CAM uses PCM cruise for controls_allowed

* fix gas safety tests

* misra

* fix static analysis

comment

* fix brake pressed

* Add OP VOACC override stock cam

* Add VOACC safetyparam to init.py

* openpilot long safety

* do this in another PR

* add back

* add safety tests

* rename

* struct for safety

* not used

* temporary fault fix

* adjust max gas

* allow PSCMStatus in long mode

* stash

* fix max gas

* fix and clean up tests

* clean up longitudinal tests into a common class

* fix pylint

* subclass

* clean that up

* rm

* blocking

* comment

* comment

* lower case

* brake bus

Co-authored-by: Shane Smiskol <shane@smiskol.com>
2022-11-01 00:58:18 -07:00
Adeeb Shihadeh 622ce923e9
Hyundai: share flags with CAN-FD platform (#1099)
* Hyundai: share flags with CAN-FD platform

* update flags there
2022-10-12 20:29:15 -07:00
Greg Hogan 2f3e2825e5
CAN-FD non-ISO support (#1082)
CAN FD non-ISO support
2022-10-12 15:28:20 -07:00
Adeeb Shihadeh ffb3109e28
Hyundai: HDA2 longitudinal control support (#1096)
* ev6 long

* update steering
2022-10-11 20:50:23 -07:00
Shane Smiskol 3334dc21f5
IsoTpMessage: parameterize separation time (#1088)
* parameterize separation time

* take in seconds and convert

* fix

* define once
2022-10-05 16:35:28 -07:00
Shane Smiskol cffc41e878 Specify IsoTpMessage keywords 2022-10-05 16:22:53 -07:00
Shane Smiskol 7d196264a4
IsoTpMessage: param for single frame flow control (#1079)
* iso-tp: request a single frame at a time

* behind param

* this might be more clear

* like this better

* fit the theme

* revert this change
2022-10-05 16:12:24 -07:00
Adeeb Shihadeh e987e6c639
add pandaState.safetyRxChecksInvalid field (#1083)
* add fault for invalid safety RX checks

* fix test build

* debug

* fix debug

* fix test

* just a bool in health
2022-10-03 16:05:16 -07:00
Shane Smiskol 1910db8d4c
IsoTpMessage.send: setup_only argument (#1081)
* some fixes

* some fixes

* revert to tx not done

* this should work

* correct debug prints

* not true

* revert this

* setup_only
2022-09-30 14:29:41 -07:00
Shane Smiskol 51f023bc66
IsoTpMessage: return if message updated (#1078)
* extend timeout for each message/frame (not multi-frame full response)

* linter
2022-09-27 18:08:09 -07:00
Shane Smiskol 11ea112258
IsoTpMessage: add separation time to flow control msg (#1074)
* one frame at a time, 20 ms delay

* send one at a time

* update separation time to 10ms

* comment
2022-09-19 20:47:12 -07:00
Igor Biletskyy 59ede3fe61
CAN health packet: add speed and canfd info (#1071)
in
2022-09-16 20:39:18 -07:00
Igor Biletksyy 046fd58e8d python lib: check get_packets_versions length 2022-09-15 14:54:38 -07:00
Igor Biletskyy f029c99440
health packet: fix confusing variable names (#1068)
* fix naming

* different buffer overflows

* naming
2022-09-15 13:08:46 -07:00
Igor Biletskyy 0eef8cf333
CAN: health message for each CAN module (#1067)
* initial can health pkt

* MISRA: variable scope

* MISRA 10.4

* typo

* add total_fwd_cnt

* check size of can_health_t

* improve

* comment

* that's better

* move

* add health check to tests

* why?

* ...

* revert later

* meh

* Revert "meh"

This reverts commit 0eb8432194.

* Revert "revert later"

This reverts commit 2d98957a8f.

* adjust test
2022-09-15 13:04:10 -07:00
Igor Biletskyy ac21dbe551
H7: add chiplet panda support (RPv2) (#1049)
* temporarily disable Jenkins

* firmware

* python lib

* tests

* ..

* usb load switch to high

* it is still red

* usb power mode remove

* Revert "temporarily disable Jenkins"

This reverts commit a911cfad8d.

* forgot this

* common periph

* change name

* board tick

* add V2 to CI

* update known bootstub
2022-09-09 20:13:06 -07:00
Adeeb Shihadeh 13d64d4cc3
USB power mode + bootkick cleanup (#1051)
* remove tick

* remove more

* delete more

* board tick

* update health

* dos bootkicking

* cleanup
2022-08-31 20:46:07 -07:00
Igor Biletksyy 6d2e2bde86 put is_internal() back for openpilot pandad.py 2022-08-31 10:39:05 -07:00
Igor Biletskyy b81dfba8fe
python lib: cleanup hw type check (#1050)
cleanup
2022-08-30 10:46:12 -07:00
Igor Biletskyy 451d6309b5
python lib: check serial length for Panda.list() (#1042)
* known serial length

* rm from pedal test

* rm from helpers

* oopps

* ...

* add warning

* warning
2022-08-23 22:29:35 -07:00
Jason Wen 9d6496ece8
Hyundai CAN-FD: Tucson Hybrid 2022 support (#999)
* Hyundai: Car Port for Tucson Hybrid 2022

* Remove test comments

* Fix fwd_hook

* Allow tx on 0x1a0

* Fix byte counts

* Send LFA and HDA icons based on engageability

* Add FLAG_HYUNDAI_CANFD_HDA2 flag

* Update __init__.py

* Allow tx with CRUISE_INACTIVE

* Panda safety cleanup

* Include bus 0 in rx checks

* Missed one

* Remove redundant check

* Add comments

* start cleanup

* little more

* more cleanup

* tests

* one more test case

* rename

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-08-19 19:43:58 -07:00
Adeeb Shihadeh d3e2477231 python lib: disable checks on reconnect 2022-08-18 22:01:12 -07:00
Adeeb Shihadeh 7e843b370d
allow disabling heartbeat while in non-car safety mode (#1035)
* allow disabling heartbeat while in non-car safety mode

* simple test

* clean that up

* remove that
2022-08-17 22:42:18 -07:00
Robbe Derks ba8772123f
Simple integrating fan controller (#1022)
* fast rpm measurement

* fix indentation

* this seems stable

* clip fan integral

* fix misra

* add fan power to health

* board-specific max rpm

* refactor fan enable

* cleanup

* stall detection and reset

Co-authored-by: Comma Device <device@comma.ai>
2022-08-17 20:43:49 -07:00
Igor Biletskyy ba90f6a8c9
CI tests: check app against known good bootstub first (#1033)
* test

* add master bootstub
2022-08-15 20:11:49 -07:00
Igor Biletskyy 54eb42d903
one flash.sh for both H7 and F4 (#1032)
* flash one

* edit readme
2022-08-15 20:11:38 -07:00
Jason Young 199bc10db3
VW PQ: Longitudinal control safety, lateral torque update (#989)
* VW PQ: Updated checksum and counter handling

* first pass PQ long control safety

* refactor stock test to prep for long test

* long control tests

* falling edge enable logic and tests

* accidentally worked but this is better

* test misra/cppcheck evaluation of debug build

* Revert "test misra/cppcheck evaluation of debug build"

This reverts commit 7594fc5e2f.

* allow use of manufacturer ramp-up rate

* soften wheel-touch threshold

* fix tests

* check/test ACC main switch state

* fix CRC for Motor_5

* derp

* retry CI

* try that again

* fuuuu

* fix Motor_5 checksum validation

* use existing acc_main_on global

* re-pin opendbc

* no need for resume spam in longitudinal mode

* concise

* consistency cleanup

* comment and whitespace cleanup

* more cleanup

* more

* restore driver torque threshold

* add long control replay route

* obsolete comment

* proper flag name

* wild to mild-ish

* bump openpilot ref

* Update test_safety_replay.py

* handle non existent routes

* comment consistency/polish

* flip comparison order for falling edge clarity

* restore refs

* read the diff next time, speedy

* srsly

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-08-12 18:50:00 -07:00
Jason Shuler 5e0dde7b48
GM: Add support for cam harness & stock ACC (#962)
* Allow brake TX on PT bus

* Initial Panda GM cam harness support
 * Complete rewrite / simplification
 * Add param for cam harness (default is OBD2)
   - Forward btw 0 and 2
   - Filter LKAS and optionally ACC from cam
 * Add param for stock ACC
   - Allows ACC on PT bus when set, not otherwise
   - Allows ACC from cam when set, not otherwise
 * Add temporary WIP EPS timing workaround in ifdef

* Remove keepalive; regen == braking

* Fix MISRA violations

* EPS timing opt-in by param

* Minor clean up

* remove timing code for readability

fix and formatting

* we only need to send one message if cam harness and stock long

* Simplify params

* Removed dup brake msg

* revised params, split 3-ways

* add test

* clean up a bit, no need to send ACC yet

like this

* split out button enable and pcm enable into seperate tests

* some formatting

some formatting

* GM CAM uses PCM cruise for controls_allowed

* fix gas safety tests

* misra

* fix static analysis

comment

* fix brake pressed

* Add OP VOACC override stock cam

* Add VOACC safetyparam to init.py

* Revert "Add VOACC safetyparam to init.py"

This reverts commit 2e46f8746f.

* Revert "Add OP VOACC override stock cam"

This reverts commit a4b096cc1e.

* better comments

* better comments

better comments

fix

* move non-base msg definitions to subclass

* various comments

* TODO: add button safety

* add button safety

* use new pcm_cruise_check

* revert regen braking change

* only cancel button allowed

* Apply suggestions from code review

* Update board/safety/safety_gm.h

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

* fix suggestion

* Fix tests

* Revert "Fix tests"

This reverts commit 500577921f.

* this is a much simpler fix, do full fix in another PR

* tx button safety

Co-authored-by: Shane Smiskol <shane@smiskol.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-08-12 15:56:39 -07:00
Adeeb Shihadeh 06592b5c0e
Hyundai: rename HDA2 platform to CANFD (#1027)
* Hyundai: rename HDA2 platform to CANFD

* one more
2022-08-11 22:06:54 -07:00
Adeeb Shihadeh 486af79503
Chrysler: add Ram HD support (#1010)
* ram hd safety

* bump opendbc

* dt prefix

* remove that
2022-08-11 14:41:46 -07:00
Jason Wen 89989abca5
Hyundai: support camera-based SCC cars (#965)
* Hyundai: Car Port for 2022 Kona Electric Camera SCC

* add missing flag

* set camera_scc in other safety modes

* Add safety test

* this will be a stock longitudinal port for now

* common cruise check

make this check common

* Fix comment typo

* Camera SCC HKG send CLU11 on bus 2

* Update CLU11 comment

* fix button test when txing

* just add bus 2 to existing addr checks

* actually no, this will never be on bus 2

* CLU11 is always on bus 0

line

* consistent param ordering

* fix test

fix test

* this is fine

* Mistook SCC for CLU, fix

* try to make this a little more clear

* add comment

* fix that

Co-authored-by: Shane Smiskol <shane@smiskol.com>
2022-08-03 00:54:41 -07:00
Adeeb Shihadeh 7f6ef7cd00
fix flashing H7 in bootstub + tests (#1007)
Co-authored-by: Bruce Wayne <batman@comma.ai>
2022-08-02 22:28:54 -07:00
Robbe Derks 6bdf249d03
Dynamic sector erase (#1006)
* dynamic sector erase

* fix red panda flash

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-08-02 21:58:56 -07:00
Adeeb Shihadeh fe3ad834c6
improved HITL test reliability (#897)
* improved HITL test reliability

* little more

* revert that

* little speedup

* some speed up

Co-authored-by: Bruce Wayne <batman@comma.ai>
2022-08-02 17:05:47 -07:00
Adeeb Shihadeh 4b86b83991
Subaru: support Outback and Global Gen 2 (#991)
* Subaru: support Outback and Global Gen 2

* send 0x321

* check bus

* fwd that

* gen2 limits

* lower max steer

* update safety replay route
2022-07-29 20:44:41 -07:00
Adeeb Shihadeh fae3ee2e81
Chrysler: Ram 1500 support (#969)
* RamInit

* Some fixes

* ram param

* cleanup steering

* invert

* couple fixups

* tests pass

* check that

* misra fixes

* same limits

* revert that

* remove those

Co-authored-by: Jonathan <jraycec@gmail.com>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
2022-07-06 22:50:29 -07:00
Shane Smiskol 3dbd30864e
Honda Civic 2022 (radarless): car safety (#942)
* civic 2022

* remove

* maybe not the right way

* Honda Radarless: add tests

* update

* different bus

* other bus

* Revert "other bus"

This reverts commit 691e045f87.

* add new HUD message

* add

* different bus

* correct freq

* small updates

* comma

* remove

* remove for now

* missing

* not needed

* make into a safety param and clean up

* this can be reverted

* clean up tests (something's broken)

* fix some errors

* this message doesn't exist on any bus

* this car doesn't have BRAKE_MODULE

* make safety more explicit and fix button safety

* fix some tests

* fix tests

formatting

clean up

* radarless uses SCM_FEEDBACK too

* fix tx msgs, clean up, make test common between bosch tests

* misra

* Fix python linting errors

add comment

* not sure where that came from

* add comments

add comments

* we can guarantee honda_bosch_long is true only if not radarless

* these are the same! 🎉

* use updated route with correct tx msgs

* helper pt bus function

* this is explained above

* use function

* no more blocked messages!

* bump openpilot

* comment

* line too long

* needs system

* send on bus 0

* Camera needs bus 2 for buttons

This reverts commit f90db5d359.

* fix button tests

* bump openpilot

* move this down

* make this explicit

* comments

Co-authored-by: vanillagorillaa <ntmccoy@yahoo.com>
Co-authored-by: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com>
2022-06-16 19:02:44 -07:00
Willem Melching 36c62afa0c
Kia EV6 (#905)
* block lkas

* taco time

* local changes

* start

* tx checks

* counter + vehicle moving

* support big can fd

* check crc

* add torque to rx checks

* tests

* little more

* little more

* get some misra coverage

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-05-19 15:59:58 -07:00
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