21.11.2013 Views

CANgate User's Manual - dataTaker

CANgate User's Manual - dataTaker

CANgate User's Manual - dataTaker

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Command Reference<br />

Commands and Parameters<br />

In this section, literal text (to be entered exactly as shown) is shown thus: RECV.<br />

Variable parameters are shown as: CANport.<br />

Optional parameters are surrounded by braces. If multiple parameters are surrounded by braces, eg.<br />

CMD param1 param2 { param3 param4 }<br />

then one or more of the parameters may be omitted, starting with the rightmost parameter. That is, you can specify either:<br />

CMD param1 param2 or<br />

CMD param1 param2 param3 or<br />

CMD param1 param2 param3 param4<br />

If parameters have their own individual braces, eg.<br />

CMD param1 param2 { param3 } { param4 }<br />

then each optional parameter can be either specified, or not. So as well as the above choices you could also specify:<br />

CMD param1 param2 param4<br />

All optional parameters have a defined default value, which is what will be used if the parameter is not specified.<br />

Remember that <strong>CANgate</strong> commands are not case sensitive, so recv is equivalent to RECV.<br />

Slot Definition Commands<br />

RECV – Receive Standard-ID CAN Messages<br />

{ slot } RECV CANport RxID { startByte{.bit} endByte{.bit} sampleRate } { FORMAT formatOptions }<br />

where:<br />

slot is the memory slot being defined (integer, 0-150). If not specified then 0 is assumed. If <strong>CANgate</strong> is in Run Mode<br />

then zero is the only value that can go here.<br />

CANport is the CAN port to use (integer, 1-2)<br />

<br />

<br />

<br />

<br />

<br />

RxID is the 11-bit CAN identifier to listen for (integer, 0-0x7FF)<br />

startByte{.bit} is the starting bit position of the field of interest within the 8-byte CAN data field. Bytes are numbered<br />

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<br />

not specified then .8 is assumed.<br />

endByte{.bit} is the ending bit position (inclusive) of the field of interest within the 8-byte CAN data field. If endByte is<br />

not specified then 8 is assumed. If .bit is not specified then .1 is assumed.<br />

sampleRate is the rate at which to return values to the host (integer, in ms, must be multiple of 100ms). May also be<br />

ALL, in which case a value is returned on receipt of every matching CAN message. If this parameter is 0 or not<br />

specified, the memory slot will only return data when it is polled by the host system (using the RP command).<br />

formatOptions specify how the data value is to be formatted when it is returned to the host system; see FORMAT<br />

Sub-command (P21) for more details. if not specified, data will be returned in raw hexadecimal format.<br />

A RECV memory slot captures all messages on the specified CAN port with the specified standard identifier, and extracts the<br />

required data field. When polled (using the RP command), or at the intervals specified by the sampleRate parameter, the slot<br />

will return the most recent value for the data field. If no messages have been received, nothing will be returned (other than<br />

the configured static formatting text, which is specified by the FORMAT sub-command and by default is just CRLF).<br />

The SNOOP command (P24) can be used to determine which CAN identifiers are being broadcast on a CAN network.<br />

Note: If the sampleRate parameter is set to ALL, it is not guaranteed that every CAN message will be returned. Many CAN<br />

networks operate at high speed, and some parameters are broadcast at very frequent intervals. The rate at which these<br />

messages arrive may exceed the bandwidth of the host RS232 connection, or the processing capabilities of the <strong>CANgate</strong>.<br />

Examples<br />

RECV 1 0x220<br />

Receive messages on CAN port 1 with ID 0x220. When polled, return all 8 data bytes (in hexadecimal) of the most recent<br />

message.<br />

RECV 1 0x603 1 2 FORMAT "P1:%d\n"<br />

Receive ID 0x603 messages. When polled, return the first two data bytes as a single decimal integer, prefixed by P1:.<br />

Remember – if DeTransfer is used to send the above command then it would need to be entered as<br />

RECV 1 0x603 1 2 FORMAT "P1:%d\\n"<br />

UM-0086-A2 <strong>CANgate</strong> User’s <strong>Manual</strong> Page 16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!