Not sure why the following code throws the error AttributeError: 'CANManager' object has no attribute bus
:
class CANManager():
def __init__(self, name="can0", bitrate=500000, data_bitrate=2000000, fd=False):
self.bus_name = name
self.connect(fd)
def connect(self, fd: bool):
if fd is False:
self.bus = can.interface.Bus(channel=self.bus_name, bustype='socketcan')
elif fd is True:
self.bus = can.interface.Bus(channel=self.bus_name, bustype='socketcan')
return True
The self.connect(fd)
should initialize bus
in the constructor, shouldn't it?