UM-0086-A2
CANgate User’s Manual
Page 16
Command Reference
Commands and Parameters
In this section,
literal text
(to be entered exactly as shown) is shown thus:
RECV
.
Variable
parameters
are shown as:
CANport
.
Optional parameters
are surrounded by braces. If multiple parameters are surrounded by braces, eg.
CMD
param1
param2
{ param3
param4 }
then one or more of the parameters may be omitted, starting with the rightmost parameter. That is, you can specify either:
CMD
param1
param2
or
CMD
param1
param2
param3
or
CMD
param1
param2
param3
param4
If parameters have their own individual braces, eg.
CMD
param1
param2
{ param3 }
{ param4 }
then each optional parameter can be either specified, or not. So as well as the above choices you could also specify:
CMD
param1
param2
param4
All optional parameters have a defined default value, which is what will be used if the parameter is not specified.
Remember that CANgate commands are not case sensitive, so
recv
is equivalent to
RECV
.
Slot Definition Commands
RECV – Receive Standard-ID CAN Messages
{ slot }
RECV
CANport
RxID
{ startByte{
.
bit}
endByte{
.
bit}
sampleRate }
{
FORMAT
formatOptions }
where:
slot
is the memory slot being defined (integer,
0-150
). If not specified then
0
is assumed. If CANgate is in Run Mode
then zero is the only value that can go here.
CANport
is the CAN port to use (integer,
1-2
)
RxID
is the 11-bit CAN identifier to listen for (integer,
0-0x7FF
)
startByte{
.
bit}
is the starting bit position of the field of interest within the 8-byte CAN data field. Bytes are numbered
from 1 to 8, bits are numbered from 8 (MSB) down to 1 (LSB). If
startByte
is not specified then
1
is assumed. If
.
bit
is
not specified then
.8
is assumed.
endByte{
.
bit}
is the ending bit position (inclusive) of the field of interest within the 8-byte CAN data field. If
endByte
is
not specified then
8
is assumed. If
.
bit
is not specified then
.1
is assumed.
sampleRate
is the rate at which to return values to the host (integer, in ms, must be multiple of 100ms). May also be
ALL
, in which case a value is returned on receipt of every matching CAN message. If this parameter is
0
or not
specified, the memory slot will only return data when it is polled by the host system (using the
RP
command).
formatOptions
specify how the data value is to be formatted when it is returned to the host system; see
(P21)
for more details. if not specified, data will be returned in raw hexadecimal format.
A
RECV
memory slot captures all messages on the specified CAN port with the specified standard identifier, and extracts the
required data field. When polled (using the
RP
command), or at the intervals specified by the
sampleRate
parameter, the slot
will return the most recent value for the data field. If no messages have been received, nothing will be returned (other than
the configured static formatting text, which is specified by the
FORMAT
sub-command and by default is just CRLF).
The
SNOOP
command
can be used to determine which CAN identifiers are being broadcast on a CAN network.
Note:
If the
sampleRate
parameter is set to
ALL
, it is not guaranteed that every CAN message will be returned. Many CAN
networks operate at high speed, and some parameters are broadcast at very frequent intervals. The rate at which these
messages arrive may exceed the bandwidth of the host RS232 connection, or the processing capabilities of the CANgate.
Examples
RECV 1 0x220
Receive messages on CAN port 1 with ID 0x220. When polled, return all 8 data bytes (in hexadecimal) of the most recent
message.
RECV 1 0x603 1 2 FORMAT "P1:%d\n"
Receive ID 0x603 messages. When polled, return the first two data bytes as a single decimal integer, prefixed by
P1:
.
Remember
– if
DeTransfer
is used to send the above command then it would need to be entered as
RECV 1 0x603 1 2 FORMAT "P1:%d\\n"