PE6, Macro, CANFD 64bytes, failed to fill data

Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
John Linq
Posts: 3
Joined: Thu 5. Jun 2025, 05:28

PE6, Macro, CANFD 64bytes, failed to fill data

Post by John Linq » Fri 6. Jun 2025, 03:21

Hello everyone,
I need help understanding how to write this macro/script in PCAN-Explorer 6:

Code: Select all

  Dim RcvMsg, TxMsg
  Set RcvMsg = MyClient.Messages.Add
  Set TxMsg = MyClient.Messages.Add

  With TxMsg
    .ID = &H220
    .DLC = 10                ' 16 Bytes
    .MsgType = pcanMsgTypeFD + pcanMsgTypeBRS
    
    ' fill data
    Dim i
    For i = 0 To 7
      .Data(i) = i + &H10    ' i = 7 is OK, i > 7 just doesn't work
    Next
  End With
.Data(i) how to fill all 16bytes?

G.Lang
Support
Support
Posts: 169
Joined: Wed 22. Sep 2010, 14:58

Re: PE6, Macro, CANFD 64bytes, failed to fill data

Post by G.Lang » Fri 6. Jun 2025, 13:14

Hi,

please send us an email which include your PCAN-Explorers license ID and referr to this forum post.

John Linq
Posts: 3
Joined: Thu 5. Jun 2025, 05:28

Re: PE6, Macro, CANFD 64bytes, failed to fill data

Post by John Linq » Mon 9. Jun 2025, 03:56

Hi,

have sent an email to:

support.peak@hms-networks.com

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: PE6, Macro, CANFD 64bytes, failed to fill data

Post by K.Wolf » Tue 10. Jun 2025, 14:03

To resolve this, first set the MsgType, then the DLC.

In your example, when you set the DLC to 10, the message is still a classic CAN message, for which a DLC value of 10 is allowed (although not recommended) but it still means a data length of 8 bytes. The internal data buffer is allocated accordingly.
When you then change the message type to FD in the next line, the internal data buffer is not reallocated. But if you set the DLC after MsgType, the internal data buffer is allocated with the correct size 16.

John Linq
Posts: 3
Joined: Thu 5. Jun 2025, 05:28

Re: PE6, Macro, CANFD 64bytes, failed to fill data

Post by John Linq » Wed 11. Jun 2025, 02:16

Thanks for the help.

Post Reply