You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
can.viewer hangs when encountering CANFD data frames #1400
@j-c-cook@zariiii9003 First of all, thank you very much for your response. I got myself the dev branch installed and tried out.
However, when I execute the script with > python -m can.viewer -c 1 -i vector, I can see the messages but they are truncated. The DLC indication is correct. Note that, I did NOT have to supply --fd flag. If I did that, I couldn't see the messages that I was sending with DLC> 8.
I can now see the CAN FD messages from the ECU, but I cannot see the messages that I sent out. The script is as follows:
import random
import time
import os
import can
from can.interfaces.vector import VectorBus
def send_fd_messages(bus: VectorBus) -> None:
while True:
length = random.randint(1, 12)
data = os.urandom(length)
msg = can.Message(
arbitration_id=0,
data=bytearray(data),
is_fd=True,
is_rx=False,
bitrate_switch=True,
dlc=length,
)
bus.send(msg)
time.sleep(0.1)
if __name__ == '__main__':
bus = VectorBus(
app_name='python-can', # the serial number of your virtual bus. Can be 0 or 100
channel=1,
fd=True,
bitrate=500_000,
data_bitrate=2_000_000,
receive_own_messages=True,
)
send_fd_messages(bus)
Also, the moment I initialize Kvaser device in code, it throws the following error.
import random
import time
import os
import can
#from can.interfaces.vector import VectorBus
from can.interfaces.kvaser import KvaserBus
def send_fd_messages(bus: KvaserBus) -> None:
while True:
print(1)
# length = random.randint(1,8)
# data = os.urandom(length)
# msg = can.Message(arbitration_id=0x18DBFFF9,data=bytearray(data),is_fd=False,is_rx=False,bitrate_switch=False,dlc=length)
# print(msg)
# bus.send(msg)
# time.sleep(0.5)
if __name__ == '__main__':
bus = KvaserBus(
#app_name='python-can', # the serial number of your virtual bus. Can be 0 or 100
channel=1,
fd=True,
bitrate=500_000,
data_bitrate=2_000_000,
receive_own_messages=False,
)
send_fd_messages(bus)
Traceback
Traceback (most recent call last):
File ".\fd_tx_test.py", line 21, in
bus = KvaserBus(
File "C:\N92\python-can dev\lib\site-packages\can\interfaces\kvaser\canlib.py", line 453, in init
self._read_handle = canOpenChannel(channel, flags)
File "C:\N92\python-can dev\lib\site-packages\can\interfaces\kvaser\canlib.py", line 131, in __check_bus_handle_validity
raise CANLIBInitializationError(function, result, arguments)
can.interfaces.kvaser.canlib.CANLIBInitializationError: Function canOpenChannel failed - Specified device not found [Error Code -3]
Thank you both @j-c-cook@zariiii9003 for your help. I have managed to found out that the Kvaser VCI device that I have, only supports CAN and not CAN FD. As for the Vector device, our ECU has some special set up that only can communicate with specific peripheral devices. When I connected such a peripheral unit, I could read and send CAN FD messages directly on the CAN bus. And it works with both the older version of can.viewer as well as the dev branch.
I will close this case as it has been resolved for me.
As for the Vector device, our ECU has some special set up that only can communicate with specific peripheral devices. When I connected such a peripheral unit, I could read and send CAN FD messages directly on the CAN bus.
That doesn't sound plausible to me. I assume that you set your bit timings correctly.
Could it be that you are using the non ISO CANFD version? You could add a new line here to try that:
Activity
zariiii9003 commentedon Sep 28, 2022
Have you tried the develop branch? The can.viewer works fine with CAN FD and long messages, i just tested it.
j-c-cook commentedon Sep 29, 2022
@o92 To install the develop branch, you can use
pip install git+https://github.com/hardbyte/python-can@develop.n-92 commentedon Sep 29, 2022
@j-c-cook @zariiii9003 First of all, thank you very much for your response. I got myself the dev branch installed and tried out.
However, when I execute the script with > python -m can.viewer -c 1 -i vector, I can see the messages but they are truncated. The DLC indication is correct. Note that, I did NOT have to supply --fd flag. If I did that, I couldn't see the messages that I was sending with DLC> 8.
https://user-images.githubusercontent.com/8834529/193082331-c0920d00-b3dc-4b1a-afb1-71757de3c251.png
And when I try to print msg.data field on console, I get as follows:
bytearray(b'!!!!!\x1e!\xfe')
zariiii9003 commentedon Sep 29, 2022
Can you run this?
n-92 commentedon Sep 30, 2022
Just an update:
I can now see the CAN FD messages from the ECU, but I cannot see the messages that I sent out. The script is as follows:
n-92 commentedon Sep 30, 2022
Also, the moment I initialize Kvaser device in code, it throws the following error.
Traceback
Traceback (most recent call last):
File ".\fd_tx_test.py", line 21, in
bus = KvaserBus(
File "C:\N92\python-can dev\lib\site-packages\can\interfaces\kvaser\canlib.py", line 453, in init
self._read_handle = canOpenChannel(channel, flags)
File "C:\N92\python-can dev\lib\site-packages\can\interfaces\kvaser\canlib.py", line 131, in __check_bus_handle_validity
raise CANLIBInitializationError(function, result, arguments)
can.interfaces.kvaser.canlib.CANLIBInitializationError: Function canOpenChannel failed - Specified device not found [Error Code -3]
Kvaser Device guide
n-92 commentedon Oct 3, 2022
Hello,
Thank you both @j-c-cook @zariiii9003 for your help. I have managed to found out that the Kvaser VCI device that I have, only supports CAN and not CAN FD. As for the Vector device, our ECU has some special set up that only can communicate with specific peripheral devices. When I connected such a peripheral unit, I could read and send CAN FD messages directly on the CAN bus. And it works with both the older version of can.viewer as well as the dev branch.
I will close this case as it has been resolved for me.
j-c-cook commentedon Oct 3, 2022
Thank you for the update and closing your issue now that it's resolved. Glad to know the
developbranch is functional for your application. 🚀zariiii9003 commentedon Oct 4, 2022
That doesn't sound plausible to me. I assume that you set your bit timings correctly.
Could it be that you are using the non ISO CANFD version? You could add a new line here to try that:
python-can/can/interfaces/vector/canlib.py
Line 399 in 89c395f