Skip to content

Commit

Permalink
misc CAN FD fixes (commaai#856)
Browse files Browse the repository at this point in the history
Co-authored-by: Comma Device <device@comma.ai>
  • Loading branch information
adeebshihadeh and Comma Device committed Feb 21, 2022
1 parent 0e79ab3 commit 9d27011
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions board/usb_comms.h
Expand Up @@ -440,10 +440,10 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp) {
// **** 0xde: set CAN FD data bitrate
case 0xf9:
if (setup->b.wValue.w < CAN_CNT) {
// TODO: add sanity check, ideally check if value is correct(from array of correct values)
// TODO: add sanity check, ideally check if value is correct (from array of correct values)
bus_config[setup->b.wValue.w].can_data_speed = setup->b.wIndex.w;
bus_config[setup->b.wValue.w].canfd_enabled = (setup->b.wIndex.w >= bus_config[setup->b.wValue.w].can_speed) ? true : false;
bus_config[setup->b.wValue.w].brs_enabled = (setup->b.wIndex.w > bus_config[setup->b.wValue.w].can_speed) ? true : false;
bus_config[setup->b.wValue.w].canfd_enabled = (setup->b.wIndex.w >= bus_config[setup->b.wValue.w].can_speed);
bus_config[setup->b.wValue.w].brs_enabled = (setup->b.wIndex.w > bus_config[setup->b.wValue.w].can_speed);
bool ret = can_init(CAN_NUM_FROM_BUS_NUM(setup->b.wValue.w));
UNUSED(ret);
}
Expand Down
10 changes: 5 additions & 5 deletions python/__init__.py
Expand Up @@ -163,9 +163,9 @@ class Panda(object):
HEALTH_PACKET_VERSION = 3
HEALTH_STRUCT = struct.Struct("<IIIIIIIIBBBBBBBHBBBHI")

F2_DEVICES = [HW_TYPE_PEDAL]
F4_DEVICES = [HW_TYPE_WHITE_PANDA, HW_TYPE_GREY_PANDA, HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS]
H7_DEVICES = [HW_TYPE_RED_PANDA]
F2_DEVICES = (HW_TYPE_PEDAL, )
F4_DEVICES = (HW_TYPE_WHITE_PANDA, HW_TYPE_GREY_PANDA, HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS)
H7_DEVICES = (HW_TYPE_RED_PANDA, )

CLOCK_SOURCE_MODE_DISABLED = 0
CLOCK_SOURCE_MODE_FREE_RUNNING = 1
Expand Down Expand Up @@ -448,7 +448,7 @@ def has_obd(self):
return (self.is_uno() or self.is_dos() or self.is_black() or self.is_red())

def has_canfd(self):
return self._mcu_type in Panda.H7_DEVICES
return self.get_type() in Panda.H7_DEVICES

def is_internal(self):
return self.get_type() in [Panda.HW_TYPE_UNO, Panda.HW_TYPE_DOS]
Expand Down Expand Up @@ -511,7 +511,7 @@ def set_can_speed_kbps(self, bus, speed):
def set_can_data_speed_kbps(self, bus, speed):
self._handle.controlWrite(Panda.REQUEST_OUT, 0xf9, bus, int(speed * 10), b'')

# CAN FD and BRS status
# CAN FD and BRS status
def get_canfd_status(self, bus):
dat = self._handle.controlRead(Panda.REQUEST_IN, 0xfa, bus, 0, 2)
if dat:
Expand Down

0 comments on commit 9d27011

Please sign in to comment.