Send message data to the CAN bus.
To use this function, the following device configuration must be completed:
Configuration
➜CAN Bus
..
➜Connect CAN bus1
..
➜Interface Operating Mode
➜Active
In the function menu | On the diagram |
---|---|
![]() |
![]() |
Name | Value Type | Description |
---|---|---|
start |
bool |
Start data transmission |
data 0..3 |
int32 |
Lower 4 bytes of data to send |
data 4..7 |
int32 |
Upper 4 bytes of data to send |
size |
int32 |
Number of bytes to transmit |
Name | Value Type | Description |
---|---|---|
state |
int32 |
Transmitter status: 0 — no data to send 1 — data sent -1 — function misconfigured -2 — data transmission error |
0 -> 1 -> 0 // final status if successful
|
* -> [-1 .. -2] // error
None
Name | Description |
---|---|
Bus | CAN interface used:CAN1 CAN2 |
Identifier Size | Identifier type: 11 bit 29 bit |
Identifier | Identifier value |
RTR Packet | The RTR flag value that will be set by the device when sending the message |
Byte Order | Byte order used when sending the source data array to the CAN bus. For example, if data 0..3 = 0x44332211, data 4..7 = 0x88776655, then data = [11,22,33,44,55,66,77,88]: “Little-endian” data sent = [11,22,33,44,55,66,77,88] “Big-endian”data sent = [88,77,66,55,44,33,22,11] “Big-endian (2 bytes)”data sent = [22,11,44,33,66,55,88,77] |
Send Mode | Whether to send the message continuously or a specific number of times |
Send Interval | Time interval between transmissions |
Repeat Count | Number of message repetitions |
Input Data | |
---|---|
data 0..3 | 0x44332211 |
data 4..7 | 0x88776655 |
size | 6 |
RTR | False |
Identifier | 0x375 |
The function reads values from data 0..3 and data 4..7 and forms an internal array data. The array is filled byte-by-byte starting from the least significant byte.
data array | ||||||||
---|---|---|---|---|---|---|---|---|
Element Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
Element Value | -- |
-- |
-- |
-- |
-- |
-- |
-- |
-- |
Value 0x44332211 fills array data from index 0 to 3:
data array | ||||||||
---|---|---|---|---|---|---|---|---|
Element Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
Element Value | 11 |
22 |
33 |
44 |
-- |
-- |
-- |
-- |
Value 0x88776655 fills array data from index 4 to 7:
data array | ||||||||
---|---|---|---|---|---|---|---|---|
Element Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
Element Value | 11 |
22 |
33 |
44 |
55 |
66 |
77 |
88 |
If size < 8, the data array is truncated from the end. In this case, size = 6, so the array becomes:
data array | ||||||
---|---|---|---|---|---|---|
Element Index | 0 | 1 | 2 | 3 | 4 | 5 |
Element Value | 11 |
22 |
33 |
44 |
55 |
66 |
Based on the Byte Order setting:
Little-endian – sent as is:
data array | ||||||
---|---|---|---|---|---|---|
Element Index | 0 | 1 | 2 | 3 | 4 | 5 |
Element Value | 11 |
22 |
33 |
44 |
55 |
66 |
Big-endian – full reversal:
data array | ||||||
---|---|---|---|---|---|---|
Element Index | 0 | 1 | 2 | 3 | 4 | 5 |
Element Value | 66 |
55 |
44 |
33 |
22 |
11 |
Big-endian (2 bytes) – each 2-byte pair reversed:
data array | ||||||
---|---|---|---|---|---|---|
Element Index | 0 | 1 | 2 | 3 | 4 | 5 |
Element Value | 22 |
11 |
44 |
33 |
66 |
55 |
With Identifier and RTR applied, the final message is:
If Little-endian order:
ID | RTR | SIZE | Data | |||||||
---|---|---|---|---|---|---|---|---|---|---|
375 |
0 |
6 |
11 |
22 |
33 |
44 |
55 |
66 |
-- |
-- |
If Big-endian order:
ID | RTR | SIZE | Data | |||||||
---|---|---|---|---|---|---|---|---|---|---|
375 |
0 |
6 |
66 |
55 |
44 |
33 |
22 |
11 |
-- |
-- |
Input Data | |
---|---|
data 0..3 | 0x56000000 |
data 4..7 | 0x00020004 |
size | 5 |
RTR | False |
Identifier | 0x310 |
Byte Order | Big-endian |
Will be sent to the CAN bus:
ID | RTR | SIZE | Data | |||||||
---|---|---|---|---|---|---|---|---|---|---|
310 |
0 |
5 |
04 |
56 |
00 |
00 |
00 |
-- |
`- |