deprecate busTime (#33146)

* deprecate busTime

* bump

* do car can + more

* forgot some

* bump opendbc

* fix that too

* bump
This commit is contained in:
Shane Smiskol 2024-07-30 21:26:58 -07:00 committed by GitHub
parent b6d124d268
commit 42f2601416
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 25 additions and 32 deletions

View File

@ -336,9 +336,9 @@ enum LaneChangeDirection {
struct CanData {
address @0 :UInt32;
busTime @1 :UInt16;
dat @2 :Data;
src @3 :UInt8;
busTimeDEPRECATED @1 :UInt16;
}
struct DeviceState @0xa4d8b5af2aa492eb {

@ -1 +1 @@
Subproject commit cff2af8ff8690466109f56be62129ebfb85cd5dc
Subproject commit 8e9d3688412405154a8189c421cfdc9d5feea715

2
panda

@ -1 +1 @@
Subproject commit f6375848ca393a9483921665b6a2d131d7ec9b20
Subproject commit 8c3bb0151e8907ade344ccb293d58cd543e28baa

View File

@ -189,7 +189,7 @@ def get_friction(lateral_accel_error: float, lateral_accel_deadzone: float, fric
def make_can_msg(addr, dat, bus):
return [addr, 0, dat, bus]
return [addr, dat, bus]
def make_tester_present_msg(addr, bus, subaddr=None, suppress_response=False):

View File

@ -112,7 +112,7 @@ def create_lat_ctl2_msg(packer, CAN: CanBus, mode: int, path_offset: float, path
}
# calculate checksum
dat = packer.make_can_msg("LateralMotionControl2", 0, values)[2]
dat = packer.make_can_msg("LateralMotionControl2", 0, values)[1]
values["LatCtlPath_No_Cs"] = calculate_lat_ctl2_checksum(mode, counter, dat)
return packer.make_can_msg("LateralMotionControl2", CAN.main, values)

View File

@ -64,7 +64,7 @@ def create_gas_regen_command(packer, bus, throttle, idx, enabled, at_full_stop):
"GasRegenAlwaysOne3": 1,
}
dat = packer.make_can_msg("ASCMGasRegenCmd", bus, values)[2]
dat = packer.make_can_msg("ASCMGasRegenCmd", bus, values)[1]
values["GasRegenChecksum"] = (((0xff - dat[1]) & 0xff) << 16) | \
(((0xff - dat[2]) & 0xff) << 8) | \
((0x100 - dat[3] - idx) & 0xff)

View File

@ -77,7 +77,7 @@ def create_lkas11(packer, frame, CP, apply_steer, steer_req,
# Genesis and Optima fault when forwarding while engaged
values["CF_Lkas_LdwsActivemode"] = 2
dat = packer.make_can_msg("LKAS11", 0, values)[2]
dat = packer.make_can_msg("LKAS11", 0, values)[1]
if CP.flags & HyundaiFlags.CHECKSUM_CRC8:
# CRC Checksum as seen on 2019 Hyundai Santa Fe
@ -156,7 +156,7 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, se
scc12_values["CF_VSM_ConfMode"] = 1
scc12_values["AEB_Status"] = 1 # AEB disabled
scc12_dat = packer.make_can_msg("SCC12", 0, scc12_values)[2]
scc12_dat = packer.make_can_msg("SCC12", 0, scc12_values)[1]
scc12_values["CR_VSM_ChkSum"] = 0x10 - sum(sum(divmod(i, 16)) for i in scc12_dat) % 0x10
commands.append(packer.make_can_msg("SCC12", 0, scc12_values))
@ -181,7 +181,7 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, se
"FCA_DrvSetStatus": 1,
"FCA_Status": 1, # AEB disabled
}
fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2]
fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[1]
fca11_values["CR_FCA_ChkSum"] = hyundai_checksum(fca11_dat[:7])
commands.append(packer.make_can_msg("FCA11", 0, fca11_values))

View File

@ -27,7 +27,7 @@ class IsoTpParallelQuery:
assert tx_addr not in 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_buffer: dict[int, list[tuple[int, int, bytes, int]]] = defaultdict(list)
self.msg_buffer: dict[int, list[tuple[int, bytes, int]]] = defaultdict(list)
def rx(self):
"""Drain can socket and sort messages into buffers based on address"""
@ -36,11 +36,11 @@ class IsoTpParallelQuery:
for packet in can_packets:
for msg in packet.can:
if msg.src == self.bus and msg.address in self.msg_addrs.values():
self.msg_buffer[msg.address].append((msg.address, msg.busTime, msg.dat, msg.src))
self.msg_buffer[msg.address].append((msg.address, msg.dat, msg.src))
def _can_tx(self, tx_addr, dat, bus):
"""Helper function to send single message"""
msg = [tx_addr, 0, dat, bus]
msg = [tx_addr, dat, bus]
self.sendcan.send(can_list_to_can_capnp([msg], msgtype='sendcan'))
def _can_rx(self, addr, sub_addr=None):
@ -53,7 +53,7 @@ class IsoTpParallelQuery:
# Filter based on subadress
msgs = []
for m in self.msg_buffer[addr]:
first_byte = m[2][0]
first_byte = m[1][0]
if first_byte == sub_addr:
msgs.append(m)
else:

View File

@ -15,7 +15,7 @@ def create_steering_control(packer, apply_steer, frame, steer_on, lkas_max_torqu
"LKA_ACTIVE": steer_on,
}
dat = packer.make_can_msg("LKAS", 0, values)[2]
dat = packer.make_can_msg("LKAS", 0, values)[1]
values["CHECKSUM"] = nissan_checksum(dat[:7])
return packer.make_can_msg("LKAS", 0, values)

View File

@ -279,7 +279,7 @@ def create_es_static_2(packer):
# *** Subaru Pre-global ***
def subaru_preglobal_checksum(packer, values, addr, checksum_byte=7):
dat = packer.make_can_msg(addr, 0, values)[2]
dat = packer.make_can_msg(addr, 0, values)[1]
return (sum(dat[:checksum_byte]) + sum(dat[checksum_byte+1:])) % 256

View File

@ -25,7 +25,7 @@ class TeslaCAN:
"DAS_steeringControlCounter": counter,
}
data = self.packer.make_can_msg("DAS_steeringControl", CANBUS.chassis, values)[2]
data = self.packer.make_can_msg("DAS_steeringControl", CANBUS.chassis, values)[1]
values["DAS_steeringControlChecksum"] = self.checksum(0x488, data[:3])
return self.packer.make_can_msg("DAS_steeringControl", CANBUS.chassis, values)
@ -69,7 +69,7 @@ class TeslaCAN:
values["SpdCtrlLvr_Stat"] = 1
values["MC_STW_ACTN_RQ"] = counter
data = self.packer.make_can_msg("STW_ACTN_RQ", bus, values)[2]
data = self.packer.make_can_msg("STW_ACTN_RQ", bus, values)[1]
values["CRC_STW_ACTN_RQ"] = self.crc(data[:7])
return self.packer.make_can_msg("STW_ACTN_RQ", bus, values)
@ -88,7 +88,7 @@ class TeslaCAN:
}
for packer, bus in [(self.packer, CANBUS.chassis), (self.pt_packer, CANBUS.powertrain)]:
data = packer.make_can_msg("DAS_control", bus, values)[2]
data = packer.make_can_msg("DAS_control", bus, values)[1]
values["DAS_controlChecksum"] = self.checksum(0x2b9, data[:7])
messages.append(packer.make_can_msg("DAS_control", bus, values))
return messages

View File

@ -297,7 +297,7 @@ class TestCarModelBase(unittest.TestCase):
now_nanos += DT_CTRL * 1e9
msgs_sent += len(sendcan)
for addr, _, dat, bus in sendcan:
for addr, dat, bus in sendcan:
to_send = libpanda_py.make_CANPacket(addr, bus % 4, dat)
self.assertTrue(self.safety.safety_tx_hook(to_send), (addr, dat, bus))

View File

@ -90,7 +90,7 @@ def test_startup_alert(expected_event, car_model, fw_versions, brand):
managed_processes['card'].start()
assert pm.wait_for_readers_to_update('can', 5)
pm.send('can', can_list_to_can_capnp([[0, 0, b"", 0]]))
pm.send('can', can_list_to_can_capnp([[0, b"", 0]]))
assert pm.wait_for_readers_to_update('pandaStates', 5)
msg = messaging.new_message('pandaStates', 1)
@ -103,7 +103,7 @@ def test_startup_alert(expected_event, car_model, fw_versions, brand):
else:
finger = _FINGERPRINTS[car_model][0]
msgs = [[addr, 0, b'\x00'*length, 0] for addr, length in finger.items()]
msgs = [[addr, b'\x00'*length, 0] for addr, length in finger.items()]
for _ in range(1000):
# card waits for pandad to echo back that it has changed the multiplexing mode
if not params.get_bool("ObdMultiplexingChanged"):

View File

@ -6,5 +6,5 @@ def can_capnp_to_can_list(can, src_filter=None):
ret = []
for msg in can:
if src_filter is None or msg.src in src_filter:
ret.append((msg.address, msg.busTime, msg.dat, msg.src))
ret.append((msg.address, msg.dat, msg.src))
return ret

View File

@ -10,7 +10,6 @@ void can_list_to_can_capnp_cpp(const std::vector<can_frame> &can_list, std::stri
for (auto it = can_list.begin(); it != can_list.end(); it++, j++) {
auto c = canData[j];
c.setAddress(it->address);
c.setBusTime(it->busTime);
c.setDat(kj::arrayPtr((uint8_t*)it->dat.data(), it->dat.size()));
c.setSrc(it->src);
}

View File

@ -257,7 +257,6 @@ bool Panda::unpack_can_buffer(uint8_t *data, uint32_t &size, std::vector<can_fra
}
can_frame &canData = out_vec.emplace_back();
canData.busTime = 0;
canData.address = header.addr;
canData.src = header.bus + bus_offset;
if (header.rejected) {

View File

@ -39,7 +39,6 @@ struct __attribute__((packed)) can_header {
struct can_frame {
long address;
std::string dat;
long busTime;
long src;
};

View File

@ -219,7 +219,6 @@ void can_recv_thread(std::vector<Panda *> pandas) {
auto canData = evt.initCan(raw_can_data.size());
for (uint i = 0; i<raw_can_data.size(); i++) {
canData[i].setAddress(raw_can_data[i].address);
canData[i].setBusTime(raw_can_data[i].busTime);
canData[i].setDat(kj::arrayPtr((uint8_t*)raw_can_data[i].dat.data(), raw_can_data[i].dat.size()));
canData[i].setSrc(raw_can_data[i].src);
}

View File

@ -8,7 +8,6 @@ cdef extern from "panda.h":
cdef struct can_frame:
long address
string dat
long busTime
long src
cdef extern from "can_list_to_can_capnp.cc":
@ -22,9 +21,8 @@ def can_list_to_can_capnp(can_msgs, msgtype='can', valid=True):
for can_msg in can_msgs:
f = &(can_list.emplace_back())
f.address = can_msg[0]
f.busTime = can_msg[1]
f.dat = can_msg[2]
f.src = can_msg[3]
f.dat = can_msg[1]
f.src = can_msg[2]
cdef string out
can_list_to_can_capnp_cpp(can_list, out, msgtype == 'sendcan', valid)

View File

@ -49,7 +49,7 @@ class TestStreamSession:
def test_incoming_proxy(self, mocker):
tested_msgs = [
{"type": "customReservedRawData0", "data": "test"}, # primitive
{"type": "can", "data": [{"address": 0, "busTime": 0, "dat": "", "src": 0}]}, # list
{"type": "can", "data": [{"address": 0, "dat": "", "src": 0}]}, # list
{"type": "testJoystick", "data": {"axes": [0, 0], "buttons": [False]}}, # dict
]

View File

@ -66,7 +66,6 @@ void PandaStream::streamThread() {
auto canData = evt.initCan(raw_can_data.size());
for (uint i = 0; i<raw_can_data.size(); i++) {
canData[i].setAddress(raw_can_data[i].address);
canData[i].setBusTime(raw_can_data[i].busTime);
canData[i].setDat(kj::arrayPtr((uint8_t*)raw_can_data[i].dat.data(), raw_can_data[i].dat.size()));
canData[i].setSrc(raw_can_data[i].src);
}