Exception Handling can.CanError not working, Status of vector hardware

59 views Asked by At

enter image description hereI´m working on a simple CAN-Bus example with Vector hardware and trying to handle a exception. I would like to empty the transmit queue or reset the bus when the exception occurs so that data always continues to be sent if nothing is connected to the bus. Unfortunately it doesn't work as I would expect it. I'm sure it's a stupid question but I don't understand what I'm doing wrong. The exception is thrown in the library and my statement with the print at the end is ignored. Another question is how to get the actual XL_Status value in classcan.interfaces.vector.xldefine.XL_Status(value)?

import time
import can


try:
    bus1 = can.Bus(interface='vector', app_name='Tool', channel=0, bitrate=500000, data_bitrate=1000000,fd=False, receive_own_messages=False)
    bus1.flush_tx_buffer()

    msg1 = can.Message(arbitration_id=0x5FF, data=[0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00], is_extended_id=False)


    #bus.send_periodic()
    task1 = bus1.send_periodic(msgs = msg1, period = 0.2)               
    print(f"Message sent on {bus1.channel_info}")


    while 1:
        time.sleep(1)

except can.CanError:
    print("Message NOT sent")

I have checked the lower levels of the library but not managed to get the status-parameters of the hardware.

0

There are 0 answers