Skip to content

Commit

Permalink
fix tests for outside pip install (openpilot/local)
Browse files Browse the repository at this point in the history
forgot
  • Loading branch information
sshane committed Aug 17, 2024
1 parent 5d7e7fa commit e1586a6
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions opendbc/car/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from enum import IntFlag, ReprEnum, EnumType
from dataclasses import replace

from panda.python.uds import SERVICE_TYPE
from panda import uds
from opendbc.car import structs
from opendbc.car.can_definitions import CanData
from opendbc.car.docs_definitions import CarDocs
Expand Down Expand Up @@ -192,7 +192,7 @@ def get_friction(lateral_accel_error: float, lateral_accel_deadzone: float, fric


def make_tester_present_msg(addr, bus, subaddr=None, suppress_response=False):
dat = [0x02, SERVICE_TYPE.TESTER_PRESENT]
dat = [0x02, uds.SERVICE_TYPE.TESTER_PRESENT]
if subaddr is not None:
dat.insert(0, subaddr)
dat.append(0x80 if suppress_response else 0x0) # sub-function
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/chrysler/values.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import IntFlag
from dataclasses import dataclass, field

from panda.python import uds
from panda import uds
from opendbc.car import CarSpecs, DbcDict, PlatformConfig, Platforms, dbc_dict
from opendbc.car.structs import CarParams
from opendbc.car.docs_definitions import CarHarness, CarDocs, CarParts
Expand Down
6 changes: 3 additions & 3 deletions opendbc/car/ecu_addrs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time

from panda.python.uds import SERVICE_TYPE
from panda import uds
from opendbc.car import make_tester_present_msg, carlog
from opendbc.car.can_definitions import CanData, CanRecvCallable, CanSendCallable
from opendbc.car.fw_query_definitions import EcuAddrBusType
Expand All @@ -12,10 +12,10 @@ def _is_tester_present_response(msg: CanData, subaddr: int = None) -> bool:
dat_offset = 1 if subaddr is not None else 0
if len(msg.dat) == 8 and 1 <= msg.dat[dat_offset] <= 7:
# success response
if msg.dat[dat_offset + 1] == (SERVICE_TYPE.TESTER_PRESENT + 0x40):
if msg.dat[dat_offset + 1] == (uds.SERVICE_TYPE.TESTER_PRESENT + 0x40):
return True
# error response
if msg.dat[dat_offset + 1] == 0x7F and msg.dat[dat_offset + 2] == SERVICE_TYPE.TESTER_PRESENT:
if msg.dat[dat_offset + 1] == 0x7F and msg.dat[dat_offset + 2] == uds.SERVICE_TYPE.TESTER_PRESENT:
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/ford/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass, field, replace
from enum import Enum, IntFlag

import panda.python.uds as uds
from panda import uds
from opendbc.car import AngleRateLimit, CarSpecs, dbc_dict, DbcDict, PlatformConfig, Platforms
from opendbc.car.structs import CarParams
from opendbc.car.docs_definitions import CarFootnote, CarHarness, CarDocs, CarParts, Column, \
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/fw_query_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import struct
from collections.abc import Callable

import panda.python.uds as uds
from panda import uds

from opendbc.car.structs import CarParams

Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/fw_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from tqdm import tqdm

import panda.python.uds as uds
from panda import uds
from opendbc.car import carlog
from opendbc.car.can_definitions import CanRecvCallable, CanSendCallable
from opendbc.car.structs import CarParams
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/honda/values.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from enum import Enum, IntFlag

from panda.python import uds
from panda import uds
from opendbc.car import CarSpecs, PlatformConfig, Platforms, dbc_dict, structs
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.docs_definitions import CarFootnote, CarHarness, CarDocs, CarParts, Column
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/hyundai/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass, field
from enum import Enum, IntFlag

from panda.python import uds
from panda import uds
from opendbc.car import CarSpecs, DbcDict, PlatformConfig, Platforms, dbc_dict
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.structs import CarParams
Expand Down
10 changes: 5 additions & 5 deletions opendbc/car/isotp_parallel_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from opendbc.car import carlog
from opendbc.car.can_definitions import CanData, CanRecvCallable, CanSendCallable
from opendbc.car.fw_query_definitions import AddrType
from panda.python.uds import CanClient, IsoTpMessage, FUNCTIONAL_ADDRS, get_rx_addr_for_tx_addr
from panda import uds


class IsoTpParallelQuery:
Expand All @@ -23,9 +23,9 @@ def __init__(self, can_send: CanSendCallable, can_recv: CanRecvCallable, bus: in

real_addrs = [a if isinstance(a, tuple) else (a, None) for a in addrs]
for tx_addr, _ in real_addrs:
assert tx_addr not in FUNCTIONAL_ADDRS, f"Functional address should be defined in functional_addrs: {hex(tx_addr)}"
assert tx_addr not in uds.FUNCTIONAL_ADDRS, f"Functional address should be defined in functional_addrs: {hex(tx_addr)}"

self.msg_addrs = {tx_addr: get_rx_addr_for_tx_addr(tx_addr[0], rx_offset=response_offset) for tx_addr in real_addrs}
self.msg_addrs = {tx_addr: uds.get_rx_addr_for_tx_addr(tx_addr[0], rx_offset=response_offset) for tx_addr in real_addrs}
self.msg_buffer: dict[int, list[CanData]] = defaultdict(list)

def rx(self) -> None:
Expand Down Expand Up @@ -66,14 +66,14 @@ def _drain_rx(self) -> None:
self.msg_buffer = defaultdict(list)

def _create_isotp_msg(self, tx_addr: int, sub_addr: int | None, rx_addr: int):
can_client = CanClient(self._can_tx, partial(self._can_rx, rx_addr, sub_addr=sub_addr), tx_addr, rx_addr,
can_client = uds.CanClient(self._can_tx, partial(self._can_rx, rx_addr, sub_addr=sub_addr), tx_addr, rx_addr,
self.bus, sub_addr=sub_addr, debug=self.debug)

max_len = 8 if sub_addr is None else 7
# uses iso-tp frame separation time of 10 ms
# TODO: use single_frame_mode so ECUs can send as fast as they want,
# as well as reduces chances we process messages from previous queries
return IsoTpMessage(can_client, timeout=0, separation_time=0.01, debug=self.debug, max_len=max_len)
return uds.IsoTpMessage(can_client, timeout=0, separation_time=0.01, debug=self.debug, max_len=max_len)

def get_data(self, timeout: float, total_timeout: float = 60.) -> dict[AddrType, bytes]:
self._drain_rx()
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/nissan/values.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, field

from panda.python import uds
from panda import uds
from opendbc.car import AngleRateLimit, CarSpecs, DbcDict, PlatformConfig, Platforms, dbc_dict
from opendbc.car.structs import CarParams
from opendbc.car.docs_definitions import CarDocs, CarHarness, CarParts
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/subaru/values.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass, field
from enum import Enum, IntFlag

from panda.python import uds
from panda import uds
from opendbc.car import CarSpecs, DbcDict, PlatformConfig, Platforms, dbc_dict
from opendbc.car.structs import CarParams
from opendbc.car.docs_definitions import CarFootnote, CarHarness, CarDocs, CarParts, Tool, Column
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/toyota/interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from panda import Panda
from panda.python import uds
from panda import uds
from opendbc.car import structs, get_safety_config
from opendbc.car.toyota.values import Ecu, CAR, DBC, ToyotaFlags, CarControllerParams, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, \
MIN_ACC_SPEED, EPS_SCALE, UNSUPPORTED_DSU_CAR, NO_STOP_TIMER_CAR, ANGLE_CONTROL_CAR
Expand Down
8 changes: 4 additions & 4 deletions opendbc/car/vin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

from panda.python.uds import get_rx_addr_for_tx_addr, FUNCTIONAL_ADDRS
from panda import uds
from opendbc.car import carlog
from opendbc.car.isotp_parallel_query import IsoTpParallelQuery
from opendbc.car.fw_query_definitions import STANDARD_VIN_ADDRS, StdQueries
Expand All @@ -17,8 +17,8 @@ def get_vin(can_recv, can_send, buses, timeout=0.1, retry=2, debug=False):
for i in range(retry):
for bus in buses:
for request, response, valid_buses, vin_addrs, functional_addrs, rx_offset in (
(StdQueries.UDS_VIN_REQUEST, StdQueries.UDS_VIN_RESPONSE, (0, 1), STANDARD_VIN_ADDRS, FUNCTIONAL_ADDRS, 0x8),
(StdQueries.OBD_VIN_REQUEST, StdQueries.OBD_VIN_RESPONSE, (0, 1), STANDARD_VIN_ADDRS, FUNCTIONAL_ADDRS, 0x8),
(StdQueries.UDS_VIN_REQUEST, StdQueries.UDS_VIN_RESPONSE, (0, 1), STANDARD_VIN_ADDRS, uds.FUNCTIONAL_ADDRS, 0x8),
(StdQueries.OBD_VIN_REQUEST, StdQueries.OBD_VIN_RESPONSE, (0, 1), STANDARD_VIN_ADDRS, uds.FUNCTIONAL_ADDRS, 0x8),
(StdQueries.GM_VIN_REQUEST, StdQueries.GM_VIN_RESPONSE, (0,), [0x24b], None, 0x400), # Bolt fwdCamera
(StdQueries.KWP_VIN_REQUEST, StdQueries.KWP_VIN_RESPONSE, (0,), [0x797], None, 0x3), # Nissan Leaf VCM
(StdQueries.UDS_VIN_REQUEST, StdQueries.UDS_VIN_RESPONSE, (0,), [0x74f], None, 0x6a), # Volkswagen fwdCamera
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_vin(can_recv, can_send, buses, timeout=0.1, retry=2, debug=False):
vin = vin[1:18]

carlog.error(f"got vin with {request=}")
return get_rx_addr_for_tx_addr(addr, rx_offset=rx_offset), bus, vin.decode()
return uds.get_rx_addr_for_tx_addr(addr, rx_offset=rx_offset), bus, vin.decode()
except Exception:
carlog.exception("VIN query exception")

Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/volkswagen/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass, field
from enum import Enum, IntFlag, StrEnum

from panda.python import uds
from panda import uds
from opendbc.can.can_define import CANDefine
from opendbc.car import dbc_dict, CarSpecs, DbcDict, PlatformConfig, Platforms
from opendbc.car.common.conversions import Conversions as CV
Expand Down

0 comments on commit e1586a6

Please sign in to comment.