python-can icon indicating copy to clipboard operation
python-can copied to clipboard

Vector hardware,no ack can not raise can.CanError

Open XXIN0 opened this issue 3 years ago • 12 comments

Describe the bug

HI, I want to test the can transmit without ack,but it can raise can.CanError. image

Additional context

Python version:3.7.9 python-can version: 3.3.4 python-can interface/s (if applicable): Vector CANcaseXL

import can

my_bus = can.interface.Bus(bustype='vector', channel='0,1', app_name='Python Can',bitrate=500000, receive_own_messages=False)
msg = can.Message(arbitration_id=0x123, data=[1, 2, 3, 4, 5, 6, 7, 8], channel="0,1",)
my_bus.send(msg, timeout=0.5)

XXIN0 avatar Jan 14 '22 01:01 XXIN0

You need a another device on the physical CAN bus to acknowledge your messages. Otherwise you have the option to use the Virtual Channel in Vector HW config. Then you don't need any receivers.

Would you mind posting your Traceback?

zariiii9003 avatar Jan 15 '22 23:01 zariiii9003

Hi, It didn't have Traceback,if use my way to send message.I think when the bus timeout,it will raise an error.

If I use the software:"Busmaster",it will raise an error,I don‘t know the diffrence between the "python-can" and "busmaster" image image

XXIN0 avatar Jan 17 '22 03:01 XXIN0

Sorry @XXIN0, but I do not understand how python-can comes into play here where the problem is that you want to report or get assistance with.

felixdivo avatar Jan 17 '22 06:01 felixdivo

for example,if I don't connect any devices,when I send an can message,it will raise an error that tell me the send is not ok.

XXIN0 avatar Jan 17 '22 09:01 XXIN0

Which one of these options is your problem?

  1. You expect an error, but you don't get any.
  2. You expect no error, but you get can.CanError.

zariiii9003 avatar Jan 17 '22 09:01 zariiii9003

1 is my expect

XXIN0 avatar Jan 17 '22 12:01 XXIN0

Hi, having the same issue, I see there is no implementation in the python canlib for raising errors when sending can frames with Vector interface. Will this be resolved soon?

geynis avatar Jun 02 '22 12:06 geynis

@XXIN0 I have found a work around, open the bus with receive_own_messages=True and use the receive function to get an error frame for an error on transmitted frames. I'm checking Vector's API to see how can we fix this issue, will let you know.

geynis avatar Jun 07 '22 05:06 geynis

for CAN you can check Message.is_error_frame. I don't think there is a way to get the exact kind of error. For CAN FD you can get the error type like this.

zariiii9003 avatar Jun 07 '22 07:06 zariiii9003

@zariiii9003 thanks, i didn't look on the latest version. I still think there should be a better way to get the Tx error on send function and not throw the receive function.

geynis avatar Jun 07 '22 07:06 geynis

The send function just adds the message to the send queue. There should be no exception unless the driver says so. However, we could implement the rxErrorCounter and txErrorCounter, i think that would be useful. But there should be a common api for all interfaces.

zariiii9003 avatar Jun 07 '22 07:06 zariiii9003

@XXIN0 I have found a work around, open the bus with receive_own_messages=True and use the receive function to get an error frame for an error on transmitted frames. I'm checking Vector's API to see how can we fix this issue, will let you know.

@geynis Thanks,I'll try your suggestion.

XXIN0 avatar Jun 08 '22 02:06 XXIN0