Page 1 of 1

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

Posted: Fri 6. Jun 2025, 03:21
by John Linq
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?

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

Posted: Fri 6. Jun 2025, 13:14
by G.Lang
Hi,

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

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

Posted: Mon 9. Jun 2025, 03:56
by John Linq
Hi,

have sent an email to:

support.peak@hms-networks.com

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

Posted: Tue 10. Jun 2025, 14:03
by K.Wolf
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.

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

Posted: Wed 11. Jun 2025, 02:16
by John Linq
Thanks for the help.