python-can-isotp: Not able to transmit data for classic CAN FD (single frame size= 64 bytes)
My requirement is to transmit data from can to tcp (for classic CANTp speed control service) I am trying to transmit single frame size of 64 bytes on CAN channel using isotp.stack(). Similar to what we have here https://github.com/pylessard/python-can-isotp/blob/a5b1df256ae3bec5cb86c980668dbad07629bb43/test/test_transport_layer.py#L20
My Code snippet:
import can
class VirtualBus:
def __init__(self, net_channel: str = '0'):
self.bus = can.Bus(channel=net_channel,
interface='vector',
receive_own_messages=True,
app_name='CANoe',
bitrate=500000)
bus = VirtualBus(net_channel=channel)
print(bus.bus.channel_info)
address = isotp.Address(addressing_mode=isotp.AddressingMode.Normal_29bits, rxid=rxid, txid=txid)
stack = isotp.CanStack(bus=bus.bus,
address=address,
error_handler=print,
params={'tx_padding': 0xCC,
'can_fd': True,
'tx_data_length': 64,
'rx_consecutive_frame_timeout': 100000})
stack.send(data)
while stack.transmitting():
stack.process()
time.sleep(stack.sleep_time())
Getting error as:
"C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\can\broadcastmanager.py", line 281, in _run self.bus.send(self.messages[msg_index]) File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\can\interfaces\vector\canlib.py", line 536, in send self._send_sequence([msg]) File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\can\interfaces\vector\canlib.py", line 543, in _send_sequence return self._send_can_msg_sequence(msgs) File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\can\interfaces\vector\canlib.py", line 556, in _send_can_msg_sequence xl_event_array = (xlclass.XLevent * message_count.value)( File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\can\interfaces\vector\canlib.py", line 580, in _build_xl_event xl_event.tagData.msg.data = tuple(msg.data) RuntimeError: (c_ubyte_Array_8) <class 'IndexError'>: invalid index (c_ubyte_Array_8) <class 'IndexError'>: invalid index
Note : when I tried to change the value of ‘tx_data_length’ more than 8 bytes, its throwing the above error. Also to add CAPL script with the same rxid and txid works perfect. Is something in the canoe application that i have to enable for CAN FD??
Am I missing anything?? Any parameter that I need to set? Please help me out here.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24 (11 by maintainers)
Credits goes to @zariiii9003 😃 I’m closing this issue
You must adapt your bit timings either in CANoe or in python-can:
The bitrates and the sample points must match, otherwise an exception is thrown.
Good, I will monitor it. You should show how you create your bus object 😃