Commit Graph

835 Commits (spacecruft)

Author SHA1 Message Date
Riccardo e8d7ed1d90 Rename function name to not confuse safety_set_mode and set_safety_mode 2019-11-06 14:30:22 -08:00
Comma Device bac4d85434 dos and python3 2019-11-06 21:42:07 +00: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
Riccardo 256d274e76 Fix Mac installation instruction per: https://github.com/commaai/panda/pull/308/files 2019-10-31 16:23:55 -07:00
Robbe b143a1cf9e Fixed Misra complaint 2019-10-31 11:58:36 -07:00
Robbe 606f1d9131 Fixed RTC on non-uno boards, second try. Cannot work when there is no xtal. 2019-10-30 18:30:00 -07:00
robbederks 933c757705
Fix RTC on non-uno boards (#311)
* Fan and IR at 0 when in power savings mode

* Initialise RTC for all boards, not only uno. Fixes hang while getting time from non-initialized RTCs
2019-10-30 18:11:30 -07: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
robbederks 6cccf969ab
Fan and IR at 0 when in power savings mode (#309) 2019-10-29 12:36:47 -07:00
Riccardo 05373282a2 board get_sdk scripts were left on python2 2019-10-29 11:51:37 -07:00
Robbe 1965817d30 Changed default values for testing 2019-10-25 16:24:53 -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 e2e2be92c9 add safety mode to health packet 2019-10-24 15:33:27 -07:00
Riccardo 101238c7f6 turned on VW ignition based CAN logic 2019-10-22 17:27:35 -07:00
Riccardo a0d8d5dae7 fix misra 5.3: check_ignition is intended as check_started and can't be used twice 2019-10-22 16:12:18 -07:00
Riccardo ea636de615 made check_ignition function to both look at ignition_line and ignition_can 2019-10-22 15:27:55 -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
dekerr 55dfa52306 Update core to CMSIS 5.6 release (#251)
* initial commit

* release version
2019-10-16 15:19:01 -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 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
robbederks 0812362b52 GPS UART fix until boardd is refactored (#294)
* Temporary GPS fix

* spaces
2019-10-08 19:41:10 -07:00
robbederks 0894b28f1e Fixed USB power mode on black (#291)
* Fixed USB power mode on black

* bump version
2019-10-05 20:34:19 -07:00
rbiasini 4b3358c921
patch to be able to switch from EON to PC with a Panda that has EON b… (#290)
* fix switching from EON to PC with a Panda that has EON build and not 12V supply
2019-10-04 14:51:26 -07:00
robbederks a95c44a717
Made setting of NOOUTPUT on no heartbeat more efficient (#287)
* Made setting of NOOUTPUT on no heartbeat more efficient

* Stupid mistake

* Fixed hardcoded safety mode
2019-10-04 13:30:00 -07:00
robbederks 9486836886
UART instability fix with high interrupt load (#283)
* Fixed UART overrun error

* Added stability test scripts

* Refactored UART code. ESP/GPS now uses DMA in circular mode to directly write into the ring buffer, saving a bunch of interrupts and potential race conditions.

* Changed stability test to use amount of bytes instead of amount of non-zero messages, since the ring buffer pointer is only updated on half or full DMA transfer or on line idle (e.g. no more 1 char messages from the gps)

* Increase data limit. It's too low sometimes in normal operation

* Forgot to set write pointer in ring buffer

* Increased test limit even more
2019-10-04 13:28:56 -07:00
rbiasini 9a9e9d47bc
Fix usb_power_mode missing initialization (#289)
* Fix usb_power_mode missing initialization

* typo

* re-added NONE usb power mode, so usb_power_mode is only set in set_usb_power_mode func
2019-10-04 10:48:17 -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
rbiasini 78ef4a6ebc
Stop charge (#284)
* CDP by default in EON build on white panda

* Cleaned up power mode setting

* send usb power mode in health

* cleaner CDP setting on ignition

* bump panda
2019-10-02 11:48:40 -07:00
Arne Schwarck 5266a40287 Fix typo (#286) 2019-10-02 11:40:38 -07:00
Riccardo f4787ec5a2 Revert "turn on CDP when ignition switches on (#281)"
This reverts commit 8c1df559f7.
2019-10-01 17:01:14 -07:00
Riccardo d37daee978 Revert "NONE and CLIENT should be the same thing in white/grey pandas"
This reverts commit e97b283e77.
2019-10-01 15:20:59 -07:00
Riccardo e97b283e77 NONE and CLIENT should be the same thing in white/grey pandas 2019-10-01 15:16:13 -07:00
rbiasini 8c1df559f7
turn on CDP when ignition switches on (#281) 2019-09-30 21:48:30 -07:00
rbiasini fac0277169
Misra update (#280)
* Updated cppcheck ref. New rules to be fixed

* changed 2 MACRO names that had more than 31 characters in common

* Fix newly popped 10.4: same type on arithmetic ops

* Fix 18.4: operators should not be applied to an expression

* ensure a NULL pointer isn't dereferenced
2019-09-27 17:18:02 -07:00
Robbe c4ac3d63be Disable GPS load switching on black pandas 2019-09-27 13:22:06 -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
Jafar Al-Gharaibeh 9881e61184 Panda for Mazda (#165)
Implement the safety limits
Smarter forwarding:
   Detect what msgs are sent by OP and drop corresponding CAM msgs
   Detect if Stock CAM is connected
   Detect if CAM is in hardware passthrough

Signed-off-by: Jafar Al-Gharaibeh <to.jafar@gmail.com>
2019-09-09 15:58:41 -07:00
Bugsy a8ed7d2199 add subaru outback/legacy to subaru safety (#259)
* add subaru outback/legacy safety

* subaru safety passes misra check

* change violation to bool
2019-09-09 15:13:02 -07:00
George Hotz bdeb1c953f mazda is #12 2019-09-09 14:56:14 -07:00
Riccardo 14ea4d2e07 merge safety gm in a single file 2019-09-08 14:07:05 -07:00
Vasily Tarasov bf1ef875ee Add GM passive safety mode (#266) 2019-09-08 14:02:27 -07:00
BogGyver c131fffaeb fix canflash for pedal (#267) 2019-09-05 08:24:49 -07:00
George Hotz 3397b1527e only allow bootloader entry on debug builds 2019-09-04 16:05:50 -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
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
robbederks d68508c79a Gpio race condition fix (#263)
* Fixed pedal not initializing

* Interrupt changes

* More changes
2019-08-28 12:53:51 -07:00
robbederks d69d05fc0f Fixed pedal not initializing (#262) 2019-08-26 19:24:24 -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
Robbe 519e39e494 Changed heartbeat timeout to be 2 seconds on no ignition 2019-07-24 14:36:01 -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
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 fd68c26aba
Propagate can_push errors (#249)
* Misra 17.7: counting can_push errors
2019-07-10 17:27:26 -07:00
George Hotz fcb1208e15 fix weird code in USB_ReadPacket 2019-07-09 15:08:25 -07:00
Riccardo 0b19206360 Misra 17.7: The value returned by a function having non-void return type shall be used. We should hang on initial failed safety_set_mode 2019-07-08 20:08:53 -07:00
Riccardo f45dd04c67 cppcheck: ignore redundantAssignment and selfAssignment for registers in llcan.h 2019-07-08 17:16:15 -07:00
Riccardo 9ce6311558 Misra 12.1 (operator order) and 10.4 (incompatible essential types) fixes, arised after properly checking UID_BASE config 2019-07-08 15:51:20 -07:00
rbiasini 23e3684d70
Cppcheck unused functions (#247)
* Skip cppcheck on unused functions that are consumed in large headers we can't pass to cppcheck
2019-07-08 15:13:52 -07:00
Riccardo c97d60be64 Removed bad language 2019-07-08 12:05:08 -07:00
Riccardo d9d0a62f2b Misra 5.5: missed this change from previous PR 2019-07-07 22:22:05 -07:00
rbiasini 85fa3c02ae
Misra 5.5: Identifiers shall be distinct from macro names (#246)
* Misra 5.5: Identifiers shall be distinct from macro names
2019-07-07 22:19:02 -07:00
Riccardo 190d604a0b Pedal: 2 minor fixes to Misra 15.7 (else needed) and 17.7 (non-void output must be used) 2019-07-07 22:07:14 -07:00
Riccardo 8ea01ff127 Pedal: no built-in functions to avoid puts and putc re-definitions 2019-07-07 21:38:40 -07:00
rbiasini 1f40d1e6a6
Misra pedal (#245)
* Fix misra on pedal
2019-07-07 16:59:31 -07:00
Riccardo e6dc4172b1 Minor indent error 2019-07-07 15:57:14 -07:00
Riccardo 247e128b45 Fix strict compiler on bootstub build 2019-07-07 15:05:47 -07:00
Riccardo ba68569216 Removed build strict test and enabled -Werror flag 2019-07-07 14:46:03 -07:00
rbiasini f7bd2c2f38
Misra 10.4: fix last 2 violations (#242) 2019-07-04 02:27:21 -07:00
rbiasini 9be5fdead9
finished misra 17.8 (#241) 2019-07-04 01:37:26 -07:00
rbiasini 3c3aba3dbc
Misra 10.4: Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category (#240)
* Almost done with 10.4, a couple of non-obvious violations remaining
2019-07-04 01:04:58 -07:00
Riccardo f2a3a177b3 Misra 15_7: fix what seems to be a false positive of cppcheck 2019-07-03 20:53:00 -07:00
rbiasini 812ace5386
Misra 15_7: if … else if constructs should be terminated with an else clause (#230)
* Fixed all Misra 15_7 violations
2019-07-03 20:48:02 -07:00
rbiasini 1bd9284372
Misra 17.7: the value returned by a function having non-void return shall be used (#237)
* Fixed Misra 17.7 violations except for can_push
2019-07-03 16:01:01 -07:00
George Hotz 18c9e88bc0
Merge pull request #238 from commaai/misra_17_8
Misra 17.8: a function parameter should not be modified
2019-07-03 13:36:49 -07:00
George Hotz 7ac321de4e
Merge pull request #235 from commaai/memxxx
memxxx function changes to be Misra compliant
2019-07-03 13:35:49 -07:00
Riccardo 7cd80de23a typo 2019-07-03 02:07:02 -07:00
Riccardo 385e33b32c 12.1 regression 2019-07-03 02:04:25 -07:00
Riccardo 955842bae6 WIP 2019-07-03 01:59:27 -07:00
rbiasini ea908cbb75
10_1 violations: Operands shall not be of an inappropriate essential type (#233)
* 10_1 violations
2019-07-02 23:43:06 -07:00
rbiasini fa33038055
Fix Misra 5.3: An identifier declared in an inner scope shall not hide an identifier declared in an outer scope (#236)
* Fix Misra 5.3
2019-07-02 22:39:00 -07:00
Riccardo cf6985ad15 memxxx function changes to be Misra compliant 2019-07-02 17:43:54 -07:00
Riccardo ecb9b6c01f Revert "Misra 10 1: Operands shall not be of an inappropriate essential type (#232)"
This reverts commit 8732e4faf0.
2019-06-30 13:43:21 -07:00
rbiasini 8732e4faf0
Misra 10 1: Operands shall not be of an inappropriate essential type (#232)
Fixe Misra 10.1 violations
2019-06-30 15:07:04 -05:00
rbiasini ae816c104a
Fix 15_6 violations (#231) 2019-06-28 13:46:57 -07:00
rbiasini abd841e9be
Fix all 16_4 violations (#229) 2019-06-27 15:50:00 -07:00
Riccardo ec3d0386c2 refactor set_power_save_state 2019-06-26 18:24:21 -07:00
Riccardo c27e7848f3 fix conflicts 2019-06-26 16:17:30 -07:00
rbiasini 4886b6b984
Misra 12.1: The precedence of operators within expressions should be made explicit (#227)
* Fixed all misra 12.1 violations
2019-06-26 16:16:35 -07:00
Riccardo 3fd6b337f9 ops, bug 2019-06-26 15:59:32 -07:00
Riccardo e3c5e7da8c Fix Misra 15_5 violations 2019-06-26 15:52:34 -07:00
Riccardo 52838e1c2a WIP 2019-06-26 14:47:06 -07:00
rbiasini 73ae4f6acf
Misra 14.4: The controlling expression of an if statement and the controlling expression of an iteration‑statement shall have essentially Boolean type (#225)
* Fixed 14.4 Misra violations
2019-06-26 13:13:16 -07:00
Riccardo 8a45958dfe Misra 17.7: puts function should have void output 2019-06-26 13:05:31 -07:00
Riccardo 97a11115bb hardwired input param is now a boolean 2019-06-26 12:18:06 -07:00
George Hotz fd96c02215 disable SPI on the EON variant 2019-06-26 12:01:57 -07:00
George Hotz 0e67890ac7
Merge pull request #224 from commaai/misra_13_3
Fixed Misra 13.3: A full expression containing an increment (++) or d…
2019-06-26 11:51:50 -07:00
Riccardo e41b5a4c4f Fixed Misra 13.3: A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator 2019-06-24 19:23:53 -07:00
Riccardo 541f8beee3 Fix bad bug 2019-06-24 19:16:53 -07:00
Riccardo 6a9ae3b7c3 The comma operator should not be used 2019-06-24 18:12:23 -07:00
Riccardo 5e3458df72 Fix Misra 20.7: Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses 2019-06-24 17:57:18 -07:00
Riccardo d1e6bd86b1 Fix Misra 16.6 and 16.7 by using a different COMPILE_TIME_ASSERT 2019-06-24 17:50:01 -07:00
Riccardo f03c3a9fb6 Fix Misra 8.11: When an array with external linkage is declared, its size should be explicitly specified 2019-06-24 17:10:14 -07:00
Riccardo 83eccb0b5c Fix obvious 10.1 Misra violations: Operands shall not be of an inappropriate essential type 2019-06-24 16:43:11 -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 57217027e2 Toyota safety: block LTA message in TSS2 cars 2019-06-20 18:33:28 -07:00
Riccardo 2ef429e656 -pedantic is too much, let's fix wall first 2019-06-17 21:39:00 -07:00
Riccardo 198a4459cc MAX is now macro and cannot be used as function param 2019-06-17 18:48:38 -07:00
Riccardo 578ef22d52 Misra 12.1 violation in MIN/MAX macros 2019-06-17 18:39:17 -07:00
Riccardo 65fb5a48e7 Macro can trigger Misra violation due redef of var before their use 2019-06-17 15:29:04 -07:00
rbiasini 0a94643321
Misra 15 7 (#219)
* Fixed Misra 15_7 violations

* switch case for buttons
2019-06-17 14:13:50 -07:00
rbiasini a3f65d66e9
capitalize MIN and MAX macros (#220) 2019-06-17 13:48:14 -07:00
rbiasini bacfcd0fd0
Make macros to get msg attributes (#218)
* made GET_ADDR, GET_BUS and GET_LEN macros

* for simplicity, addr is int instead of uint32_t as it can only use up to 29 bits
2019-06-14 19:13:05 -07:00
George Hotz 00ebc16936 track can overflows 2019-06-14 13:33:30 -07:00
George Hotz d33bb4117c oops, have to call that now 2019-06-14 13:28:15 -07:00
George Hotz e0df5c81f6 pull in libc changes from harness branch 2019-06-14 13:26:27 -07:00
George Hotz 96dcfb18d4 pull in uart changes from harness branch 2019-06-14 13:26:01 -07:00
George Hotz 59eaec5dd6 add volatiles to the ring buffer pointers 2019-06-14 13:22:33 -07:00
George Hotz b35285ba7d can push failed only with debug 2019-06-14 13:19:30 -07:00
Riccardo 464f5c2b22 Tesla safety: reduced scope of vars 2019-06-14 12:30:59 -07:00
George Hotz f9d2e8876b can does not sleep 2019-06-14 12:14:21 -07:00
rbiasini 3601212ec5
Removed 10.1 violations (#217) 2019-06-14 12:08:59 -07:00
rbiasini c066c7838c
Misra 10.4 violations (#216) 2019-06-14 10:57:14 -07:00
rbiasini 78308c0bc5
All 14.4 violations are gone (#213) 2019-06-12 20:12:48 -07:00
Riccardo 0dc4f6fd30 cadillac safety: enforcing index not going outside array size 2019-06-12 20:07:42 -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
Riccardo 4c9e0af29e simplification of cadillac_get_torque_idx 2019-06-12 13:48:34 -07:00
Riccardo 2f71ba995a Tesla safety now using same line break rules as rest of the code 2019-06-12 13:10:51 -07:00
Riccardo 55679532aa Fix Misra 20.1 violations: Moved safety declarations in its own header and qdded optional input to run misra tests for safety code only. 2019-06-12 06:35:47 -07:00
Riccardo 0e251062c6 Fix Misra 10.8 violations: could not directly cast complex expressions from float to int 2019-06-11 21:46:10 -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 264de67fe8 Minor clean up to Subaru fwd hook 2019-06-11 19:42:53 -07:00
Riccardo b4c52a1bda Cleaned up subaru FWD hook 2019-06-11 19:40:56 -07:00
Riccardo f4419b08b9 Simplify get_ts_elapsed 2019-06-11 02:07:02 -07:00
Riccardo fa1c928961 Fix Misra 13.4 on safety code 2019-06-11 01:10:45 -07:00
Riccardo 7372ade33e Fix Misra 15.6 on safety code 2019-06-11 01:07:41 -07:00
Riccardo a2d5c9b5f4 Fix Misra 17.8 on safety code 2019-06-11 00:58:22 -07:00
Riccardo b7ed7adc71 Fix Misra 20.7 on safety code 2019-06-11 00:49:26 -07:00
Willem Melching 50658b2b00 Use dfu-utils binary from panda repo on EON 2019-06-10 13:56:13 -07:00
Riccardo 1dfe11ed3a Set controls_allowed=0 in Chrysler safety init 2019-06-07 17:36:07 -07:00
Riccardo d77fa17913 deleted unnecessary subaru safety init and using nooutput_init instead 2019-06-07 15:11:28 -07:00
Riccardo 71099efaba AddedToyota safety test around long_controls_allowed logic and fixed a bug 2019-06-05 15:29:09 -07:00
rbiasini 380b7c75c5
Long allowed (#202)
* added long_controls_allowed to cars safety code. long_controls_allowed init to 1 for now, so safety tests pass
2019-06-05 14:00: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
Commaremote 192fd05318 Toyota safety: fixed rounding logic 2019-06-03 16:06:39 -07:00
George Hotz b35f6ff566 legacy build is no longer supported 2019-05-23 13:23:21 -07:00
George Hotz a06af9f2aa always LIVE on EON 2019-05-23 12:39:54 -07:00
George Hotz dc5979f66a LIVE on EON 2019-05-23 12:39:54 -07:00
George Hotz 0b26645b12 no EON by default 2019-05-23 12:39:54 -07:00
George Hotz 1906a4b769 panda now draws below 100mw in power save mode 2019-05-23 12:39:54 -07:00
George Hotz e70b44aa57 move that to main.c 2019-05-23 12:39:54 -07:00
George Hotz dfce5f6e36 minor fixes, and no more autobaud 2019-05-23 12:39:54 -07:00
George Hotz 96a7e3196f a soothing blue in power save mode 2019-05-23 12:39:54 -07:00
George Hotz a74f001ba7 refactor power savings to depend on car started bit 2019-05-23 12:39:54 -07:00
George Hotz 386d5dfdf2 can wake from sleep is removed, didn't work in the first place 2019-05-23 12:39:54 -07:00
George Hotz 881b1f442b not on pedal chip 2019-05-23 12:39:54 -07:00
George Hotz 0a9f8eb581 remove many ifdef PANDA 2019-05-23 12:39:54 -07:00
George Hotz 506900576b remove nested includes and include guards 2019-05-23 12:39:54 -07:00
George Hotz 3810452a02 WTF WHY WAS THIS SHIT PUT EVERYWHERE 2019-05-23 12:39:54 -07:00
George Hotz 3cf8db9351 can.h always has CAN3 2019-05-23 12:39:22 -07:00
George Hotz 1f97c2189b refactor pedal bootstub to use llcan 2019-05-23 12:39:22 -07:00
George Hotz 58ec63b31f oops, backward 2019-05-23 12:39:22 -07:00
George Hotz 6255097a10 new style power savings 2019-05-23 12:39:22 -07:00
George Hotz 6b282f1c06 tesla doesn't need a special LIN hook 2019-05-23 12:39:22 -07:00
George Hotz 1d2467756e refactor #ifdef EON 2019-05-23 12:39:22 -07:00
George Hotz 4af036e93a fixup puts 2019-05-23 12:39:22 -07:00
George Hotz 2c1e5f6325 the refactor continues 2019-05-23 12:39:22 -07:00
George Hotz 7517f2c174 remove ifdef PANDA from main 2019-05-23 12:39:22 -07:00
George Hotz aec40ae91c remove fan, as it was only for NEO board 2019-05-23 12:39:22 -07:00
George Hotz 605bb27bce fix bootstub build 2019-05-23 12:39:22 -07:00
George Hotz c0f1f6e068 move things around for simplicity 2019-05-23 12:39:22 -07:00
George Hotz f32f0395fd factor out clear_send 2019-05-23 12:39:22 -07:00
George Hotz 8221927215 this is probably broken. refactor out llcan and clock 2019-05-23 12:39:22 -07:00
Riccardo 1114cb1ad3 ELM327 safety mode: re use existing functions 2019-05-22 18:41:26 -07:00
rbiasini 1aa00c95ee
Misra c2012 (#192)
* Started making panda misra compliant: this fixes some of 12.1 warnings

* Also added a regression test for strict compiler warning
2019-05-20 22:13:45 -07:00
George Hotz 047bd725e0 fix tests and remove rev b support 2019-05-19 09:12:26 -07:00
Riccardo 3e199cb914 Subaru safety: ES_LKAS message should not be forwarded 2019-05-11 22:27:07 -07:00
dekerr 4a3b587c64 generate dependencies and clean (#184)
* gen dependencies
Main.o and bootstub.o were missing headers (like recent power_saving.h). Generate them instead to guarantee makefile re-makes if any dependency is modified.
2019-05-06 17:33:38 -07:00
Riccardo 005e131049 Toyota Safety: cleaned up logic for TSSP2.0 cars 2019-05-05 20:29:56 -07:00
wocsor b53fb2715c add ACCEL_CMD to filtering for TSSP2.0 cars (#185) 2019-05-05 20:22:18 -07:00
Riccardo Biasini 3b351b7018 Minor fix to current type 2019-04-23 13:53:43 -07:00
George Hotz 64bcc89a9c Subaru: 545 msg must be generated 2019-04-14 22:52:38 -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 f383eee968 Power saving: wake on RX and don't print durint IRQ 2019-04-08 19:21:37 -07:00
Riccardo 9540db7445 Chrysler safety: better to mention messages we don't want to forward 2019-04-04 12:50:40 -07:00
Drew Hintz 1049502644 chrysler: forward bus 0 to bus 2 (#177)
* chrysler: forward bus 0 to bus 2
This keeps the stock LKAS camera active so that we can copy data from its messages.

* Only forward if giraffe switches are 1 0.
Forward LKAS_HEARTBIT messages from stock camera to bus 0.
2019-04-04 10:05:00 -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 06958e424c Fix pedal bootstub build 2019-03-22 21:42:14 -07:00
Nigel Armstrong f5817e6bd7 Fix Pedal bootstub version 2019-03-22 21:06:47 -07:00
Riccardo 9b5b696e83 Subaru: remove GM leftover 2019-03-20 14:20:21 -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
Riccardo 5686dae25b Subaru updated driver factor 2019-03-12 23:47:54 -07:00
rbiasini a6193a8285
Dcp remove (#168)
* No DCP charge mode when building from EON
2019-03-11 23:41:40 -07:00
Riccardo Biasini e437b9b4b1 Subaru: fixed bug and added safety tests 2019-03-11 02:12:22 -07:00
Riccardo Biasini 176f1325ba Subaru: added proper safety model 2019-03-11 00:29:50 -07:00
Riccardo 0b10bb70ec Subaru safety: move camera to bus 2 2019-03-05 15:37:17 -08:00
rbiasini bce279a627
Pedal: only one firmware (#164)
* Pedal: only one firmware
2019-03-03 21:04:41 -08:00
Riccardo Biasini 4f73cb48b8 Toyota pedal: checking for no pedal being commanded when openpilot is off 2019-03-02 15:22:09 -08:00
Riccardo 39c1e39e81 Cadillac: added brake msg forwarding 2019-02-18 17:04:10 -08:00
kernyan e0dd55841a Fixed undefined reference error when "make recover" in EON
In fd233832ef
the linker flag -lgcc might not work on EON as it does not have the
correct library.

The fix was a workaround in sha.c such that we no longer need to import
function __aeabi_llsr from library, by replacing right shift operation
with const argument.

E.g.,
uint64_t a = b >> i // requires __aeabi_llsr from libgcc
uint64_t a = b >> 2 // does not require external library

Resolves: #522
2019-02-13 00:43:30 -08:00
rbiasini c91f038eab
Toyota pedal support (#159) 2019-02-07 12:48:28 -08:00
Riccardo de1ba06d71 Build optimizer: back to Os now that 'make --recover' is fixed 2019-02-06 11:45:30 -08:00
Drew Hintz fd233832ef add -lgcc flag to fix "undefined reference to __aeabi_llsr" (#156)
https://github.com/commaai/openpilot/issues/522
2019-02-06 11:44:18 -08:00
Riccardo 1cc74e2b42 Reverted code optimizer option to O2 after 'make recover' broke 2019-02-05 22:17:35 -08:00
rbiasini 1218d09edb
Cadillac ascm proxy (#155)
* added safety_ascm

* better using one funciton

* GM_ASCM safety mode by default

* fixced ign bug and passing everything for now

* blocking 0x152-0x154 and reforwarding 0x153

* gotta fwd 152 as well on CH bus

* adding braking message block

* blocking gas cmd as well

* allow cadillac supercruise to pass through

* no more hardcoded ascm safety mode
2019-02-05 18:37:02 -08:00
Riccardo 93266a9fa7 Hyundai: allow the same max steer torque as stock 2019-01-28 21:46:13 -08:00
Bugsy d275fa8489 Subaru: Forwarding (#152)
Bus 0 to 1
Bus 1 to 0 exept LKAS
2019-01-28 21:42:06 -08:00
Drew Hintz 9ee628557f optimize board build for size to avoid going over the limit. (#150)
* optimize board build for size to avoid going over the limit.
Here are the sizes of board/obj/panda.bin with different settings:
-O2 32228
-Og 30172
-Os 28028

* warning if panda.bin is over the panda's limit

* if bin is too big, error out
2019-01-23 13:24:29 -08:00
Riccardo 20e8fa9716 Start introducing Bounties 2019-01-17 16:17:53 -08:00
Riccardo Biasini 37ee289fe6 chrysler safety: fixed comments 2019-01-06 19:04:26 -08:00
Willem Melching c2dfbadee7
tesla safety: return -1 to block forward (#149) 2019-01-03 18:07:38 +01:00
Riccardo be0061dccb Chrysler: safety now based on motor torque 2019-01-02 21:53:07 -08:00
Riccardo Biasini 9193eebfa0 Chrysler: safety limits updated 2018-12-30 19:05:04 -08:00
Riccardo 04f1d44f0e Chrysler safety: 3 sa max rate down for now 2018-12-29 14:54:09 -08:00
Riccardo cf3ecd629d Chrysler safety: re-using hyundai framework 2018-12-28 19:20:57 -08:00
George Hotz 49ed9bc1ec Update CLICKS for longer bootup time of EONS and avoid unwanted fast charge mode
updated panda version
2018-12-16 18:23:39 -07:00
Riccardo 293fa33f83 Honda: fixed message forwarding addresses from can2 to can0 2018-11-09 17:58:55 -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
rbiasini c05b15b358
Toyota frc on (#141)
* Honda: forwarding CAN0 to camera, so camera can stay on

* forward cam on toyota

* fwd some honda camera msgs

* add crv and rdx steering msg to honda fwd filter

* only fwd cam on toyota if frc is connected

* toyota: remove unused variables

* toyota: don't forward frc bus when switch 1 is high

* toyota: check when switch 1 is high
2018-11-04 15:06:44 -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
rbiasini 6f157aab68
Toyota frc on (#140)
* Honda: forwarding CAN0 to camera, so camera can stay on

* forward cam on toyota

* fwd some honda camera msgs

* add crv and rdx steering msg to honda fwd filter

* only fwd cam on toyota if frc is connected

* toyota: remove unused variables

* toyota: don't forward frc bus when switch 1 is high
2018-11-03 22:33:06 -07:00
rbiasini 915ee4f585
Honda: forwarding CAN0 to camera, so camera can stay on (#139)
* Honda: forwarding CAN0 to camera, so camera can stay on

* fwd some honda camera msgs

* add crv and rdx steering msg to honda fwd filter
2018-11-03 17:11:51 -07: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
Vasily Tarasov 53aef76cf1 GM: passive on LKA-only cars (#135)
If LKA camera is still connected to powertrain.
2018-09-06 21:48:47 +02:00
Riccardo 1c0ffd1a4d Hyundai safety: simplifications 2018-09-05 16:08:42 -07:00
Andrew Frahn 56794d6e1a Hyundai Safety Auto-Detect which CAN bus Camera is on (#134)
* This compiles, and steers the car, but no unit tests performed (yet)

* Updates

225 for max torque after discussions with users in #hyundai
Fixed violation disable as requested

* Hyundai Auto-Detect which CAN bus Camera is on
2018-09-05 15:39:37 -07:00
Riccardo f2292e420b Hyundai: added safety check for button spam 2018-08-31 22:47:50 -07:00
George Hotz 1a8c4c48a1 Hyundai safety: fwd option 2018-08-30 11:54:44 -07:00
Riccardo 487fcaef2f Safety hyundai: fixed RT check 2018-08-29 19:30:14 -07:00
Riccardo 04270b8fa7 Safety Hyundai: bug fixes 2018-08-29 19:23:49 -07:00
Commaremote d0c28b7b53 Hyndai safety: tuned 2018-08-28 20:05:58 -07:00
Commaremote ad1ba6970d Hyundai safety: fixed wrong param 2018-08-28 18:12:21 -07:00
Riccardo 8a1dcbec54 Hyundai safety: added Santa Fe safety: need to be tested. Removed some unnecessary funcitons 2018-08-28 16:01:40 -07:00
Commaremote 4e9d08aabb Hyundai safety: controls_allowed ==1 by default for now 2018-08-24 22:54:46 -07:00
Commaremote f42d092505 Hyundai all output for now 2018-08-23 19:00:30 -07:00
Riccardo 7927cabcc5 compiling the use of bitbang_gmlan only for panda 2018-08-20 19:28:05 -07:00
Willem Melching 3d67294cb6 keep pedal obj folder 2018-08-20 07:33:58 -07:00
Riccardo c2a08532ca Hyundai safety: 593 also needs ot be modified 2018-08-17 23:24:32 -07:00
Riccardo 594863cea3 Hyundai: added initial safety files which just fwd bus 0 to 2 and viceversa, except for lkas msgs 2018-08-17 21:31:00 -07:00
Riccardo 905a93583a fixed pedal and legacy board builds: no float support 2018-08-14 15:55:47 -07:00
Riccardo 0a480ec20e moved interpolate function to safety header 2018-08-13 22:52:31 -07:00