serialhdl: Only load the CAN module if CAN bus is configured

Temporarily postpone loading the CAN module so that moonraker (and
similar) can improve upgrade scripts.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-03-13 15:02:41 -05:00
parent c7dc3e78bf
commit 4cbcd45ce9
1 changed files with 2 additions and 1 deletions

View File

@ -4,7 +4,7 @@
# #
# This file may be distributed under the terms of the GNU GPLv3 license. # This file may be distributed under the terms of the GNU GPLv3 license.
import logging, threading, os import logging, threading, os
import serial, can import serial
import msgproto, chelper, util import msgproto, chelper, util
@ -103,6 +103,7 @@ class SerialReader:
self.serialqueue, receive_window) self.serialqueue, receive_window)
return True return True
def connect_canbus(self, canbus_uuid, canbus_nodeid, canbus_iface="can0"): def connect_canbus(self, canbus_uuid, canbus_nodeid, canbus_iface="can0"):
import can # XXX
txid = canbus_nodeid * 2 + 256 txid = canbus_nodeid * 2 + 256
filters = [{"can_id": txid+1, "can_mask": 0x7ff, "extended": False}] filters = [{"can_id": txid+1, "can_mask": 0x7ff, "extended": False}]
# Prep for SET_NODEID command # Prep for SET_NODEID command