How to check if driver is loaded?
Posted: Mon 6. Jan 2020, 16:55
Hi all, I'm writing a python script for raspbian that otherwise works fine. The issue I have is the software is broken if the can driver isn't loaded(meaning the usb to can device isn't physically connected to the pi). Quite simply, I wish to put the program on hold until the driver is loaded. How can I check if it is loaded?? I get the error reporting "The driver is not loaded".. full text of error:
ERROR: failed to scan directory (errno=2) '/sys/class/pcan'
ERROR: failed to open file (errno=2) '/sys/class/pcan/version'.
Traceback (most recent call last):
File "redacted", line 11, in <module>
bus = can.interface.Bus(bustype='pcan', channel='PCAN_USBBUS1', bitrate=500000)
File "/home/pi/.local/lib/python3.7/site-packages/can/interface.py", line 127, in __new__
return cls(channel, *args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/can/interfaces/pcan/pcan.py", line 198, in __init__
raise PcanError(self._get_formatted_error(result))
can.interfaces.pcan.pcan.PcanError: The driver is not loaded
ERROR: failed to scan directory (errno=2) '/sys/class/pcan'
ERROR: failed to open file (errno=2) '/sys/class/pcan/version'.
Traceback (most recent call last):
File "redacted", line 11, in <module>
bus = can.interface.Bus(bustype='pcan', channel='PCAN_USBBUS1', bitrate=500000)
File "/home/pi/.local/lib/python3.7/site-packages/can/interface.py", line 127, in __new__
return cls(channel, *args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/can/interfaces/pcan/pcan.py", line 198, in __init__
raise PcanError(self._get_formatted_error(result))
can.interfaces.pcan.pcan.PcanError: The driver is not loaded