Commit Graph

62 Commits

Author SHA1 Message Date
Maxime Desroches ae8ef1f71a
misra8.4: safety modes (#2029)
safety mode
2024-09-19 10:30:57 -07:00
Aryan b4442a7c93
enable misra-c2012-10.3 (#1852)
* enable misra-c2012-10.3

* fix that

* cleanup

* little more

* one more

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2024-02-18 11:56:44 -08:00
Ruben Medina 80731c0aa7
enable misra-constParameterCallback (#1827) 2024-01-20 22:22:11 -08:00
Hoang Bui 817d68f6a6
enable misra-c2012-10.4 (#1796)
* enable misrac-10.4

* changes

* cleaner
2024-01-13 15:49:56 -08:00
Shane Smiskol f741a90de8
safety: macro to update vehicle speed (#1762)
vehicle speed update macro
2023-12-06 18:05:07 -08:00
Adeeb Shihadeh 892ca5a0f1 this is a better name 2023-11-30 19:20:08 -08:00
Adeeb Shihadeh b50455cc76
safety: specify RX message frequency in Hz (#1754)
* safety: specify RX message frequency in Hz

* these are redundant now

* update that

* cleanup
2023-11-30 14:55:15 -08:00
Shane Smiskol beffd7bcbf
Nissan: check bus for brake pressed msg (#1740)
* never checked bus!

* easy fix
2023-11-26 21:07:20 -06:00
Adeeb Shihadeh 3b22bc18c6
safety: more int -> bool (#1742) 2023-11-23 16:48:08 -08:00
Adeeb Shihadeh f1cd12651c
safety: remove LIN hook (#1741)
* safety: remove LIN hook

* rm more
2023-11-23 16:30:20 -08:00
Adeeb Shihadeh 933a301cad
safety: do TX whitelist check in top level hook (#1730)
* new fields

* add check

* do first one

* first two

* all done

* fix all output

* simpler

* unused now

* fix body and elm

* fix that

* fix misra

* revert that
2023-11-20 00:15:46 -08:00
Adeeb Shihadeh b1ca493580
safety: fix ambiguous names (#1729)
renames
2023-11-19 22:44:13 -08:00
Adeeb Shihadeh 606d7580c8
safety: cleanup init return struct (#1728)
* try 1

* do the rest

* fix misra
2023-11-19 21:05:53 -08:00
Adeeb Shihadeh 3d2f99dd40
safety: move RX addr check into top level hook (#1727)
* safety: move RX addr check into top level hook

* tesla

* rest

* can't forget about the body

* rm more

* fix that

* cleanup

* drop the fn
2023-11-19 20:03:35 -08:00
Adeeb Shihadeh c6248d6504
safety: cleanup ints that are bools (#1726)
* safety: cleanup ints that are bools

* update tests
2023-11-19 16:47:09 -08:00
Shane Smiskol 7c84475410
safety: use address check helper (#1721)
use SET_ADDR_CHECKS
2023-11-16 22:36:05 -08:00
Shane Smiskol 9fd1b268b4
Nissan: consider true sign in safety (#1680)
* works

* simpler

* cmt again

* better
2023-10-03 01:50:37 -07:00
Jason Wen 39bc5a4886
Nissan Altima: add a param for alternate EPS bus (#1649)
* Nissan Altima: Specify panda flag for alt bus safety config

* test this safety mode

* test this safety mode

* rm

* nl

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
2023-09-06 00:46:33 -07:00
Shane Smiskol 0b6adad9c8
Nissan: test alternate EPS bus param (#1651)
* test this safety mode

* test this safety mode

* use int

* clean up

* clean up
2023-09-06 00:36:25 -07:00
Shane Smiskol 35609dfdce
safety utils: add ROUND helper (#1397)
* add round macro

* Update board/utils.h

* function

* one line

* misra

* use here too
2023-05-06 21:25:25 -07:00
Shane Smiskol 3a64b6ccb5
safety: make vehicle_speed a sample (#1391)
* convert vehicle_speed into sample_t, change no behavior

* draft

* round

* test

* clean up

* round

* round all

* use min

* remove round macro from this PR

* reset speed measurement

* debug

* bbd

* rm

* revert

* test above and below

* need this now

* misra pt 1

* misra pt 2

* misra pt 3

* i don't understand this one, not different from other cases

* fix test

* test

* revert that

* draft

* test the sample_t works properly for safety modes that use it (angle only)

* can combine these tests

* test decimals

* global

* misra

comment

* suggestions

* fix

* use new helper
2023-05-04 03:37:56 +00:00
Adeeb Shihadeh 7aef934d4c
Fix undefined behavior in GET_BYTES macro (#1367) 2023-04-26 22:59:58 -07:00
Adeeb Shihadeh 85cc70d4aa
safety: only pass addr to fwd hook (#1339) 2023-04-08 16:45:59 -07:00
Shane Smiskol 8bb62cf226
Ford: check quality flag (#1264)
* quality flag support

* add NULL to other safety modes

* add to safety helpers debug print

* comment

* rename to quality_flag and add comment
2023-02-24 22:54:51 -08:00
Shane Smiskol ff39bc472d
Angle control safety: match openpilot limits (#1254)
* make limits match OP

* make tesla match too

* fudge speed

* we reason

* needs to be negative
2023-02-22 20:05:33 -08:00
Shane Smiskol a99f85dc8c
Nissan: use averaged left and right wheel speeds (#1255)
* average left and right for a more accurate speed

* fix

* fix (again)
2023-02-22 19:46:07 -08:00
Shane Smiskol a6d0765b69
safety: common angle checks (#1182)
* common angle checks

* clean up

* clean up check and add comments

* readable

* ints

* tests draft

* clean up

* comment

* pylint exception

* clean up

* duplicate
2022-12-02 16:45:23 -08:00
Shane Smiskol b238d41979
safety: clean up passing in longitudinal_allowed (#1176)
* clean up

* clean up

* and fix that

* interceptor func

* fix

* draft

* fix that
2022-11-30 22:09:13 -08:00
Shane Smiskol 997e328074
Nissan: check two wheel speeds for standstill (#1124)
* safety

* use already parsed wheel speed
2022-10-31 19:40:44 -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 4a5fc24b75
safety: move controls_allowed and relay malfunction reset (#944)
* safety: reset controls allowed and relay malfunction before safety mode init

* add back for all output
2022-05-19 14:03:43 -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 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
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
Adeeb Shihadeh 499906f324
Nissan + Tesla: don't exit controls allowed on blocked message (#877)
* Nissan + Tesla: don't exit controls allowed on blocked message

* update tests
2022-03-18 14:52:52 -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
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
Adeeb Shihadeh 73bbf58567
Nissan Leaf: tests + new brake signal (#777)
* Update safety_nissan.h

Updated brake CAN address to 0x25e and brake pressed to byte logic

* Update safety_nissan.h

missed a change

* Update safety_nissan.h

* Update safety_nissan.h

* Update safety_nissan.h

Corrected Line 79 to pull from the "CRUISE THROTTLE" message at address 0x239, byte 4, bit 6, which gets us to the "USER_BRAKE_PRESSED" bit for comparison if the brake pedal is being pressed.

* Update safety_nissan.h

Removed duplicate 0x239 message in "AddrCheckStruct"

* Update safety_nissan.h

Just adding back 0x1cc to see if that fixes things?

* leaf safety tests

* clenaup

* bump openpilot

* Update tests/safety/test_nissan.py

Co-authored-by: Kirk Miller <kirk.miller92@gmail.com>
2021-11-12 11:59:49 -08:00
Adeeb Shihadeh a01ef1f7c9
safety: check relay malfunction in common TX hook (#752)
* don't check relay malfunction in car safety tx hooks

* check in safety

* fix tests
2021-10-29 11:16:27 -07:00
Adeeb Shihadeh ad36028a5b
safety: check relay malfunction outside of fwd hook (#750)
* safety: check relay malfunction outside of fwd hook

* fix tests

* move to safety
2021-10-29 10:59:05 -07:00
Willem Melching a723686fe2
Make all tx/rx LENs a define (#713) 2021-09-03 17:39:09 -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
Andre Volmensky 72d6b6de69
Nissan Altima port (#612)
* Nissan Altima port

* Added bus check for Cruise Enabled message
2020-12-11 13:41:12 +01:00
Andre Volmensky 3a8430b9d5
Updating X-Trail/Rogue gas_pressed threshold (#585) 2020-08-08 11:10:32 -07:00
Andre Volmensky 4b576ab13d
Bugfix: Fix harness error when starting car (#572)
* Bugfix: Fix harness error when starting car

* fix misra violation

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2020-07-18 23:08:21 -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
Andre Volmensky 098f47a5b4
Fix leaf brake rx check (#547) 2020-05-30 16:43:53 -07:00
Andre Volmensky bdec1398e5
Fix length of 0x20b in NISSAN_TX_MSGS, wasn't cancelling ACC (#544) 2020-05-27 12:41:19 -07:00