Commit Graph

59 Commits

Author SHA1 Message Date
DevTekVE
4c2ccd7fe5 Modular Assistive Driving System (MADS) (#40)
* alternative experience

* safety init

* fix

* more update

* not really

* misra

* Add Custom MIT License (#38)

* brake check was not handled

* revert

* alt -> lkas

* explicit checks

* support toyota and ford

* rename

* hyundai can-fd support

* only allow lkas if enabled

* hyundai: main button handling

* revert

* hyundai: main button heartbeat

* add logging for controls allowed lateral

* fix panda safety

* ford btn

* toyota btn

* fca btn

* honda btn

* mads safety tests

* more tests

* safety misra

* safety mutation

* misra

* mutation experiment

* fix

* ford test main button

* ford test lkas button

* more ford test

* hyundai lkas and main

* more ford

* hyundai canfd

* rename

* rename

* cleaner

* more fixes

* more hyundai tests

* no longer needed

* thanks for tests!

* more tests for lat

* more explicit

* make sure to reset

* try this out

* probably needed

* move

* misra

* not needed

* move to safety_mads

* not really needed

* remove

* MADS: Refactor MADS safety with improved state management (pull request #46)

Refactor MADS safety with improved state management

This commit introduces a major refactoring of the MADS safety module, improving state management and control flow. Key changes include:

Core Changes:
- Introduced a MADSState struct to centralize state management
- Removed global state variables in favor of structured state
- Implemented button transition handling with explicit state tracking (PRESSED/RELEASED/NO_CHANGE)
- Added state flags for button availability detection
- Simplified lateral control permission logic

Button Handling:
- Separated main button and LKAS button state tracking
- Added independent engagement states for each button
- Improved button press detection across multiple platforms
- Added support for main and LKAS buttons on Hyundai platforms
- Modified ACC main state handling

Testing:
- Added comprehensive test coverage for MADS state transitions
- Added new MADS-specific test base class for consistent testing across platforms
- Added mutation testing for state management
- Extended timeout for mutation tests from 5 to 8 minutes
- Added extensive button press validation tests
- Enhanced debugging output in replay drive tests

The refactored code provides a more organized implementation of MADS safety features while maintaining compatibility with existing safety checks.

* adding note

* adding ford (WIP)

* adding honda (WIP)

* adding toyota (WIP)

* adding chrysler (WIP)

* Standardize Button State Handling Across Platforms

Refactor button state handling by replacing integer constants with an enumerated `ButtonState` type and updating logic to improve readability and maintainability. This change affects button press detection in Ford, Honda, Hyundai, and Toyota safety modules and aligns them with a unified MADS button state approach. Enums provide a clearer understanding of button states and transitions, facilitating easier maintenance and future enhancements.

* Disable LKAS button press logic in Honda and Toyota safety.

The code for processing LKAS button presses has been commented out in both Honda and Toyota safety implementations. This change aims to investigate or temporarily halt the button press effects without removing the logic altogether. It will be important to test for any impacts this may have on vehicle control functionality.

* Remove commented out code in toyota_rx_hook function

This commit cleans up the toyota_rx_hook function by removing unnecessary commented-out code that checks for LKAS button presses on bus 2. This helps improve code readability and maintainability without altering the existing functionality.

* GM, mazda, nissan, subaru (global & preglobal)

* Honda LKAS

* Revert "Remove commented out code in toyota_rx_hook function"

This reverts commit d6b012c01a08118d91fad56c9f6ac2f92b671968.

* Toyota, Subaru Global LKAS

* nissan fix

* gm fix

* use speed msg to force rx

* im bored

* misra

* subaru/toyota/honda

* nope

* attempt

* go through all buttons

* try nissan

* more nissan

* nissan tests passed!

* subaru lkas test (not sure why it's not passing 2 and 3 values)

* Improved code organization in safety_subaru.h and test_subaru.py

This commit includes a minor restructuring in safety_subaru.h and test_subaru.py for better readability and flow. The condition check in safety_subaru.h for lkas_hud now has explicit parentheses. With regard to test_subaru.py, an unnecessary import was removed, and the sequence of steps in the test was reordered - now enabling mads and cleaning up mads_states happens before each subtest.

* Refactor tests to use _speed_msg instead of _user_brake_msg.

Updated the MADS safety tests to utilize the _speed_msg(0) function call in place of _user_brake_msg(False).

* Reworking the tests a little for clarity

* disabling lkas again on toyota temporarily

* fix mads condition to engage

* hyundai and honda good with new tests

* Redoing more tests

* update for safety tick ensuring mads control is exited while lagging

* Updating tests for toyota

* cleaning up tests on hkg

* commenting out temp_debug for future use

* revert

* constants

* cleanup

* format!

* match yota

* Apply suggestions from code review

* force

* explicit checks

* revert

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
2024-12-05 19:39:36 -05:00
Jason Wen
0399659922 Merge branch 'upstream/master' into sync-20241205 2024-12-05 13:48:19 -05:00
Maxime Desroches
b770745342 ci: split MISRA linter and MISRA mutation (#2086)
* sep

* this
2024-11-21 11:48:02 -08:00
DevTekVE
36c5e06ec9 initial attempt at adjusting tests 2024-11-19 20:25:10 +01:00
Robbe Derks
a67f3650c8 Increase MISRA to 2min max (#2079)
increase to 2min max
2024-11-14 11:28:28 +01:00
Maxime Desroches
9aec4294cc ci: test building in release mode (#2062)
* build

* space

* better
2024-10-18 14:10:54 -07:00
Maxime Desroches
78b49ab155 safety mutation tests (#2040)
* mutation

* clone

* origin

* get diff

* better example

* better

* fix docker

* work on push

* make test fail

* real change

* test all modes

* ignore

* better

* reco

* fix

* no libpanda on device

* curl

* nl

* nl again

* delete

* clean

* clean

* this

* add this back

* cleanup
2024-09-25 21:56:09 -07:00
dzid26
fcccbb3a13 revert shorter MISRA mutation CI timeout
- test_misra.sh only got faster locally
2024-09-07 19:57:19 -07:00
Radek
2aaab40117 fix test_mutation.py performace (#2012)
stop pytest from executing test_misra.sh in test collections
- in each test_mutation.py worker
2024-09-06 13:30:05 -07:00
Adeeb Shihadeh
c4e75ee89c remove cereal dependence (#2000)
* remove cereal

* rm more shit

* add back make

* python3

* python3

* fix that

* put that back

* rename

* fix that

* can't move it
2024-08-18 11:40:54 -07:00
Adeeb Shihadeh
53e0f13739 update to ubuntu 24.04 (#1941)
* update to ubuntu 24.04

* Apply suggestions from code review

* Update .github/workflows/repo.yml

* Update test.yaml

* docker builds

* bump

* no pyenv

* ugh this should just be removed

* fix

* add release/

* no openpilot

* remove those too

* build in the docker

* cleanup

* need the addons
2024-04-28 15:32:18 -07:00
Justin Newberry
698d17e021 fix inconsistent misra mutation tests (#1935)
* revert

* fix
2024-04-22 10:28:53 -07:00
Justin Newberry
4d60ae9c62 CI: fix misra mutation tests (#1934)
* fix that

* skip build, install first

* Revert "skip build, install first"

This reverts commit 01efdb77ce3d834b55bbed1172ca83bb0103bfc8.

* prune
2024-04-18 17:59:33 -07:00
Adeeb Shihadeh
c076a9f2f6 remove pedal fw (#1872)
* remove pedal fw

* little more

* one more

* and tests

* rest of it

* little more

* fix linter

* more fix
2024-02-16 22:58:01 -08:00
Shane Smiskol
aca33b83a4 tests: one file for safety and coverage tests (#1865)
* one file for all tests

* clean up

* unreachable

* Revert "unreachable"

This reverts commit 4b792b1f9b5290b57975d21c24be5029be16b0e3.
2024-02-13 17:27:19 -08:00
Aryan
54459e694e update cppcheck (#1859)
* update cppcheck

* Update tests/misra/install.sh

* delete cppcheck cache

* remove misra 5.8 erroors

* fixed uninitialized data error

* suppress misra-c2012-2.3 and misra-c2012-2.4

* reinstate cache to fix mutation test

* rerun for mutation test

* increase timeout for mutation test

* styling

* comments + variable name changes

* Update tests/misra/install.sh

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

* Update install.sh

* more variable name changes

* condition on defining CANPacket_t

* just cherry pick

* fix build

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2024-02-10 14:50:36 -08:00
Hoang Bui
ced1fb3dee Add more MISRA mutation tests (#1818)
* 9 added tests

* test speed with new del header

* mypy

* cleanup

* fix error in delete

* random

* change

* works on local

* sorted

* with order

* add pytest randomly

* test with ci

* remove sort

* cleanup

* all files

* no obj

* another bootstub

* fix

* cleanup

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2024-01-20 15:52:38 -08:00
Adeeb Shihadeh
12d326c110 parallelize misra mutation tests (#1768)
* parallelize misra mutation tests

* timeouts
2023-12-09 14:32:40 -08:00
Adeeb Shihadeh
7340ece196 misra mutation test (#1763)
* misra mutation test

* a few cases

* revert that

* fixups

* test that

* build fw
2023-12-08 23:20:42 -08:00
Shane Smiskol
5fe1d67b77 safety: test coverage (#1699)
* run in CI

* test

* make report optional

* 100% GM coverage

comments

* more coverage: these are unhittable lines

* vw mqb: convert switch to if, consistent with all other safety modes

* we don't check any of these yet

* rm

* ensure honda_fwd_brake is reset

* can rm this

* test honda brake latching

* honda: add rx brake function

* use loops for more coverage and more compact code

* other honda stuff

* remove car-specific stuff from init_tests

* don't need to have car safety modes reset interceptor detected (global init does)

* use get_bit

* ahh ford counter is unhittable: counter check disabled due to skipping

* misra

* test nooutput and alloutput

* required changes for that

* fix test

* more all/nooutput coverage

* start on lin

* rx coverage

* lin tx coverage

* some barebones body test

* double negative

* draft elm327 safety (git stash)

* fixes from merge

* clean up test cov

* add rm

* no body

* failed grep returns exit code 1

* more clear msgs
2023-11-10 19:37:41 -08:00
Adeeb Shihadeh
b6e37f25b6 Remove flash logging (#1674)
* Revert "Disable flash logging (#1667)"

This reverts commit 62db60595b.

* Revert "Faster log retrieval (#1484)"

This reverts commit 694aae9c26.

* Revert "Flash bounds checking outside of bootstub (#1459)"

This reverts commit 054344de6b.

* Revert "Logging (#1445)"

This reverts commit 0cc91a7f7b.

* cleanup

* cleanup
2023-09-30 12:49:46 -07:00
Adeeb Shihadeh
ee21517c77 CI: run each job only once (#1659) 2023-09-07 19:10:05 -07:00
Adeeb Shihadeh
9df7802f71 CI: bump up safety test timeout 2023-08-10 16:36:00 -07:00
Adeeb Shihadeh
61e987f6e2 remove safety replay test (#1569) 2023-08-07 18:38:01 -07:00
Adeeb Shihadeh
43bde4138d jungle: SBU provisioning tests (#1553)
* jungle: SBU provisioning tests

* update can_send

* cleanup

* fix misra

* space
2023-08-04 14:28:23 -07:00
Robbe Derks
0cc91a7f7b Logging (#1445)
* try 1

* some fixes

* fix some misra

* first poc working

* more things

* more misra fixes

* fix misra

* add rate limiting

* fix misra

* add some unit tests through libpanda

* add more tests and fix some stuff

* fix misra again

* add startup log hitl test

* list

* don't fail on wrong timestamps

* improvements

* fix tests

* expected logs test?

* not sure why this passed

* oh, it doesn't reset

* only show last few

* guess at expected logs

* needs this

* ugh

* reduce compiler warnings

* adjust expected logs

* this is correct

* is it really 1?

* min max

* reduce spam in SPI test

* some cleanup
2023-06-13 17:00:56 +02:00
Adeeb Shihadeh
a8f851870d ci: bump up safety test timeout 2023-05-21 20:31:01 -07:00
Adeeb Shihadeh
1e8c5d59c7 CI: run tests with UBSan (#1363)
* CI: run tests with UBSan

* try this
2023-04-26 23:15:28 -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
ba7d21805a ci: lower safety test timeout 2023-03-21 18:49:47 -07: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
1f73c70fdc generic libpanda for tests (#1177)
* generic libpanda for tests

* move safety helpers

* fix ci build

* fix running

* opendbc is in the image

* make can packet

* rename
2022-11-30 17:41:24 -08:00
Adeeb Shihadeh
b19a74f93d CI: fix mounting in GITHUB_WORKSPACE (#1175) 2022-11-30 15:56:15 -08:00
Shane Smiskol
702e5281d8 remove unused scons argument (#1169)
* clean

* also here
2022-11-29 01:28:46 -08:00
Robbe Derks
d574f4aebc STM32F4: SPI communications (#998)
* cleanup is_enumerated, rename comms and init spi

* big comms refactor, building now

* misra fixes

* more fixes

* misra try 3

* cleanup

* this belongs in a separate PR

* remove unneccesary file

* revert llspi changes

* llspi misra fix

* enable SPI on F4 and setup gpio

* duh

* wip: spi comms

* more spi wip

* dynamic sector erasing

* Revert "dynamic sector erasing"

This reverts commit fce1215a2ede45e5e2a0e97ca23a86c1d8bfa94a.

* more sectors to be erased

* debugging

* woah, this works

* cleanup on the panda side

* add sync and checksum checks, and fix recovery on errors

* this seems relatively stable

* add retrying

* this is stabler

* some endianness and endpoint fixes

* builds

* revert that

* add that back

* checksum start

* start splitting up driver

* spi behind flag

* cleanup test

* bump up timeout

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-11-09 18:46:20 -08:00
Adeeb Shihadeh
b3e9292922 HITL test fixups (#1117)
* automated -> hitl

* simplify

* jenkinsfile cleanup

* cleanup

* fix new linter errors

* fix ws cleanup

* some retry

* more cleaning up after ourselves

* unpin scons

* bump opendbc

* fix quotes

* enable flaky

* debug print

Co-authored-by: Bruce Wayne <batman@comma.ai>
2022-11-03 17:24:28 -07:00
Adeeb Shihadeh
bce6f48a9d CI speedup (#1108)
* use docker buildkit

* enable push

* try this caching

* no regressions

* don't copy into the image

* move that

* getting there

* debug

* little smaller

* debug

* configure safe dir

* no sudo

* cleanup

* another timeout
2022-10-16 16:37:58 -07:00
Adeeb Shihadeh
b27e1476a7 CI: update docker login 2022-08-03 21:17:47 -07:00
Adeeb Shihadeh
b6a672de5a bump openpilot (#946)
* bump openpilot

* need that too :(
2022-05-19 14:30:08 -07: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
0cc5ec33e4 fix build apth 2021-10-25 16:14:24 -07:00
Adeeb Shihadeh
def8558e3d fix safety replay 2021-10-25 16:08:49 -07:00
martinl
92f6a9bb1d Misra artifacts upload (#731)
* Update misra artifact upload workflow

* Update misra artifact upload filenames
2021-09-30 21:47:14 +02:00
Adeeb Shihadeh
3cf5b473c8 CI fixups (#657) 2021-06-09 18:36:07 -07:00
Willem Melching
ad9ecefe65 Switch panda to scons builder (#635)
* add scons builder

* cleanup 1

* remove building from python code

* add pedal build

* fixup flags

* add EON flag

* change github actions to scons

* fixup automated tests

* move flashing scripts

* fix indent

* remove version.mk

* fix not in git

* fix linker script filename

* untested pedal flashing scripts

* add release option

* better asserts

* swap condition

* enable usb and fix flash script

* usb flash is not supported

* use button to enable dfu mode

* no usb because misra

* remove sleep
2021-03-24 14:44:32 +01:00
Jason Young
9108b82fb0 VW MQB: Updated message and signal data, round 1 (#632)
* EPS_01 -> LH_EPS_03

* Bump openpilot commit ref

* made echo test more stable

* update python to 3.8.5

* Revert "Bump openpilot commit ref"

This reverts commit 75ec1a0c

* Bump openpilot commit ref

* Bump openpilot commit ref

* Update Dockerfile.panda

* fixed torque signal name

* Signal naming fix, round 2

* fix CI

Co-authored-by: Robbe Derks <robbe.derks@gmail.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2021-03-14 16:24:53 -07:00
Adeeb Shihadeh
49c7615ed3 ubuntu 16.04 -> 20.04 (#608)
* ubuntu 16.04 -> 20.04

* fix pip

* think pyenv installs this

* bump python

* non interactive

* fix pyenv install

* python serial

* bump cffi

* fix index log build

* logreader dependency
2020-10-23 23:14:58 -07:00
Adeeb Shihadeh
8b41ed3b81 Deprecate ESP (#592)
* remove unused wifi tests

* remove that one too

* no bootmode from ESP

* clean that up

* remove two more wifi tests

* remove boardesp and esptool

* esp_gps -> gps

* missed those

* remove esptool refs

* remove esp certs

* no more wifi

* that was old

* cleanup jenkins dockerfile

* fix linter

* remove more wifi refs

* clone panda jungle from github

* no copy

* always default esp to off
2020-08-26 15:37:50 -07:00
Adeeb Shihadeh
6ae6221cf2 add driver build status to README 2020-08-22 19:21:11 -07:00
Adeeb Shihadeh
abeafb6256 fix linter 2020-06-11 17:06:53 -07:00