How to send sequence number

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
PCANUser
Posts: 26
Joined: Fri 14. Dec 2012, 10:40

How to send sequence number

Post by PCANUser » Fri 12. Dec 2014, 12:54

Hello,

I have a PCAN panel with various controls that are linked to a transmit message. The transmit message contains a sequence number. I would like to take the values from the panel and transmit them in the message but also automatically increment the sequence number with each transmitted message. As a further complication, there is a CRC in the message based upon the contents of the other fields.

I assume that macros are the way to go on this one but could you please provide some hints how to combine data from a panel with a sequence number and then combine these values to create a CRC that is also part of the same transmitted message?

Thanks,
Richard

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

Re: How to send sequence number

Post by K.Wolf » Mon 15. Dec 2014, 14:38

Hello,

you can do this only by using a VBS macro.
As an example, we have this symbol definition:

Code: Select all

{SENDRECEIVE}

[MyMessage]
ID=123h
DLC=8
Var=SequenceNumber unsigned 0,8
Var=Sig1 signed 8,16
Var=Sig2 signed 24,16
Var=CRC unsigned 56,8
The following macro code assigns the increasing SequenceNumber and calculates the CRC. Values for Sig1 and Sig2 are determined by two slider controls on a panel.

Code: Select all

Sub SendMessage()
  Dim sequence, sig1, sig2, crc

  Set sequence = Signals("SequenceNumber")
  Set sig1 = Signals("Sig1")
  Set sig2 = Signals("Sig2")
  Set crc = Signals("CRC")
  ' Disable AutoTransmit option of variables
  sequence.Source.AutoTransmit = False
  sig1.Source.AutoTransmit = False
  sig2.Source.AutoTransmit = False

  sequence.Value = 0
  While True
    sequence.Value = sequence.Value + 1
    crc.Value = 123  ' calculate and assign CRC value here
    Wait 100
  Wend
  
End Sub
When the CRC value is assigned, the message is actually transmitted, because AutoTransmit of the CRC variable is still set to True. The resulting message has an approximate transsmission cycle time of 100 ms.
Adjusting one of the slider controls does not generate additional transmit events.

Post Reply