Skip to content

Commit 8f99d2b

Browse files
Merge commit '084a40a46fb5658d36344de66c2effcd88d3f2c6'
2 parents 0cce949 + 084a40a commit 8f99d2b

31 files changed

+113
-106
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN pip3 install --break-system-packages --no-cache-dir $PYTHONPATH/panda/[dev]
3737

3838
# TODO: this should be a "pip install" or not even in this repo at all
3939
RUN git config --global --add safe.directory $PYTHONPATH/panda
40-
ENV OPENDBC_REF="6f83fdf9b9a26e2f20e58aed5623137ca2f61d3c"
40+
ENV OPENDBC_REF="da0a5e3d2b3984b56ebf5e25d9769f5c77807e4d"
4141
RUN cd /tmp/ && \
4242
git clone --depth 1 https://github.com/commaai/opendbc opendbc_repo && \
4343
cd opendbc_repo && git fetch origin $OPENDBC_REF && git checkout FETCH_HEAD && rm -rf .git/ && \

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ For example, to receive CAN messages:
7575
```
7676
And to send one on bus 0:
7777
``` python
78-
>>> from opendbc.safety import Safety
79-
>>> panda.set_safety_mode(Safety.SAFETY_ALLOUTPUT)
78+
>>> from opendbc.car.structs import CarParams
79+
>>> panda.set_safety_mode(CarParams.SafetyModel.allOutput)
8080
>>> panda.can_send(0x1aa, b'message', 0)
8181
```
8282
Note that you may have to setup [udev rules](https://github.com/commaai/panda/tree/master/drivers/linux) for Linux, such as

board/drivers/can_common.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ void ignition_can_hook(CANPacket_t *to_push) {
173173
ignition_can_cnt = 0U;
174174
}
175175

176+
// Rivian R1S/T GEN1 exception
177+
if ((addr == 0x152) && (len == 8)) {
178+
// VDM_OutputSignals
179+
ignition_can = GET_BIT(to_push, 60U);
180+
ignition_can_cnt = 0U;
181+
}
182+
176183
// Tesla Model 3/Y exception
177184
if ((addr == 0x221) && (len == 8)) {
178185
// VCFRONT_LVPowerState->VCFRONT_vehiclePowerState

board/jungle/scripts/loopback_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import random
66
from termcolor import cprint
77

8-
from opendbc.safety import Safety
8+
from opendbc.car.structs import CarParams
99
from panda import Panda, PandaJungle
1010

1111
NUM_PANDAS_PER_TEST = 1
@@ -89,7 +89,7 @@ def can_loopback(sender):
8989
def test_loopback():
9090
# disable safety modes
9191
for panda in pandas:
92-
panda.set_safety_mode(Safety.SAFETY_ELM327 if FOR_RELEASE_BUILDS else Safety.SAFETY_ALLOUTPUT)
92+
panda.set_safety_mode(CarParams.SafetyModel.elm327 if FOR_RELEASE_BUILDS else CarParams.SafetyModel.allOutput)
9393

9494
# perform loopback with jungle as a sender
9595
can_loopback(jungle)
@@ -100,7 +100,7 @@ def test_loopback():
100100

101101
# enable safety modes
102102
for panda in pandas:
103-
panda.set_safety_mode(Safety.SAFETY_SILENT)
103+
panda.set_safety_mode(CarParams.SafetyModel.silent)
104104

105105
#################################################################
106106
############################# MAIN ##############################

board/jungle/scripts/spam_can.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
import os
33
import random
4-
from opendbc.safety import Safety
4+
from opendbc.car.structs import CarParams
55
from panda import PandaJungle
66

77
def get_test_string():
@@ -10,7 +10,7 @@ def get_test_string():
1010
if __name__ == "__main__":
1111
p = PandaJungle()
1212

13-
p.set_safety_mode(Safety.SAFETY_ALLOUTPUT)
13+
p.set_safety_mode(CarParams.SafetyModel.allOutput)
1414

1515
print("Spamming all buses...")
1616
while True:

examples/query_fw_versions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from opendbc.car.carlog import carlog
55
from opendbc.car.uds import UdsClient, MessageTimeoutError, NegativeResponseError, InvalidSubAddressError, \
66
SESSION_TYPE, DATA_IDENTIFIER_TYPE
7-
from opendbc.safety import Safety
7+
from opendbc.car.structs import CarParams
88
from panda import Panda
99

1010
if __name__ == "__main__":
@@ -64,7 +64,7 @@
6464
exit()
6565

6666
panda = Panda(serial=args.serial)
67-
panda.set_safety_mode(Safety.SAFETY_ELM327, 1 if args.no_obd else 0)
67+
panda.set_safety_mode(CarParams.SafetyModel.elm327, 1 if args.no_obd else 0)
6868
print("querying addresses ...")
6969
with tqdm(addrs) as t:
7070
for addr in t:

examples/query_vin_and_stats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
import time
33
import struct
4-
from opendbc.safety import Safety
4+
from opendbc.car.structs import CarParams
55
from panda import Panda
66
from hexdump import hexdump
77
from panda.python.isotp import isotp_send, isotp_recv
@@ -31,7 +31,7 @@ def get_supported_pids():
3131

3232
if __name__ == "__main__":
3333
panda = Panda()
34-
panda.set_safety_mode(Safety.SAFETY_ELM327)
34+
panda.set_safety_mode(CarParams.SafetyModel.elm327)
3535
panda.can_clear(0)
3636

3737
# 09 02 = Get VIN

examples/tesla_tester.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22

33
import binascii
4-
from opendbc.safety import Safety
4+
from opendbc.car.structs import CarParams
55
from panda import Panda
66

77
def tesla_tester():
@@ -14,7 +14,7 @@ def tesla_tester():
1414
# Now set the panda from its default of SAFETY_SILENT (read only) to SAFETY_ALLOUTPUT
1515
# Careful, as this will let us send any CAN messages we want (which could be very bad!)
1616
print("Setting Panda to output mode...")
17-
p.set_safety_mode(Safety.SAFETY_ALLOUTPUT)
17+
p.set_safety_mode(CarParams.SafetyModel.allOutput)
1818

1919
# BDY 0x248 is the MCU_commands message, which includes folding mirrors, opening the trunk, frunk, setting the cars lock state and more.
2020
# For our test, we will edit the 3rd byte, which is MCU_lockRequest. 0x01 will lock, 0x02 will unlock:
@@ -27,7 +27,7 @@ def tesla_tester():
2727

2828
#Back to safety...
2929
print("Disabling output on Panda...")
30-
p.set_safety_mode(Safety.SAFETY_SILENT)
30+
p.set_safety_mode(CarParams.SafetyModel.silent)
3131

3232
print("Reading VIN from 0x568. This is painfully slow and can take up to 3 minutes (1 minute per message; 3 messages needed for full VIN)...")
3333

python/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from functools import wraps, partial
1010
from itertools import accumulate
1111

12-
from opendbc.safety import Safety
12+
from opendbc.car.structs import CarParams
1313

1414
from .base import BaseHandle
1515
from .constants import FW_PATH, McuType
@@ -714,7 +714,7 @@ def get_interrupt_call_rate(self, irqnum):
714714
def set_power_save(self, power_save_enabled=0):
715715
self._handle.controlWrite(Panda.REQUEST_OUT, 0xe7, int(power_save_enabled), 0, b'')
716716

717-
def set_safety_mode(self, mode=Safety.SAFETY_SILENT, param=0):
717+
def set_safety_mode(self, mode=CarParams.SafetyModel.silent, param=0):
718718
self._handle.controlWrite(Panda.REQUEST_OUT, 0xdc, mode, param, b'')
719719

720720
def set_obd(self, obd):

tests/black_white_loopback_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import time
1010
import random
1111
import argparse
12-
from opendbc.safety import Safety
12+
from opendbc.car.structs import CarParams
1313
from panda import Panda
1414

1515
def get_test_string():
@@ -48,8 +48,8 @@ def run_test(sleep_duration):
4848
raise Exception("Connect white/grey and black panda to run this test!")
4949

5050
# disable safety modes
51-
black_panda.set_safety_mode(Safety.SAFETY_ALLOUTPUT)
52-
other_panda.set_safety_mode(Safety.SAFETY_ALLOUTPUT)
51+
black_panda.set_safety_mode(CarParams.SafetyModel.allOutput)
52+
other_panda.set_safety_mode(CarParams.SafetyModel.allOutput)
5353

5454
# test health packet
5555
print("black panda health", black_panda.health())
@@ -63,9 +63,9 @@ def run_test(sleep_duration):
6363
print("Number of cycles:", counter, "Non-zero bus errors:", nonzero_bus_errors, "Zero bus errors:", zero_bus_errors, "Content errors:", content_errors)
6464

6565
# Toggle relay
66-
black_panda.set_safety_mode(Safety.SAFETY_SILENT)
66+
black_panda.set_safety_mode(CarParams.SafetyModel.silent)
6767
time.sleep(1)
68-
black_panda.set_safety_mode(Safety.SAFETY_ALLOUTPUT)
68+
black_panda.set_safety_mode(CarParams.SafetyModel.allOutput)
6969
time.sleep(1)
7070

7171

0 commit comments

Comments
 (0)