0

This is my code iam using cantools here ggg contains the converted integer values of hex id of message , dlcs contain the respective dlc value

 can_bus = can.interface.Bus(channel='0',bitrate=500000, bustype='vector' ,app_name='CANalyzer',data_bitrate=2000000)
  can_bus2 = can.interface.Bus(channel='0',bitrate=500000,bustype='vector',app_name='CANalyzer',data_bitrate=2000000)
 for i,j in zip(ggg,dlcs):
    example_messages = db.get_message_by_frame_id(i)
    message = can.Message(arbitration_id=example_messages.frame_id,is_rx=False,data=[1,2,3,4,5,6,7,8],is_extended_id = True,dlc=int(j),is_fd=True,bitrate_switch=True)
    
    #can_bus.send(message) ##send single messages
    can_bus.send_periodic(message,0.100,30,True) # /send periodic messages
    example_message = can_bus2.recv(3) #/recieve messages

Message where 8 bytes is getting transmitted properly

getting these errors due to more dlc size in my messages a helping hand would be wonderful .

Traceback (most recent call last):
  File "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 560, in _send_can_msg_sequence
    self.xldriver.xlCanTransmit(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\can\interfaces\vector\xldriver.py", line 37, in check_status_operation
    raise VectorOperationError(
can.interfaces.vector.exceptions.VectorOperationError: xlCanTransmit failed (XL_ERR_INVALID_DLC) [Error Code 513]
xlCanTransmit failed (XL_ERR_INVALID_DLC) [Error Code 513]


Note : when i tried to change the data more than 8 bytes in can.message its throwing error


 "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
  • You are using classic CAN and not CAN FD, right? If so then why are you surprised that the DLC caps at 8 bytes... – Lundin Sep 28 '22 at 07:47
  • 1
    Only setting `is_fd=True` on each message is not enough to enable CAN FD. You should also add `fd=True` when you create the `can_bus` object. – MSpiller Sep 28 '22 at 08:27
  • hi @M.Spiller after making the changes you suggested iam getting a TxErr , not acknowledged error and dominant error , please give guidance as iam new to this subject – Lakshmi Srikanta Sep 28 '22 at 13:23
  • Again, can you please clarify if you are using CAN or CAN FD. – Lundin Sep 28 '22 at 14:26
  • @Lundin my application is meant to be used for CAN FD and CAN TP respectively and simulate the IG Block using python . my network hardware settings are 500 , 2000 – Lakshmi Srikanta Sep 28 '22 at 15:36
  • _Not acknowledged error_ means that no other CAN node has acknowledged the message. Check the other nodes, cabling, termination, etc. – MSpiller Sep 29 '22 at 09:20

1 Answers1

0

I was getting the same error as you have mentioned.

RuntimeError: (c_ubyte_Array_8) <class 'IndexError'>: invalid index

Following set of code helped me: Can bus obj initialization: set fd=True

self.bus = can.Bus(channel=net_channel,
                   interface='vector',
                   receive_own_messages=True,
                   app_name='CANoe',
                   fd=True,
                   bitrate=500000)
msg0 = can.Message(arbitration_id=0x580, dlc=15, is_fd=True,
                   is_extended_id=True, bitrate_switch=True,
                   data=[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3])

you can look into my reported issue https://github.com/hardbyte/python-can/issues/1582