Skip to content

Commit

Permalink
deprecate busTime (#33146)
Browse files Browse the repository at this point in the history
* deprecate busTime

* bump

* do car can + more

* forgot some

* bump opendbc

* fix that too

* bump
  • Loading branch information
sshane authored Jul 31, 2024
1 parent b6d124d commit 42f2601
Show file tree
Hide file tree
Showing 21 changed files with 25 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion opendbc
2 changes: 1 addition & 1 deletion selfdrive/car/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/ford/fordcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/gm/gmcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/car/hyundai/hyundaican.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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))

Expand Down
8 changes: 4 additions & 4 deletions selfdrive/car/isotp_parallel_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, sendcan: messaging.PubSocket, logcan: messaging.SubSocket, bu
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"""
Expand All @@ -36,11 +36,11 @@ def rx(self):
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):
Expand All @@ -53,7 +53,7 @@ def _can_rx(self, addr, sub_addr=None):
# 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:
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/nissan/nissancan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/subaru/subarucan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 3 additions & 3 deletions selfdrive/car/tesla/teslacan.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create_steering_control(self, angle, enabled, counter):
"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)

Expand Down Expand Up @@ -69,7 +69,7 @@ def create_action_request(self, msg_stw_actn_req, cancel, bus, counter):
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)

Expand All @@ -88,7 +88,7 @@ def create_longitudinal_commands(self, acc_state, speed, min_accel, max_accel, c
}

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
2 changes: 1 addition & 1 deletion selfdrive/car/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def test_car_controller(car_control):

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))

Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/tests/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"):
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/pandad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion selfdrive/pandad/can_list_to_can_capnp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion selfdrive/pandad/panda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion selfdrive/pandad/panda.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ struct __attribute__((packed)) can_header {
struct can_frame {
long address;
std::string dat;
long busTime;
long src;
};

Expand Down
1 change: 0 additions & 1 deletion selfdrive/pandad/pandad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions selfdrive/pandad/pandad_api_impl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion system/webrtc/tests/test_stream_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def mocked_update(t):
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
]

Expand Down
1 change: 0 additions & 1 deletion tools/cabana/streams/pandastream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 42f2601

Please sign in to comment.