![background image](http://html1.mh-extra.com/html/yacht-devices/ydnb-07n/ydnb-07n_user-manual_3085700037.webp)
— 37 —
Example 9.
PGNS_TO_ASSEMBLY=0x1F513
match(CAN1,0x1F51300,0x1FFFF00)
{
set(DATA+6, UINT32, get(DATA+6,UINT32) — 1852000) # 1000 nm off
send()
}
Example 10.
match(CAN1, 0x1F51300,0x1FFFF00)
{
if (get(DATA,UINT8) & 0x1F == 1) # 2-nd message in a sequence?
{
set(DATA+1, UINT32, get(DATA+1,UINT32) – 1852000) # 1000 nm off
}
send()
}
Net result of both programs will be the same, but in Example 10 the
match()
subprogram will be executed 3
times for each PGN 0x1F513, as this PGN is sent in a succession of 3 fast-packet frames. The code execution
time in the second example is longer, as it has additional operations.
But in the case of Example 9, the Device will receive all three CAN messages first and only then transmit
the assembled NMEA message to the program. The time between receiving the first and third messages
will be over 1000 microseconds, the period in which two messages on the CAN network must be
transmitted. When you call the
send()
, the NMEA 2000 message will be divided into three CAN messages
and go to the send queue. The third message will, at the earliest, be sent in 1000 microseconds.
In this way, in Example 10, all messages will be sent approximately 1000 microseconds earlier than
in Example 9. In practice, the difference of 1 millisecond may not seem significant, but the longer
the NMEA 2000 message, the longer will be the delay. Furthermore, if there is high load on the either
of the CAN networks, the program shown in Example 10 has an additional advantage.
Summary of Contents for YDNB-07N
Page 46: ......