I am using a Peak-USB X6 with D-Sub connectors. I am trying to reset a specific channel if 'message.is_error_frame', 'message.is_extended_id', or 'message.is_remote_frame' comes back as true. I am currently using 'Bus.reset()' to accomplish this. When testing the code on my Vector 1630, I was able to successfully reset channel 1 and 2 after the CAN line was disconnected, and once the communication was re-established the bus became active again and continued on with whatever it was previously doing. Using the exact same code with my X6 however, the bus does not reset and hits a heavy/warning limit. I looked through all the documentation and to my understanding the PcanBus object has the function reset(), but for some reason it is not working as expected and the X6 just has a fast-flashing red LED and doesn't appear to reset. Please take note that I am using this in a class. Below is the section of code in question.
Can anyone tell me if I am doing something wrong? If I am, how can I make this work for my Peak-USB X6 interface same as it works for my Vector 1630?
def run(self):
print("...Starting to Monitor CAN...")
while self._ISRUNNING == True:
try:
# Read message from bus
msg = self.canBus.recv(timeout=1.0)
# Catch abnormal messages
if msg is None or msg.is_error_frame or msg.is_extended_id or msg.is_remote_frame:
self._BUSEMPTY = True
self.canBus.reset()
print("...Bus Empty Detected!")
sleep(5)
continue
except Exception as e:
continue
I have tried the code posted above and expected it to work as it does with the Vector VN1630, but it will not reset. I have tried this on multiple machines and installed the most recent drivers for the device and it still does not work. I also tried the 'Bus.flush_tx_buffer()' beforehand and it did not help, either. Although using the flush_tx_buffer function sometimes causes it to switch to a slow-blinking red LED, but I cannot get it to slow-blink green as it should be when reset.