Documentation Home Page RT-LAB Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

Procedure to Decode CanAc2Monitor Data

Description

CanAc2 Monitor block has been conceived to monitor all message's types transmitted over the bus, therefore there is no message structure associated with this block. In spite of this behaviour it is still possible to decode signal values embedded within the 8-value vector reported in PacketX outport.

In order to decode the resulted data obtained from CanAc2 Monitor block it shall be necessary to perform the following steps:

  • Obtain the message’s structure; in CanAc2 nomenclature, it is called “output_line_width”.
  • Apply the following equation:


Signal Conversion


If CanAc2 Monitor block does data unpacking with option “Signal 1-N” (big endian):

Shifting for Big Endian format


If CanAc2 Monitor block does data unpacking with option “Signal N-1” (little endian):

Shifting for Little Endian format


Equation's Parameter Definition

ParameterDescriptionRemarks
n1, 2, 3,…N
NIt’s the number of signals contained within the message structure.
hDenotes hexadecimal format.
&Ampersand symbol denotes a bit-wise AND operation.
Message_dataType64The contents of this variable shall depend on the type of swapping applied during message codification, so the message received by CanAc2 Monitor block should be treated depending on each specific case.See Table 2
ouput_line_width[index]Elements of output_line_witdth are ZERO if index is out of range.index < 1 or index > N

Treatment of the CanAc2 Monitor raw data

Type of unpacking in CanAc2 Monitor Operation to do over CanAc2 Monitor Data 
Signal 1 to N-No SwappingApply 8-bit swapping
Signal 1 to N-Swap 8-bitDo nothing
Signal 1 to N-Swap 16-bitApply 16-bit swapping, then 8-bit swapping
Signal 1 to N-Swap 32-bitApply 32-bit swapping, then 8-bit swapping
Signal N to 1-No SwappingDo nothing
Signal N to 1- Swap 8-bitApply 8-bit swapping
Signal N to 1- Swap 16-bitApply 16-bit swapping
Signal N to 1- Swap 32-bitApply 32-bit swapping

Example 1

signal_values = [3 1 30 100 120 200 201 1000 202]

output_line_width = [2 3 7 7 7 8 8 16 8]

CanAc2 Monitor block performs “Signal 1-N-No Swapping”: This means that the order of signal storage into the CAN message shall be from left to right; LSB signal (most to the left) shall be placed in LSB message data bytes (D 0) without swapping.

CanAc2 Monitor block returns the following raw data:

CanAc2_Monitor_data = [C7 93 F1 C8 C9 E8 03 CA]

Perform 8-bit swapping: Take the elements in reverse order in 1-byte groups.

Message_dataType64 = [C7 93 F1 C8 C9 E8 03 CA]

Message_dataType64 = [ CA 03 E8 C9 C8 F1 93 C7] = CA03E8C9C8F193C7 h

Example 2

signal_values = [3 1 30 100 120 200 201 1000 202]

output_line_width = [2 3 7 7 7 8 8 16 8]

CanAc2 Monitor block performs “Signal 1-N- Swap 32-bit”: This means that the order of signal storage into the CAN message shall be from left to right; LSB signal (most to the left) shall be placed in LSB message data bytes (D 0) with 32-bit swapping.

CanAc2 Monitor block returns the following data:

CanAc2_Monitor_data = [C9 E8 03 CA C7 93 F1 C8]

Perform 32-bit swapping: Take the elements in reverse order in 4-byte groups.

temp = [C9 E8 03 CA C7 93 F1 C8]

temp = [ C7 93 F1 C8 C9 E8 03 CA]

Then, perform 8-bit swapping to the previous result.

Message_dataType64 = 8bit_swapping(temp) = [C7 93 F1 C8 C9 E8 03 CA]

Message_dataType64 = [CA 03 E8 C9 C8 F1 93 C7] = CA03E8C9C8F193C7 h

Example 3

signal_values = [3 1 30 100 120 200 201 1000 202]

output_line_width = [2 3 7 7 7 8 8 16 8]

CanAc2 Monitor block performs “Signal N-1- Swap 16-bit”: This means that the order of signal storage into the CAN message will be from right to left; MSB signal (most to the right) shall be placed in LSB message data bytes (D 0) with 16-bit swapping.

CanAc2 Monitor block returns the following data:
CanAc2_Monitor_data = [E8 CA C9 03 78 C8 CF B2]
Perform 16-bit swapping: Take the elements in reverse order in 2-byte groups.

Message_dataType64 = [E8 CA C9 03 78 C8 CF B2]

Message_dataType64 = [ CF B2 78 C8 C9 03 E8 CA] = CFB278C8C903E8CA h

Example 4

Take result of example 1.

Message_dataType64 = CA03E8C9C8F193C7 h

Apply equations 1 & 2:


Example 5

Take result of example 3.

Message_dataType64 = CFB278C8C903E8CA h

Apply equations 1 & 3:

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323
Follow OPAL-RT: LinkedIn | Facebook | YouTube | X/Twitter