USERCANWRITE
Write frames to a CAN port
Platform: |
OEM719, OEM729, OEM7700, OEM7720, PwrPak7, CPT7, CPT7700, SMART7 |
Use this command to write a basic CAN frame to the specified CAN port. The USERCANSTATUS log can be used to check the completion or status of the operation. An optional user defined Transaction ID can be provided to help synchronize requests with responses in the USERCANSTATUS log.
This command is primarily intended to be used by Lua applications that need to interact with external devices.
Writing a CAN frame requires a Port ID, which indicates the CAN bus to write to; a identifier type (STANDARD or EXTENDED) and an identifier number. The operation can be set as "blocked" (TimeOutMS > 0) or "non-blocked" (TimeOutMS == 0). If set to "blocked", the operation will wait a certain period of time for a slot in the TX FIFO buffer. For system health reasons, there is no option for the operation to be blocked indefinitely.
Message ID: 2255
Syntax:
USERCANWRITE PortID MessageType MessageID Datalength Data [TimeOutMS] [TransactionID]
Abbreviated ASCII Examples:
USERCANWRITE CAN1 STD 123 8 3132333435363738 12 1234
USERCANWRITE CAN2 EXT 1767 3 ABCDED
Field |
Field Type |
ASCII Value |
Binary Value |
Description |
Format |
Binary Bytes |
Binary Offset |
---|---|---|---|---|---|---|---|
1 |
Command header |
– |
– |
USERCANWRITE header This field contains the command name for abbreviated ASCII or the message header for ASCII (see page 1) or Binary (see page 1). |
– |
Header |
0 |
2 |
PortID |
CAN1 |
1 |
The CAN port Identifier. |
Enum |
4 |
H |
CAN2 |
2 |
||||||
3 |
MessageType |
STD |
1 |
Standard message |
Enum |
4 |
H+4 |
EXT |
2 |
Extended message |
|||||
4 |
MessageID |
|
|
The Standard message ID has 11 bits. The Extended message ID has 29 bits. |
HexUlong |
4 |
H+8 |
5 |
Datalength |
0 to 8 |
The length of data to be written in bytes. |
Ulong |
4 |
H+12 |
|
6 |
Data |
|
|
The data to be written. The number of bytes in this data block must match the DataLength. In particular, when DataLength is 0, this field is empty. For ASCII and Abbreviated ASCII commands, this field is a hexadecimal string of two digits for each byte in the data block. There is no 0x prefix and spaces are not allowed in the string. Data is streamed to the device as a series of bytes in the order provided. |
UChar Array |
N1 |
H+16 |
7 |
TimeOutMS |
0 to 5000 |
The number of milliseconds for the operation to timeout. Default is 0. If set to 0, there is no wait for a free slot in the TX FIFO. If no slot is available, the data drops and a flag is set in USERCANSTATUS log. Maximum value is 5000. |
Ulong |
4 |
H+16+4*INT((N+3)/4) |
|
8 |
TransactionID |
|
|
An optional user provided ID for this transaction. Default = 0. This transaction ID is copied to the USERCANSTATUS log created for this write operation. |
Ulong |
4 |
H+20+4*INT((N+3)/4) |