UM-0086-A2
CANgate User’s Manual
Page 29
Data Range:
0 to 8031.875 rpm
Type:
Measured
Suspect Parameter Number: 190
The
SNOOPJ
command can now be used to verify that the PGN is in fact being broadcast by an ECU on the CAN network.
This involves examining the returned data looking for the required PGN (61444). For example:
SNOOPJ 1
…
EXT 0CF00402 PGN:61444 PRI:3 SA:2 DA:0
…
This line indicates that the required PGN is being broadcast on the network, and decodes the CAN identifier (0CF00402) as
follows:
priority
field is 3
PGN
field is 61444 (0x00F004)
destAddr
field is not applicable because this PGN uses PDU2 format (bits 15-8 of PGN >= 0xF0)
srcAddr
(ie. the address of the sending ECU) is 2.
Using this information, a memory slot can be initialised, for example:
RECVJ 1 61444 4 5 2 3 FORMAT 0.125 "%.3f rpm\n"
which will:
receive J1939 messages
on CAN port
1
with identifier 0x0CF00402 (PGN
61444
, source address
2
, priority
3
)
and extract bytes
4
-
5
as an unsigned 16-bit value (byte 4 = LSB, byte 5 = MSB)
then multiply by
0.125
and, when polled, return the result as a floating point value with 3 decimal places (
%.3f
)
followed by the text "
rpm
" and a CRLF (
\n
).
Note that for J1939, multi-byte fields are always specified LSB first (Intel format). It is not necessary to specify the
n
option
after the
FORMAT
for RECVJ/RQSTJ slots.
Request PGNs
Some PGNs are not broadcast; they are only returned when specifically requested. For example, if the above PGN was
actually a "request-only" PGN, the engine speed would then be obtained using:
RQSTJ 1 61444 4 5 2 3 FORMAT .125 "%.3f rpm\n"; RP
which looks very similar to the RECVJ slot definition. The
RP
on the end causes the memory slot to be immediately polled,
which will cause the request to be immediately sent. (Note that it doesn't make sense to poll a RECVJ slot immediately after
defining it, because at that time it is likely that no matching messages will have been received, in which case nothing will be
returned.)
Reusing Request Data
Often a J1939 PGN will contain several separate parameters (which is why it is called a Parameter Group Number). These
parameters are typically extracted using a number of memory slots, all with the same PGN but with different start and end
bytes specified. The same is true for certain OBD PIDs.
For requested PGNs, it is inefficient for each slot to send a separate request, particularly for multi-packet PGNs. Also, you
may not get a consistent snapshot of all of a PGN's constituent parameters – that is, they may not have been measured at
the same time (which may or may not be a problem).
For this reason, CANgate will attempt to reuse requested data where possible, ie. a RQST/RQSTJ slot will use previously
received reply data rather than sending a new request. This will, however, only be done if:
the most recently sent request message exactly matches this slot's request message (ie. it's a request for the same
PGN, same source and destination address and so on), and
this is a different slot to the one which sent the request (or, if this and the requesting slot are both slot #0, then the two
slot definitions are different in some way, eg. they are extracting a different range of bytes), and
the reply data was received less than 5 seconds ago.
The second condition means that if you repeatedly poll a group of slots, each of which extracts a different part of the same
PGN, then only one request will be sent each time the group is polled – provided that the group is polled within 5 seconds.