Commit Graph

141 Commits (1dbed65e38d6f89bcd6879a3b6b9a82222ff3f98)

Author SHA1 Message Date
Riccardo 6bbae7be2f VW safety: allow cancel spam on both buses to be compatible with camera and gateway integration 2019-12-03 19:48:33 -08:00
Riccardo 878dd00ac8 solve race condition is relay_malfunction right after changing the relay status by adding a counter 2019-11-26 21:37:01 -08:00
Riccardo 8a044b3444 forgot Hyundai: now also using make_msg 2019-11-19 11:33:23 -08:00
Riccardo 4f9c879696 remove abunch of lines from safety regression tests by using common make_msg function 2019-11-19 11:29:04 -08:00
Riccardo d5c772b0b1 Fixe Toyota message white-list 2019-11-18 12:52:31 -08:00
Riccardo 212d336b3d Safety Chrysler: Added cancel spam button check 2019-11-17 22:32:13 -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
Riccardo e0de1a4fc8 define ALLOW_DEBUG in safety tests 2019-11-15 13:19:02 -08:00
Riccardo e74ed93640 safety tests a bit more simplified 2019-11-15 01:12:54 -08:00
Riccardo 2027765bd0 relay malfunction test centralized 2019-11-15 01:03:34 -08:00
Riccardo 8af1a01ac6 clean up safety tests 2019-11-15 00:52:34 -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
Riccardo d063a18885 Hyundai safety: re-enable button spam safety check 2019-11-13 23:57:29 -08:00
Riccardo e8d7ed1d90 Rename function name to not confuse safety_set_mode and set_safety_mode 2019-11-06 14:30:22 -08:00
rbiasini 48d0d0c782
VW button spam: fix safety and add tests (#306)
* VW button spam: fix safety and add tests

* button spam is actually sent on bus 2

* Fix safety test. Still need to add gas safety test

* added gas safety test to VW and using consistent nomenclature

* style fixes
2019-10-29 15:11:42 -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
Riccardo 40075321dc VW: stricter limits to comply with comma safety policy 2019-10-24 19:52:16 -07:00
Riccardo 7434c5ce28 centralize requirements for tests 2019-10-15 14:21:33 -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
Jason Young 4972376de3 Update VW regression test to follow Comma safety index refactoring (#296)
* Follow along with recent Comma safety index refactoring.
2019-10-10 14:57:16 -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 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
Riccardo ed2ac87cf4 Also moved safety tests to python3 2019-09-26 01:06:38 -07:00
Riccardo 0de9ef73cc Revert "Final 2to3 on the whole repo"
This reverts commit c92fd3bc90.
2019-09-25 17:01:13 -07:00
Riccardo c92fd3bc90 Final 2to3 on the whole repo 2019-09-25 16:58:56 -07:00
Riccardo 2dc34096a0 2to3 applied 2019-09-24 22:33:46 -07:00
Riccardo 1e2412a297 env python -> env python3 2019-09-24 17:50:53 -07:00
rbiasini d68356b924
Honda Nidec: fwd stock AEB (#257)
* Honda Nidec: fwd stock AEB

* bug

* correct aeb bit

* typo

* Revert "typo"

This reverts commit d424198b1fbc5a783c39b5bdd7d034865ed61a83.

* typo

* bug fix

* don't have tx hook blocking aeb messages from stock system

* typo

* fwd stock brake even if they are the same

* only stop forwarding aeb when aeb flag clears

* Fix safety tests

* Added fwd safety tests

* tiny bit more readable
2019-08-30 20:15:03 -07:00
Riccardo 36067e01c7 Honda safety: fixed incorrect brake decoding. Due to the specific limit of 255, this change does not affect the safety behavior 2019-08-22 20:29:44 -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
rbiasini e49d0dbbd6
Pedal: use avg between tracks (#253) 2019-07-15 13:15:22 -07:00
rbiasini 01072bec0b
Misra 11.x: pointer usage. (#250)
* RDLR, RDHR gone from safety

* back at not failing misra safety

* fix safety tests

* did not mean this

* Use get-bytes in pedal too

* Ignore Misra 11.5 and Fix 11.8 violaitons

* Fix 11.3 violations

* Neglect Misra 11.4, fix pointer issue in bootstub and rutn on Werror for pedal builds

* Fix Misra 11.6: can't assign number to void pointer

* Fix test after changing honda_moving name

* for loop is better

* Fix bugs from fbck
2019-07-10 20:56:03 -07:00
rbiasini e2d781380a
Strict compiler (#222)
have no Wall warnings from the strict compiler and enforcing it in the regression test.
2019-06-24 10:25:30 -07:00
Riccardo da59e0cb9a Fix toyota tests 2019-06-20 18:41:41 -07:00
rbiasini a3f65d66e9
capitalize MIN and MAX macros (#220) 2019-06-17 13:48:14 -07:00
quillford 19d1e41eed WIP: enhance safety replay test (#211)
* safety replay: add msg length

* add support for individual segments to safety replay

* safety replay: extend segment support to rest of safety modes

* safety replay: add debug flag

* safety replay: return if no steering msgs in segment mode

* minor refactor of safety replay
2019-06-14 16:27:15 -07:00
rbiasini 78308c0bc5
All 14.4 violations are gone (#213) 2019-06-12 20:12:48 -07:00
rbiasini 67b831ef45
Misra 15 5 (#210)
Remove 15.5 violations
2019-06-12 18:18:07 -07:00
rbiasini 57a6c493bb
Toyota gas pressed: reconcile panda code with openpilot (#212) 2019-06-12 17:51:47 -07:00
rbiasini 23461a176c
Misra 12 1 safety (#209)
* this gets rid of all 12.1 violations
2019-06-11 21:23:48 -07:00
Riccardo 242b3305fe Added fwd hook coverage test for Cadillac and created default_fwd_hook instead of nooutput and alloutput, which were teh same 2019-06-11 19:50:12 -07:00
Riccardo a605b5720e Also covering fwd hook for Subaru and GM now 2019-06-11 19:37:18 -07:00
Riccardo 133269a1a4 Added fwd test coverage for Toyota, Hyundai and Chrysler too. Removed replay tools for Chrysler, as a generic replay tool has been recently added 2019-06-11 19:24:08 -07:00
Riccardo a4653e2d7f Added fwd hook coverage to safety regression tests 2019-06-11 18:16:48 -07:00
quillford cd20d123c4 refactor tests/safety to use generic hooks (#208)
* refactor tests/safety to use generic hooks

* cleanup refactor

* removed dead code
2019-06-11 01:31:00 -07:00
quillford c381a470b1
replay test (#205)
replay drives to test for safety violations. fails if any messages are blocked while controls are allowed
2019-06-07 17:12:02 -07:00
Riccardo 7f8babb8ad Much more thorough limit safety tests on Honda, also switching long_controls_allowed 2019-06-05 16:14:10 -07:00
Riccardo 71099efaba AddedToyota safety test around long_controls_allowed logic and fixed a bug 2019-06-05 15:29:09 -07:00
Riccardo 07fd31e921 added long_controls_allowed tests in GM 2019-06-05 14:52:48 -07:00
Riccardo 6ce580a062 added function to get/set long_controls_allowed 2019-06-05 14:40:07 -07:00
rbiasini 09714e3a44
Toyota gas cancellation (#200)
* cancel on pedal press for toyota.
2019-06-05 13:38:59 -07:00
Riccardo 436b203e0b Honda safety: fixed bug and properly abstracted gas_interceptor_detected variable 2019-06-04 13:36:46 -07:00
Riccardo 220cc8f4b5 Honda safety: this concludes the proper re-naming 2019-06-04 12:43:50 -07:00
Riccardo a00a50c622 Honda safety: better naming 2019-06-04 12:21:52 -07:00
Riccardo 95b010943f Toyota: fixed regression safety tests 2019-06-03 16:53:03 -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
Riccardo c6eeaad667 Subaru: added last engage/disengage regression test 2019-03-13 20:17:19 -07:00
Riccardo Biasini 37d46e0c78 Subaru: added subaru safety tests 2019-03-13 11:52:50 -07:00
Riccardo Biasini e437b9b4b1 Subaru: fixed bug and added safety tests 2019-03-11 02:12:22 -07:00
Riccardo Biasini 4f73cb48b8 Toyota pedal: checking for no pedal being commanded when openpilot is off 2019-03-02 15:22:09 -08:00
Drew Hintz 7b504d2f88 panda safety test that replays drives of saved CAN messages (#151)
* panda safety test that replays drives of saved CAN messages

* utility to trim Cabana CSV logs to just messages relevant for panda safety testing

* when trimming, only output the same line once even if it matches both criteria
2019-02-21 13:35:04 -08:00
Riccardo 93266a9fa7 Hyundai: allow the same max steer torque as stock 2019-01-28 21:46:13 -08:00
Riccardo be0061dccb Chrysler: safety now based on motor torque 2019-01-02 21:53:07 -08:00
Riccardo Biasini 039d1834b6 Chrysler: fixed regression test 2019-01-01 20:00:11 -08:00
Riccardo cf3ecd629d Chrysler safety: re-using hyundai framework 2018-12-28 19:20:57 -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
Riccardo 8291971d9a Toyota: using a more generalized CRUISE_ACTIVE bit that works on all cars 2018-11-04 13:57:25 -08:00
Robert Cotran 6385551f29 Added Tesla safety changes. (#132)
* Added Tesla safety changes.

* Use generic interpolate function from safety.h

* Moved Tesla safety include to within IFDEF PANDA as legacy neo boards don't support floats used in Tesla safety code

* Remove double-pull code and time tracking from CAN message.

Better enclose Tesla-relevant code in ifdef PANDA due to use of floats

* Changes as per requests by @rbiasini from conversations in https://github.com/commaai/panda/pull/132

* Removed unused variable

Do interpolation check at every step (not every 25)

Change tesla safety constant number to 8, not 7

* Add the HYUNDAI safety number

* Remove unused struct and function (fsample)

* fix build

* Add stub gmlan implementations in safety tests
2018-10-04 19:22:10 +02:00
Riccardo 627713948a GM Volt: allowing 300 max steer 2018-09-20 16:42:11 -07:00
Riccardo 63b7926364 Hyundai safety: temporarily disabled button spam check to avoid camera faults 2018-09-07 20:43:13 -07:00
Riccardo f2292e420b Hyundai: added safety check for button spam 2018-08-31 22:47:50 -07:00
Riccardo 5398abff5f Hyundai safety: added tests for cruise enable/disable too 2018-08-30 00:16:58 -07:00
Riccardo a91d7efad7 added hyundai regression test 2018-08-30 00:04:05 -07:00
Riccardo ba8762d5a3 Toyota safety: vars and consts need 'toyota_' prefix 2018-07-17 19:43:06 -07:00
Riccardo 813218deae GM: allowing higher brakes in Volt, so decel can reach between 3 and 3.5 m/s2 2018-06-14 14:12:16 -07:00
rbiasini 38a9ea9ad9
added gm safety for steering (#123)
* added gm safety for steering
* safety tests done for safety_gm
2018-06-13 23:13:59 -07:00
Ted Slesinski 7caba241d0 Addition to Bosch safety to support Hatchback (#111)
* Addition to Bosch safety to support Hatchback

The computer brake is shown on 0x17c sensor on Accord and CR-V. We assumed all Bosch Hondas had the new 0x1be message which reports manual brake, but Civic Hatchback is not like this- It doesn't have this message and 0x17c works like the other Hondas so we are are passing a parameter from Openpilot for this.

* Renamed variable

* Make comment more descriptive

* Added safety check for cancel-only spamming

* Add regression test for brake on accord and crv

Init with bosch safety variables

Some more testing changes (still broken)

Make second test work

* Adds one more ttest

* Cannot implicitly convert type 'int' to 'bool '

* ok to spam resume if controls_allowed==true

* need to use current_controls_allowed. Still need to fix the message blocking

* checking for bus 0 on button spam

* better to use the car name in front of global vars

* even better name and fixed safety tests
2018-06-06 14:20:07 -07:00
Commaremote bf70f51596 Safety: increase buffer for sampled signals. TBD a violation feedback from board to prevent car faults 2018-06-03 17:39:57 -07:00
Commaremote b0541a8316 Cadillac: monitoring the 4 torque messages independently 2018-06-03 01:53:06 -07:00
Riccardo cd1dba9ff8 Cadillac: fixed bug in regression safety 2018-06-02 23:30:30 -07:00
rbiasini c7e2c2d696
Cadillac (#119)
* added some steer safety to Cadillac

* bug fixes

* added cadillac full steering safety. To be tested

* RT checks and max checks working. Need to test driver torque based limits

* cadillac steer safety should be done

* unneded lines
2018-06-01 19:45:29 -07:00
George Hotz 13e850e18e more correct 2018-04-12 09:09:14 -07:00
Willem Melching f295063d16 add new define to tests 2018-04-12 13:45:27 +02:00
George Hotz e7a2b3a209 add ipas tests 2018-04-11 14:42:56 -07:00
George Hotz 894572c843 fix tests 2018-04-11 14:34:17 -07:00
Riccardo 02c1ddf5fc Revert "added steer override check when IPAS is in control (#106)"
This reverts commit 7d21acbccc.
2018-04-11 14:00:25 -07:00
Willem Melching 7a1f3197e2 add panda python package test and fix safety test 2018-04-07 16:46:26 +02:00
Willem Melching 021dde7ce6 move saftey test helper files into safety folder 2018-04-07 16:34:36 +02:00
rbiasini 7d21acbccc
added steer override check when IPAS is in control (#106)
* added steer override check when IPAS is in control

* same override threshold as carController

* added initial safety tests for angle control

* cleaned up safety tests and added ipas state override check

* ipas_override is an unnecessary global variable

* bump panda version
2018-04-05 13:30:44 -07:00
Willem Melching 1c88caf917
Safety code testing (#104)
* inital infrastructure for panda safety testing

* add test for toyota acceleration

* test for non real time torque rate limits and refactoring

* add test for cruise disable

* fix toyota limit down

* add tests for realtime limits

* test for torque measurements

* fix toyota test setup

* honda button logic

* test for brake logic

* tests for gas logic

* test steer, gas and brake message contents

* add test script

* fix hardcoded limits
2018-04-02 20:41:52 +02:00