UM-0086-A2
CANgate User’s Manual
Page 20
RQSTJ – Request J1939 Data
{ slot }
RQSTJ
CANport
PGN
{ startByte{
.
bit}
endByte{
.
bit}
ECUaddr
priority
sampleRate } {
FORMAT
fmtOpt }
The parameters for a
RQSTJ
slot are the same as for a RECVJ slot (except that
ALL
is not a valid setting for
sampleRate
),
but they are used in a somewhat different way.
When a RQSTJ slot is polled, CANgate will send a message to request a particular parameter group (PGN). The format of
this request message is defined in SAE J1939/21 (Data Link Layer). The request will be sent to destination address
ECUaddr
, or to the broadcast address if
ECUaddr
=
256
. The source address will be set to CANgate's configured address
(see
(P25)
).
CANgate will then listen for a response with an appropriate CAN identifier, the same as a RECVJ slot.
Some PGNs have more than 8 bytes of data (which is the limit of a single CAN frame) associated with them. In this case the
ECU will respond with a multi-packet transfer. This may take the form of a multi-packet broadcast, or it may be a
point-to-point transfer using the J1939 transport protocol. CANgate will accept either type of response.
Note that there are some special considerations to be aware of regarding multi-packet transfers; see
(P30)
.
(P29)
.
Note
: As is the case with ISO-14230 (RQST slots), the response time will depend upon the particular ECU. J1939 requests
are queued in the same way as ISO-14230 requests – CANgate will only send out one request at a time, and will time out
after approximately 400ms if there is no response.
Examples
RQSTJ 2 65254 1 1 0 6 1000 FORMAT .25
Once per second (1000ms), send a request on CAN port 2 for PGN 65254 (time/date) to the ECU with address 0, and expect
a reply with priority 6. The first byte of the response (seconds x 4) is extracted and returned.
GPS – Receive NMEA-0813 Messages
{ slot }
GPS "
header
"
fieldNum
{ option
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.
header
is the NMEA-0183 sentence header string, without the leading
$
character (string, eg.
"GPGLL"
)
fieldNum
specifies the data field of interest in the NMEA-0183 string (integer,
1-19
). The field immediately following
the sentence header is field #1.
option
(single character:
D
or
M
or
N
, default:
N
). If
N
(normal) is specified then the indicated field is returned as is.
Otherwise, the indicated field and the next field are interpreted as a latitude or longitude value with format
DDDMM
.
mmmmm
,
h
–
DDD
= degrees,
MM
.
mmmmm
= minutes,
h
= hemisphere (
N
,
S
,
E
or
W
). If
option
=
D
then
the
degrees
component is returned, ie.
DDD
, which will be prefixed by a minus sign if
h
=
S
or
W
. Similarly, if
option
=
M
then the
minutes
component is returned, ie.
MM
.
mmmmm
, which will also be prefixed by a minus sign if
h
=
S
or
W
.
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 GPS 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. Note that GPS data is always treated as a string; scaling options will be ignored.
The
FORMAT
clause is therefore only useful for adding before and after text.
If a GPS receiver is connected to CANgate then positional data (latitude, longitude, elevation, etc.) can be returned along
with measured CAN parameters.
A GPS receiver will transmit position messages via its RS232 interface, typically about once per second. These messages
are formatted according to the
NMEA-0183
protocol. NMEA-0183 defines many different
sentences
, each of which consists
of an identification string followed by a number of comma separated data values. For example, the sentence:
$GPGLL,3749.1965,S,14458.9940,E,073510.22,A
provides a basic positional fix, containing the current latitude (37° 49.1965' S, 144° 58.9940' E), and the time the fix was
taken (07:35:10.22 UTC). Other sentence types (eg.
$GPGGA
) provide more detailed information, including elevation,
accuracy, number of satellites in view, etc.
A CANgate
GPS
memory slot is used to parse incoming NMEA-0183 data and then return specific fields to the host. This will
capture all messages with the specified ID string, and extract 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, or if the specified field does not exist in the received messages, then 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).