Commit Graph

57 Commits

Author SHA1 Message Date
Shane Smiskol
0a819ad465 Torque request bit: support multiple invalid frames (#1094)
* h90d safety

* quicker rate

* update comment

* support multi frames?

* stash

* stash

* might work?

* stash

* clean up

* revert that

* add test

* fixup tests

* clean up

* remove test

* try to combine tests

* Revert "try to combine tests"

This reverts commit f147955b94119eca0abd1b605844ab5002fb0305.

* seems simpler

* more explicit

* shouldn't be needed

* no hyundai stuff

* no line

* consecutively

* comment

* comment

* comment

* revert

* comment

* check earlier

check earlier

* ensure we don't set a negative value

* add todo comments

* for loop
2022-10-11 13:20: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
788e0b5ac9 GM: same regen check as openpilot (#1026)
* it was only checking a specific bit

* same check as openpilot

* reset on init

* unsigned

* should fix conflicts

* common

* comment

* Add missing function

* Tests

* the alternative is a mess

typo

typo

* draft

* finish common

* works but you need RegenSafetyTest before all other classes

* Revert "works but you need RegenSafetyTest before all other classes"

This reverts commit 256f3be9a86e2412220d473037d64b84167ae98d.

* This works too

* need parameterized, subtests nor super() calls correctly reset state

* Fix test and comment

* comment

* another fix...

* subclass

* ABC

* order

* fix static analysis

* can do this

* Revert "can do this"

This reverts commit 6bc63a345a2d63019a640092dd9538203e8b213d.

* this is nicer, no pylint errors

* Update tests/safety/common.py

* underscore

* dynamically detect and add tests

* simpler

* only for safety modes with a regen message

* check attr

* Revert "check attr"

This reverts commit bc37a7eedd2269bb3bc77d96762f0f0df6890991.

* need to check at test time not class init time
2022-09-12 21:32:06 -07:00
Shane Smiskol
0ca23b6778 Toyota: generic steer fault workaround safety (#939)
* toyota steer fault safety

* fix

* alternative safety

* no comment

* should be good

* same behavior, a bit simpler

* better tests

* fix comment

* update safety comment

* const is actual number of messages

* Fix bug

* misra

* Fix test

* clean up logic a bit

clean up logic a bit

fix

* fix

fix

* clean up tests

* unsigned

* forgot to rename message when merged

* Comments

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

* Update names

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

* rename rest of variables

* real time checks

* clean up safety tests

* revert

* add this

* clean up

* better name

* use common steering checks

* reverse order

* make common

* re-organize the safety

* clean up safety_toyota

* more clean up

* add comment back

* 19

* recover

* some variable name clean up

* rename and reset `valid_steering_msg_count`, another recover message

* move comment

* remove reset_toyota_timer, minor test clean up

* common test

* use init_tests

* threshold used to be: frame you can cut steer on, now it's min num of valid frames (next frame you can cut, 18+1)

* Update tests/safety/test_toyota.py

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

* fix realtime

* Update board/safety/safety_toyota.h

* Apply suggestions from code review

* Update board/safety/safety_toyota.h

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-09-06 19:12:06 -07:00
Shane Smiskol
acff2c8ec8 safety: common cruise checks (#1025)
* add function for common controls allowed setter (PCM cruise)

* Use new function when possible

fix

* consistent variable types
2022-08-12 00:28:08 -07:00
Adeeb Shihadeh
3598e8105b safety: abstract motor torque limit checks (#1018)
* abstract out motor torque steering safety

* safety: abstract motor torque limit checks

* fix comment
2022-08-09 21:05:36 -07:00
Adeeb Shihadeh
291d9e3eb9 safety: refactor steering safety checks (#1013)
* start with vw

* hyundai

* rest of driver torque cars

* remove hyundai for now

* fix cppcheck crash

* set committer

* revert gm

* remove those
2022-08-09 19:53:15 -07:00
Adeeb Shihadeh
e51aa5ebce safety: fix race condition in engagement heartbeat (#988)
* safety: fix race condition in engagement heartbeat

* move that

* fix  that
2022-07-13 14:20:00 -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
Adeeb Shihadeh
69215887dc safety: prep for CAN FD (#943) 2022-05-15 23:46:04 -07: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
ee2a4b6b58 sample_t: fixup comments (#921) 2022-04-21 20:11:13 -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 ed8897dd86b0dbfc80e6b8633f36d80c9bc91052.

* 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
Shane Smiskol
6a4daee044 safety: disallow longitudinal actuation while gas is pressed (#884)
* test implemented for Toyota

* fix Toyota interceptor

* use hasattr

* do Honda (still need Nidec ACC_HUD safety)

* add longitudinal_allowed to ACC_HUD (Nidec w/ no pedal

* rx not needed

* add base test for longitudinal

* update name

* stash

* do GM

* use gas_pressed_prev

* do tesla safety

* add full tests

* add get_longitudinal_allowed for simpler tests

* remove unnecessary tests and revert honda/hyundai

* fix honda after revert

* make sure releasing gas allows longitudinal again

* clean up

* clean up

* Just check longitudinal allowed

* don't need to reset detection

* use prev and add brake detection

* only on gas

* make sure we don't change current_controls_allowed braking behavior

* clean up tests

* use current_controls_allowed for honda & GM

* this is pretty much tested in common

* fix up tests and move common tests

* revert

* better place

* add for body
2022-04-01 19:54:40 -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
Adeeb Shihadeh
868fd5386c Hyundai: enter controls on falling edge of buttons (#875) 2022-03-16 10:37:48 -07:00
Igor Biletskyy
ca67da626f Fix MISRA violations 10.1 and 10.4 (#796)
* misra 10.1

* misra 10.4

* misra 10.4 in usb_protocol.h

* don't cast
2021-12-01 14:13:38 -08:00
Adeeb Shihadeh
fec966d6fd Honda: handle ACC state consistent with ISO 15622:2018 (#789) 2021-11-17 17:27:24 -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
Willem Melching
d1b104950a Toyota: always allow -3.5 to 2.0 m/s^2 according to ISO 15622:2018 (#714) 2021-09-06 16:36:30 -07:00
Willem Melching
8ba9b7cd37 support using safety mode param to control rx checks (#709)
Co-authored-by: Greg Hogan <gregjhogan@gmail.com>
2021-09-03 11:45:17 -07:00
Igor
6b6262c262 Fix MISRA 9.x violations (#666)
* Fix chapter 9

* fix typo
2021-06-18 15:46:40 -07:00
Igor
ddc25b0611 Update cppcheck and misra, suppress for now (#663)
* Update cppcheck and misra, suppress for now

* Add FIXME to suppression tags

* Missed one spot
2021-06-18 14:24:15 -07:00
Adeeb Shihadeh
5b14945140 Abstract RX checks for gas, brakes, and relay malfunction (#556)
* abstract gas, brake, and relay RX checks

* toyota

* mazda

* vw and subaru

* gm, honda, nissan

* chrysler

* rename

* revert that
2020-06-16 02:01:00 -07:00
Adeeb
9ebde2535c Reset state on safety mode init (#542)
* reset state on safety mode init

* more global state

* reset message seen too

* misra
2020-05-26 14:23:39 -07:00
Adeeb
d4f3f15c33 Refactor addr check (#541)
* refactor addr checks

* re-enable that

* Willem comment
2020-05-26 11:24:33 -07:00
Adeeb
e4558c0737 Safety: message length check on RX and TX (#529) 2020-05-11 12:58:33 -07:00
Adeeb
0bc864b3d5 Make torque-based steering state global (#518)
* use generic steering state vars for toyota

* chrysler

* gm

* comment

* more unnecessary lines

* hyundai

* subaru

* vw

* fix mazda
2020-04-28 10:33:20 -07:00
Adeeb
d9355c4148 Make cruise_engaged_prev a global + test case for it (#519)
* make cruise_engaged_prev a global

* test for cruise_engaged_prev
2020-04-27 22:13:30 -07:00
Adeeb
2115376412 Abstract sample speed test (#516)
* all cars move

* honda

* update comments

* vw
2020-04-27 21:36:56 -07:00
robbederks
0336f625dc Pedal gas pressed safety limits (#507)
* Fixed toyota pedal gas disengage and increased pedal limits to OP limits +5%

* Fix safety unit tests?

* Fix imports

* Fix imports #2
2020-04-16 14:52:59 -07:00
robbederks
500370aecd Make sure relay faults make it to the health packet (#492)
* Added relay malfunction handling

* Bump version

* Fixed safety test

* set/reset

* fixed test again
2020-04-09 15:53:46 -07:00
Willem Melching
d8f618492b Add ISO number for longitudinal limits flag comment 2020-04-06 15:12:01 -07:00
George Hotz
6a60b78110 touch ups 2020-04-06 15:01:48 -07:00
George Hotz
2ce65361d6 comments on unsafe flags 2020-04-06 14:54:32 -07:00
George Hotz
055ea07eea remove that unsafe flag since it isn't implemented and it's unclear how to 2020-04-06 13:37:00 -07:00
George Hotz
01b2ccbeda one more 2020-03-31 12:58:25 -07:00
George Hotz
9a30265a84 weak steering while not engaged 2020-03-31 12:55:16 -07:00
George Hotz
577f10b1ae added options for unsafe mode 2020-03-31 10:21:00 -07:00
George Hotz
83cf7bf4cb update comment 2020-03-30 18:22:08 -07:00
George Hotz
4556e7494c enable unsafe mode, toggle for use by forks that so choose 2020-03-30 18:18:54 -07:00
rbiasini
0f21b19bb3 Cleanup pedal nomenclature (#467)
* consolidate gas and brake nomenclature

* fixes in code and tests
2020-03-08 23:48:00 -07:00
Jason Young
598074c192 Volkswagen safety updates: Phase 2 (#445)
* CRC and counter checks, standstill/brake checks

* Clean up a tsk_06 that snuck through

* Be consistent about how we call _msg_esp_05

* Reduce scope: haunted by the ghost of MISRA future

* Improved check/test for in-motion braking

* MISRA styling fix
2020-02-20 13:57:07 -08:00
rbiasini
d301a59d64 WIP: Checksum checks (#403)
* add lag message check for all supported cars
* add checksum and counter checks for toyota and honda
* add rx hook regression tests
2019-12-21 10:25:54 +01:00
Riccardo
110ca03160 remove long_controls_allowed unused param and reduce technical debt 2019-12-20 16:17:37 -08:00
Riccardo
7d9bae084a better function name for msg_allowed 2019-12-18 00:17:25 -08:00
Riccardo
fb6bc3ba7e Fix Misra 2019-11-27 00:19:41 -08:00
Riccardo
2d4cb05cf1 add a safety mode counter 2019-11-26 21:20:04 -08:00
rbiasini
6249a183d6 tx_hook shall have a white-list of messages (#381)
* Started whitelisting messages

* Also toyota and cadilalc fix

* bug fixes and better checks. Need to figure out a solution for honda

* Whitelist also for subaru

* Added Chrysler as well to whitelist

* And Hyundai too

* now all supported cars should have a whitelist of messages

* Fix linter

* This should fix process replay

* Honda too is now whitelisted

* struct typedef

* Had forgot GM

* had a wrong addr for GM whitelist

* This should fix all the tests

* bump panda
2019-11-17 00:24:19 -08:00
rbiasini
cfcce8f06b WIP: Relay malfunction (#384)
* relay malfunction handling. WIP

* more cars to relay_malfunctions

* fixed safety tests

* minor change

* Fix linter

* all cars now have a relay_malfunction safety check

* added relay_malfunction safety test for fwd hooks

* added proper regression tests for relay malfunction to all cars

* temp patch to not fail regression in honda bosch

* also addr 0x194 is some nidec honda is steer control

* proper relay check for honda bosch too
2019-11-15 00:32:45 -08:00