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
How to send sequence number
Re: How to send sequence number
Hello,
you can do this only by using a VBS macro.
As an example, we have this symbol definition:
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.
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.
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
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
Adjusting one of the slider controls does not generate additional transmit events.