NMEA2000 Library  0.1
Library to handle NMEA 2000 Communication written in C++
NMEA2000.cpp File Reference
#include "NMEA2000.h"
#include "N2kDef.h"
#include "N2kGroupFunctionDefaultHandlers.h"
#include <string.h>
#include <stdlib.h>
Include dependency graph for NMEA2000.cpp:

Go to the source code of this file.

Macros

#define DbgPrintBuf(len, buf, addln)
 
#define DebugStream   Serial
 
#define MAX_PGNS_IN_LIST   74
 
#define MaxHeartbeatInterval   655320UL
 Maximum value for the ISO Heartbeat interval in ms. More...
 
#define N2kAddressClaimTimeout   250
 Timeout value for the ISO Address Claim in ms. More...
 
#define N2kDbg(fmt, args...)
 
#define N2kDbgln(fmt, args...)
 
#define N2kFrameErrDbg(fmt, args...)
 
#define N2kFrameErrDbgln(fmt, args...)
 
#define N2kFrameErrDbgStart(fmt, args...)
 
#define N2kFrameInDbg(fmt, args...)
 
#define N2kFrameInDbgln(fmt, args...)
 
#define N2kFrameInDbgStart(fmt, args...)
 
#define N2kFrameOutDbg(fmt, args...)
 
#define N2kFrameOutDbgln(fmt, args...)
 
#define N2kFrameOutDbgStart(fmt, args...)
 
#define N2kMsgDbg(fmt, args...)
 
#define N2kMsgDbgln(fmt, args...)
 
#define N2kMsgDbgStart(fmt, args...)
 
#define N2kPrintFreeMemory(a)
 
#define TP_CM   60416L
 Multi packet connection management, TP.CM. More...
 
#define TP_CM_Abort   255
 Multi packet connection management, Abort Connection. More...
 
#define TP_CM_AbortBusy   1
 Already in one or more connection managed sessions and cannot support another. More...
 
#define TP_CM_AbortNoResources   2
 System resources were needed for another task so this connection managed session was terminated. More...
 
#define TP_CM_AbortTimeout   3
 A timeout occurred and this is the connection abort to close the session. More...
 
#define TP_CM_ACK   19
 Multi packet connection management, End of Message Acknowledgement. More...
 
#define TP_CM_BAM   32
 Multi packet connection management, Broadcast Announce Message. More...
 
#define TP_CM_CTS   17
 Multi packet connection management, Clear To Send. More...
 
#define TP_CM_RTS   16
 Multi packet connection management, Request To Send. More...
 
#define TP_DT   60160L
 Multi packet data transfer. More...
 
#define TP_MAX_FRAMES   5
 Max frames, which can be received at time. More...
 

Functions

void CanIdToN2k (unsigned long id, unsigned char &prio, unsigned long &pgn, unsigned char &src, unsigned char &dst)
 Convert a CAN Id to NMEA2000 values. More...
 
void CopyBufToCANMsg (tN2kCANMsg &CANMsg, unsigned char start, unsigned char len, unsigned char *buf)
 Copy a Buffer to a CAN Message. More...
 
void CopyProgmemString (const char *str, size_t MaxLen, char *buf)
 
bool IsDefaultFastPacketMessage (unsigned long PGN)
 Checks if the PGN is a Default Fast Packet Message. More...
 
bool IsDefaultSingleFrameMessage (unsigned long PGN)
 Checks if the given PGN is a Default Single Frame Message. More...
 
bool IsFastPacketFirstFrame (unsigned char b)
 
bool IsFastPacketSystemMessage (unsigned long PGN)
 Checks if the given PGN is a Fast Packet System Message. More...
 
bool IsMandatoryFastPacketMessage (unsigned long PGN)
 Checks if the PGN is a Mandatory Fast Packet Message. More...
 
bool IsProprietaryFastPacketMessage (unsigned long PGN)
 Checks if the PGN is a Proprietary Fast Packet Message. More...
 
bool IsSingleFrameSystemMessage (unsigned long PGN)
 Checks if the given PGN is a Single Frame System Message. More...
 
unsigned long N2ktoCanID (unsigned char priority, unsigned long PGN, unsigned long Source, unsigned char Destination)
 Convert NMEA2000 values into a CAN Id. More...
 
bool ParseN2kPGN126996 (const tN2kMsg &N2kMsg, unsigned short &N2kVersion, unsigned short &ProductCode, int ModelIDSize, char *ModelID, int SwCodeSize, char *SwCode, int ModelVersionSize, char *ModelVersion, int ModelSerialCodeSize, char *ModelSerialCode, unsigned char &CertificationLevel, unsigned char &LoadEquivalency)
 Parsing the content of message PGN 126996 "Product information". More...
 
bool ParseN2kPGN126998 (const tN2kMsg &N2kMsg, size_t &ManufacturerInformationSize, char *ManufacturerInformation, size_t &InstallationDescription1Size, char *InstallationDescription1, size_t &InstallationDescription2Size, char *InstallationDescription2)
 Parsing the content of message PGN 126998 "Configuration information". More...
 
bool ParseN2kPGN59904 (const tN2kMsg &N2kMsg, unsigned long &RequestedPGN)
 Parsing the content of message PGN 59904 "ISO request". More...
 
template<typename T >
void PROGMEM_readAnything (const T *sce, T &dest)
 
size_t ProgmemStrLen (const char *str)
 
void SetN2kPGN126464 (tN2kMsg &N2kMsg, uint8_t Destination, tN2kPGNList tr, const unsigned long *PGNs)
 Setting up PGN 126464 Message "PGN List - Transmit PGNs group function". More...
 
void SetN2kPGN126993 (tN2kMsg &N2kMsg, uint32_t timeInterval_ms, uint8_t sequenceCounter)
 Setting up PGN 126993 Message "Heartbeat". More...
 
void SetN2kPGN126996 (tN2kMsg &N2kMsg, unsigned int N2kVersion, unsigned int ProductCode, const char *ModelID, const char *SwCode, const char *ModelVersion, const char *ModelSerialCode, unsigned char CertificationLevel, unsigned char LoadEquivalency)
 Setting up PGN 126996 Message "Product information". More...
 
void SetN2kPGN126996Progmem (tN2kMsg &N2kMsg, const tNMEA2000::tProductInformation *ProductInformation, char *OptionalSerialCode=0)
 
void SetN2kPGN126998 (tN2kMsg &N2kMsg, const char *ManufacturerInformation, const char *InstallationDescription1, const char *InstallationDescription2, bool UsePgm)
 Setting up PGN 126998 Message "Configuration information". More...
 
void SetN2kPGN59392 (tN2kMsg &N2kMsg, unsigned char Control, unsigned char GroupFunction, unsigned long PGN)
 ISO Acknowledgement. More...
 
void SetN2kPGN59904 (tN2kMsg &N2kMsg, uint8_t Destination, unsigned long RequestedPGN)
 Setting up PGN 59904 Message "ISO request". More...
 
void SetN2kPGN60928 (tN2kMsg &N2kMsg, uint64_t Name)
 Setting up PGN 60928 Message "ISO Address Claim". More...
 
void SetN2kPGN60928 (tN2kMsg &N2kMsg, unsigned long UniqueNumber, int ManufacturerCode, unsigned char DeviceFunction, unsigned char DeviceClass, unsigned char DeviceInstance, unsigned char SystemInstance, unsigned char IndustryGroup)
 Setting up PGN 60928 Message "ISO Address Claim". More...
 
size_t StrLen (const char *str)
 
unsigned char TPCtsPackets (unsigned char nPackets)
 

Variables

const char DefInstallationDescription1 [] = ""
 Default Installation Description (Field1) More...
 
const char DefInstallationDescription2 [] = ""
 Default Installation Description (Field2) More...
 
const char DefManufacturerInformation [] = "NMEA2000 library, https://github.com/ttlappalainen/NMEA2000"
 Default Manufacturer Information. More...
 
const tNMEA2000::tProductInformation DefProductInformation
 Default Product Information. More...
 
const unsigned long DefReceiveMessages []
 Default list of Received Messages. More...
 
const unsigned long DefTransmitMessages []
 Default list of Transmit Messages. More...
 

Macro Definition Documentation

◆ DbgPrintBuf

#define DbgPrintBuf (   len,
  buf,
  addln 
)

Definition at line 84 of file NMEA2000.cpp.

◆ DebugStream

#define DebugStream   Serial

Definition at line 32 of file NMEA2000.cpp.

◆ MAX_PGNS_IN_LIST

#define MAX_PGNS_IN_LIST   74

Definition at line 2124 of file NMEA2000.cpp.

◆ MaxHeartbeatInterval

#define MaxHeartbeatInterval   655320UL

Maximum value for the ISO Heartbeat interval in ms.

Definition at line 112 of file NMEA2000.cpp.

◆ N2kAddressClaimTimeout

#define N2kAddressClaimTimeout   250

Timeout value for the ISO Address Claim in ms.

Definition at line 110 of file NMEA2000.cpp.

◆ N2kDbg

#define N2kDbg (   fmt,
  args... 
)

Definition at line 91 of file NMEA2000.cpp.

◆ N2kDbgln

#define N2kDbgln (   fmt,
  args... 
)

Definition at line 92 of file NMEA2000.cpp.

◆ N2kFrameErrDbg

#define N2kFrameErrDbg (   fmt,
  args... 
)

Definition at line 47 of file NMEA2000.cpp.

◆ N2kFrameErrDbgln

#define N2kFrameErrDbgln (   fmt,
  args... 
)

Definition at line 48 of file NMEA2000.cpp.

◆ N2kFrameErrDbgStart

#define N2kFrameErrDbgStart (   fmt,
  args... 
)

Definition at line 46 of file NMEA2000.cpp.

◆ N2kFrameInDbg

#define N2kFrameInDbg (   fmt,
  args... 
)

Definition at line 57 of file NMEA2000.cpp.

◆ N2kFrameInDbgln

#define N2kFrameInDbgln (   fmt,
  args... 
)

Definition at line 58 of file NMEA2000.cpp.

◆ N2kFrameInDbgStart

#define N2kFrameInDbgStart (   fmt,
  args... 
)

Definition at line 56 of file NMEA2000.cpp.

◆ N2kFrameOutDbg

#define N2kFrameOutDbg (   fmt,
  args... 
)

Definition at line 67 of file NMEA2000.cpp.

◆ N2kFrameOutDbgln

#define N2kFrameOutDbgln (   fmt,
  args... 
)

Definition at line 68 of file NMEA2000.cpp.

◆ N2kFrameOutDbgStart

#define N2kFrameOutDbgStart (   fmt,
  args... 
)

Definition at line 66 of file NMEA2000.cpp.

◆ N2kMsgDbg

#define N2kMsgDbg (   fmt,
  args... 
)

Definition at line 77 of file NMEA2000.cpp.

◆ N2kMsgDbgln

#define N2kMsgDbgln (   fmt,
  args... 
)

Definition at line 78 of file NMEA2000.cpp.

◆ N2kMsgDbgStart

#define N2kMsgDbgStart (   fmt,
  args... 
)

Definition at line 76 of file NMEA2000.cpp.

◆ N2kPrintFreeMemory

#define N2kPrintFreeMemory (   a)

Definition at line 106 of file NMEA2000.cpp.

◆ TP_CM

#define TP_CM   60416L

Multi packet connection management, TP.CM.

Definition at line 117 of file NMEA2000.cpp.

◆ TP_CM_Abort

#define TP_CM_Abort   255

Multi packet connection management, Abort Connection.

Definition at line 129 of file NMEA2000.cpp.

◆ TP_CM_AbortBusy

#define TP_CM_AbortBusy   1

Already in one or more connection managed sessions and cannot support another.

Definition at line 133 of file NMEA2000.cpp.

◆ TP_CM_AbortNoResources

#define TP_CM_AbortNoResources   2

System resources were needed for another task so this connection managed session was terminated.

Definition at line 136 of file NMEA2000.cpp.

◆ TP_CM_AbortTimeout

#define TP_CM_AbortTimeout   3

A timeout occurred and this is the connection abort to close the session.

Definition at line 139 of file NMEA2000.cpp.

◆ TP_CM_ACK

#define TP_CM_ACK   19

Multi packet connection management, End of Message Acknowledgement.

Definition at line 127 of file NMEA2000.cpp.

◆ TP_CM_BAM

#define TP_CM_BAM   32

Multi packet connection management, Broadcast Announce Message.

Definition at line 121 of file NMEA2000.cpp.

◆ TP_CM_CTS

#define TP_CM_CTS   17

Multi packet connection management, Clear To Send.

Definition at line 125 of file NMEA2000.cpp.

◆ TP_CM_RTS

#define TP_CM_RTS   16

Multi packet connection management, Request To Send.

Definition at line 123 of file NMEA2000.cpp.

◆ TP_DT

#define TP_DT   60160L

Multi packet data transfer.

Definition at line 119 of file NMEA2000.cpp.

◆ TP_MAX_FRAMES

#define TP_MAX_FRAMES   5

Max frames, which can be received at time.

Definition at line 115 of file NMEA2000.cpp.

Function Documentation

◆ CanIdToN2k()

void CanIdToN2k ( unsigned long  id,
unsigned char &  prio,
unsigned long &  pgn,
unsigned char &  src,
unsigned char &  dst 
)

Convert a CAN Id to NMEA2000 values.

Parameters
idgiven CAN Id
prioPriority of the N2k message
pgnPGN of the N2k message
srcSource of the N2k message
dstDestination of the N2k message

Definition at line 1277 of file NMEA2000.cpp.

◆ CopyBufToCANMsg()

void CopyBufToCANMsg ( tN2kCANMsg CANMsg,
unsigned char  start,
unsigned char  len,
unsigned char *  buf 
)

Copy a Buffer to a CAN Message.

Parameters
CANMsgReference to an CANMsg Object with the result
startStartbyte inside the buffer
lenLength of the buffer
bufPointer to a buffer

Definition at line 1626 of file NMEA2000.cpp.

◆ CopyProgmemString()

void CopyProgmemString ( const char *  str,
size_t  MaxLen,
char *  buf 
)

Definition at line 864 of file NMEA2000.cpp.

◆ IsDefaultFastPacketMessage()

bool IsDefaultFastPacketMessage ( unsigned long  PGN)

Checks if the PGN is a Default Fast Packet Message.

Parameters
PGNPGN to be checked
Returns
true -> for PGNs:
  • 126983L: Alert, pri=2, period=1000
  • 126984L: Alert Response, pri=2, period=NA
  • 126985L: Alert Text, pri=2, period=10000
  • 126986L: Alert Configuration, pri=2, period=NA
  • 126987L: Alert Threshold, pri=2, period=NA
  • 126988L: Alert Value, pri=2, period=10000
  • 127233L: Man Overboard Notification(MOB), pri=3, period=NA
  • 127237L: Heading/Track control, pri=2, period=250
  • 127489L: Engine parameters dynamic, pri=2, period=500
  • 127490L: Electric Drive Status (Dynamic), pri=1, period=1500
  • 127491L: Electric Energy Storage Status (Dynamic), pri=7, period=1500
  • 127494L: Electric Drive Information, pri=4, period=NA
  • 127495L: Electric Energy Storage Information, pri=6, period=NA
  • 127496L: Trip fuel consumption, vessel, pri=5, period=1000
  • 127497L: Trip fuel consumption, engine, pri=5, period=1000
  • 127498L: Engine parameters static, pri=5, period=NA
  • 127503L: AC Input Status, pri=6, period=1500
  • 127504L: AC Output Status, pri=6, period=1500
  • 127506L: DC Detailed status, pri=6, period=1500
  • 127507L: Charger status, pri=6, period=1500
  • 127509L: Inverter status, pri=6, period=1500
  • 127510L: Charger configuration status, pri=6, period=NA
  • 127511L: Inverter Configuration Status, pri=6, period=NA
  • 127512L: AGS configuration status, pri=6, period=NA
  • 127513L: Battery configuration status, pri=6, period=NA
  • 127514L: AGS Status, pri=6, period=1500
  • 128275L: Distance log, pri=6, period=1000
  • 128520L: Tracked target data, pri=2, period=1000
  • 128538L: Elevator car status, pri=6, period=100
  • 129029L: GNSS Position Data, pri=3, period=1000
  • 129038L: AIS Class A Position Report, pri=4, period=NA
  • 129039L: AIS Class B Position Report, pri=4, period=NA
  • 129040L: AIS Class B Extended Position Report, pri=4, period=NA
  • 129041L: AIS Aids to Navigation (AtoN) Report, pri=4, period=NA
  • 129044L: Datum, pri=6, period=10000
  • 129045L: User Datum Settings, pri=6, period=NA
  • 129284L: Navigation info, pri=3, period=1000
  • 129285L: Waypoint list, pri=3, period=NA
  • 129301L: Time to/from Mark, pri=3, period=1000
  • 129302L: Bearing and Distance between two Marks, pri=6, period=NA
  • 129538L: GNSS Control Status, pri=6, period=NA
  • 129540L: GNSS Sats in View, pri=6, period=1000
  • 129541L: GPS Almanac Data, pri=6, period=NA
  • 129542L: GNSS Pseudorange Noise Statistics, pri=6, period=1000
  • 129545L: GNSS RAIM Output, pri=6, period=NA
  • 129547L: GNSS Pseudorange Error Statistics, pri=6, period=NA
  • 129549L: DGNSS Corrections, pri=6, period=NA
  • 129551L: GNSS Differential Correction Receiver Signal, pri=6, period=NA
  • 129556L: GLONASS Almanac Data, pri=6, period=NA
  • 129792L: AIS DGNSS Broadcast Binary Message, pri=6, period=NA
  • 129793L: AIS UTC and Date Report, pri=7, period=NA
  • 129794L: AIS Class A Static data, pri=6, period=NA
  • 129795L: AIS Addressed Binary Message, pri=5, period=NA
  • 129796L: AIS Acknowledge, pri=7, period=NA
  • 129797L: AIS Binary Broadcast Message, pri=5, period=NA
  • 129798L: AIS SAR Aircraft Position Report, pri=4, period=NA
  • 129799L: Radio Frequency/Mode/Power, pri=3, period=NA
  • 129800L: AIS UTC/Date Inquiry, pri=7, period=NA
  • 129801L: AIS Addressed Safety Related Message, pri=5, period=NA
  • 129802L: AIS Safety Related Broadcast Message, pri=5, period=NA
  • 129803L: AIS Interrogation PGN, pri=7, period=NA
  • 129804L: AIS Assignment Mode Command, pri=7, period=NA
  • 129805L: AIS Data Link Management Message, pri=7, period=NA
  • 129806L: AIS Channel Management, pri=7, period=NA
  • 129807L: AIS Group Assignment, pri=7, period=NA
  • 129808L: DSC Call Information, pri=8, period=NA
  • 129809L: AIS Class B Static Data: Part A, pri=6, period=NA
  • 129810L: AIS Class B Static Data Part B, pri=6, period=NA
  • 129811L: AIS Single Slot Binary Message, pri=5, period=NA
  • 129812L: AIS Multi Slot Binary Message, pri=5, period=NA
  • 129813L: AIS Long-Range Broadcast Message, pri=5, period=NA
  • 130052L: Loran-C TD Data, pri=3, period=1000
  • 130053L: Loran-C Range Data, pri=3, period=1000
  • 130054L: Loran-C Signal Data, pri=3, period=1000
  • 130060L: Label, pri=7, period=NA
  • 130061L: Channel Source Configuration, pri=7, period=NA
  • 130064L: Route and WP Service - Database List, pri=7, period=NA
  • 130065L: Route and WP Service - Route List, pri=7, period=NA
  • 130066L: Route and WP Service - Route/WP-List Attributes, pri=7, period=NA
  • 130067L: Route and WP Service - Route - WP Name & Position, pri=7, period=NA
  • 130068L: Route and WP Service - Route - WP Name, pri=7, period=NA
  • 130069L: Route and WP Service - XTE Limit & Navigation Method, pri=7, period=NA
  • 130070L: Route and WP Service - WP Comment, pri=7, period=NA
  • 130071L: Route and WP Service - Route Comment, pri=7, period=NA
  • 130072L: Route and WP Service - Database Comment, pri=7, period=NA
  • 130073L: Route and WP Service - Radius of Turn, pri=7, period=NA
  • 130074L: Route and WP Service - WP List - WP Name & Position, pri=7, period=NA
  • 130320L: Tide Station Data, pri=6, period=1000
  • 130321L: Salinity Station Data, pri=6, period=1000
  • 130322L: Current Station Data, pri=6, period=1000
  • 130323L: Meteorological Station Data, pri=6, period=1000
  • 130324L: Moored Buoy Station Data, pri=6, period=1000
  • 130330L: Lighting system settings, pri=7, period=NA
  • 130561L: Lighting zone, pri=7, period=NA
  • 130562L: Lighting scene, pri=7, period=NA
  • 130563L: Lighting device, pri=7, period=NA
  • 130564L: Lighting device enumeration, pri=7, period=NA
  • 130565L: Lighting color sequence, pri=7, period=NA
  • 130566L: Lighting program, pri=7, period=NA
  • 130567L: Watermaker input setting and status, pri=6, period=2500
  • 130577L: Direction data PGN, pri=3, period=1000
  • 130578L: Vessel speed components, pri=2, period=250
  • 130569L: Entertainment current file and status, pri=6, period=500
  • 130570L: Entertainment library data file, pri=6, period=NA
  • 130571L: Entertainment library data group, pri=6, period=NA
  • 130572L: Entertainment library data search, pri=6, period=NA
  • 130573L: Entertainment supported source data, pri=6, period=NA
  • 130574L: Entertainment supported zone data, pri=6, period=NA
  • 130580L: Entertainment system configuration status, pri=6, period=NA
  • 130581L: Entertainment zone configuration status, pri=6, period=NA
  • 130583L: Entertainment available dudio EQ presets, pri=6, period=NA
  • 130584L: Entertainment bluetooth devices, pri=6, period=NA
  • 130586L: Entertainment zone configuration status, pri=6, period=NA
false

Definition at line 448 of file NMEA2000.cpp.

◆ IsDefaultSingleFrameMessage()

bool IsDefaultSingleFrameMessage ( unsigned long  PGN)

Checks if the given PGN is a Default Single Frame Message.

Parameters
PGNPGN to be tested
Returns
true -> for PGNs:
  • 126992L: System date/time, pri=3, period=1000
  • 126993L: Heartbeat, pri=7, period=60000
  • 127245L: Rudder, pri=2, period=100
  • 127250L: Vessel Heading, pri=2, period=100
  • 127251L: Rate of Turn, pri=2, period=100
  • 127257L: Attitude, pri=3, period=1000
  • 127488L: Engine parameters rapid, rapid Update, pri=2, period=100
  • 127493L: Transmission parameters: dynamic, pri=2, period=100
  • 127501L: Binary status report, pri=3, period=NA
  • 127505L: Fluid level, pri=6, period=2500
  • 127508L: Battery Status, pri=6, period=1500
  • 128259L: Boat speed, pri=2, period=1000
  • 128267L: Water depth, pri=3, period=1000
  • 129025L: Lat/lon rapid, pri=2, period=100
  • 129026L: COG SOG rapid, pri=2, period=250
  • 129283L: Cross Track Error, pri=3, period=1000
  • 130306L: Wind Speed, pri=2, period=100
  • 130310L: Outside Environmental parameters, pri=5, period=500
  • 130311L: Environmental parameters, pri=5, period=500
  • 130312L: Temperature, pri=5, period=2000
  • 130313L: Humidity, pri=5, period=2000
  • 130314L: Pressure, pri=5, period=2000
  • 130316L: Temperature extended range, pri=5, period=2000
  • 130576L: Small Craft Status (Trim Tab position), pri=2, period=200
false

Definition at line 276 of file NMEA2000.cpp.

◆ IsFastPacketFirstFrame()

bool IsFastPacketFirstFrame ( unsigned char  b)
inline

Definition at line 1971 of file NMEA2000.cpp.

◆ IsFastPacketSystemMessage()

bool IsFastPacketSystemMessage ( unsigned long  PGN)

Checks if the given PGN is a Fast Packet System Message.

Parameters
PGNPGN to be tested
Returns
true -> for PGNs: 65240L, 126208L
false

Definition at line 234 of file NMEA2000.cpp.

◆ IsMandatoryFastPacketMessage()

bool IsMandatoryFastPacketMessage ( unsigned long  PGN)

Checks if the PGN is a Mandatory Fast Packet Message.

Parameters
PGNPGN to be checked
Returns
true -> for PGNs:
  • 126464L: PGN List (Transmit and Receive), pri=6, period=NA
  • 126996L: Product information, pri=6, period=NA
  • 126998L: Configuration information, pri=6, period=NA
false

Definition at line 318 of file NMEA2000.cpp.

◆ IsProprietaryFastPacketMessage()

bool IsProprietaryFastPacketMessage ( unsigned long  PGN)

Checks if the PGN is a Proprietary Fast Packet Message.

Parameters
PGNPGN to be checked
Returns
true -> for PGNs:
  • 126720L
  • 130816L
  • 131071L
false

Definition at line 579 of file NMEA2000.cpp.

◆ IsSingleFrameSystemMessage()

bool IsSingleFrameSystemMessage ( unsigned long  PGN)

Checks if the given PGN is a Single Frame System Message.

Parameters
PGNPGN to be tested
Returns
true -> for PGNs: 59392L, 59904L, 60928L, 60416L, 60160L
false

Definition at line 215 of file NMEA2000.cpp.

◆ N2ktoCanID()

unsigned long N2ktoCanID ( unsigned char  priority,
unsigned long  PGN,
unsigned long  Source,
unsigned char  Destination 
)

Convert NMEA2000 values into a CAN Id.

Parameters
priorityPriority of the N2k message
PGNPGN of the N2k message
SourceSource of the N2k message
DestinationDestination of the N2k message
Returns
unsigned long -> CAN Id

Definition at line 1306 of file NMEA2000.cpp.

◆ ParseN2kPGN126996()

bool ParseN2kPGN126996 ( const tN2kMsg N2kMsg,
unsigned short &  N2kVersion,
unsigned short &  ProductCode,
int  ModelIDSize,
char *  ModelID,
int  SwCodeSize,
char *  SwCode,
int  ModelVersionSize,
char *  ModelVersion,
int  ModelSerialCodeSize,
char *  ModelSerialCode,
unsigned char &  CertificationLevel,
unsigned char &  LoadEquivalency 
)

Parsing the content of message PGN 126996 "Product information".

Provides product information onto the network that could be important for determining quality of data coming from this product.

Parameters
N2kMsgReference to a N2kMsg Object, ready to be send
N2kVersionNMEA Network Message Database Version
ProductCodeNMEA Manufacturer's Product Code
ModelIDSizeSize of ModelID
ModelIDManufacturer's Model ID
SwCodeSizeSize of Software Version Code
SwCodeManufacturer's Software Version Code
ModelVersionSizeSize of Model Version
ModelVersionManufacturer's Model Version
ModelSerialCodeSizeSize of Model Serial Code
ModelSerialCodeManufacturer's Model Serial Code
CertificationLevelNMEA 2000 Certification Level
LoadEquivalencyLoad Equivalency
Return values
trueParsing of PGN Message successful
falseParsing of PGN Message aborted

Definition at line 2788 of file NMEA2000.cpp.

◆ ParseN2kPGN126998()

bool ParseN2kPGN126998 ( const tN2kMsg N2kMsg,
size_t &  ManufacturerInformationSize,
char *  ManufacturerInformation,
size_t &  InstallationDescription1Size,
char *  InstallationDescription1,
size_t &  InstallationDescription2Size,
char *  InstallationDescription2 
)

Parsing the content of message PGN 126998 "Configuration information".

Free-form alphanumeric fields describing the installation (e.g., starboard engine room location) of the device and installation notes (e.g., calibration data).

Parameters
N2kMsgReference to a N2kMsg Object
ManufacturerInformationSizeSize off Manufacturer Information
ManufacturerInformationManufacturer Information
InstallationDescription1SizeSize off Installation Description
InstallationDescription1Installation Description, Field 1
InstallationDescription2SizeSize off Installation Description
InstallationDescription2Installation Description, Field 2
Return values
trueParsing of PGN Message successful
falseParsing of PGN Message aborted

Definition at line 2873 of file NMEA2000.cpp.

◆ ParseN2kPGN59904()

bool ParseN2kPGN59904 ( const tN2kMsg N2kMsg,
unsigned long &  RequestedPGN 
)

Parsing the content of message PGN 59904 "ISO request".

As defined by ISO, this message has a data length of 3 bytes with no padding added to complete the single frame. The appropriate response to this message is based on the PGN being requested, and whether the receiver supports the requested PGN.

Parameters
N2kMsgReference to a N2kMsg Object
RequestedPGNPGN being requested
Return values
trueParsing of PGN Message successful
falseParsing of PGN Message aborted

Definition at line 2894 of file NMEA2000.cpp.

◆ PROGMEM_readAnything()

template<typename T >
void PROGMEM_readAnything ( const T *  sce,
T &  dest 
)

Definition at line 2119 of file NMEA2000.cpp.

◆ ProgmemStrLen()

size_t ProgmemStrLen ( const char *  str)

Definition at line 2808 of file NMEA2000.cpp.

◆ SetN2kPGN126464()

void SetN2kPGN126464 ( tN2kMsg N2kMsg,
uint8_t  Destination,
tN2kPGNList  tr,
const unsigned long *  PGNs 
)

Setting up PGN 126464 Message "PGN List - Transmit PGNs group function".

The PGN List group function type is defined by the first field. The message will be either a Transmit PGNs or a Receive PGNs group function that identifies the PGNs transmitted from or received by a node.

Note
List of PGNs must be null terminated and defined as PROGMEM e.g. const unsigned long TransmitMessages[] PROGMEM={130310L,0};
Parameters
N2kMsgReference to a N2kMsg Object, ready to be send
DestinationAddress of the destination
trTransmit or Receive, see tN2kPGNList
PGNsList of PGNs

Definition at line 2907 of file NMEA2000.cpp.

◆ SetN2kPGN126993()

void SetN2kPGN126993 ( tN2kMsg N2kMsg,
uint32_t  timeInterval_ms,
uint8_t  sequenceCounter 
)

Setting up PGN 126993 Message "Heartbeat".

This PGN shall be transmitted by all NMEA devices. Reception of this PGN confirms that a device is still present on the network. Reception of this PGN may also be used to maintain an address to NAME association table within the receiving device.

Parameters
N2kMsgReference to a N2kMsg Object, ready to be send
timeInterval_mstime interval in msec (0.01 - 655.32s )
sequenceCounterSequence counter

Definition at line 2923 of file NMEA2000.cpp.

◆ SetN2kPGN126996()

void SetN2kPGN126996 ( tN2kMsg N2kMsg,
unsigned int  N2kVersion,
unsigned int  ProductCode,
const char *  ModelID,
const char *  SwCode,
const char *  ModelVersion,
const char *  ModelSerialCode,
unsigned char  CertificationLevel = 1,
unsigned char  LoadEquivalency = 1 
)

Setting up PGN 126996 Message "Product information".

Provides product information onto the network that could be important for determining quality of data coming from this product.

Parameters
N2kMsgReference to a N2kMsg Object, ready to be send
N2kVersionNMEA Network Message Database Version
ProductCodeNMEA Manufacturer's Product Code
ModelIDManufacturer's Model ID
SwCodeManufacturer's Software Version Code
ModelVersionManufacturer's Model Version
ModelSerialCodeManufacturer's Model Serial Code
CertificationLevelNMEA 2000 Certification Level
LoadEquivalencyLoad Equivalency

Definition at line 2771 of file NMEA2000.cpp.

◆ SetN2kPGN126996Progmem()

void SetN2kPGN126996Progmem ( tN2kMsg N2kMsg,
const tNMEA2000::tProductInformation ProductInformation,
char *  OptionalSerialCode = 0 
)

Definition at line 2193 of file NMEA2000.cpp.

◆ SetN2kPGN126998()

void SetN2kPGN126998 ( tN2kMsg N2kMsg,
const char *  ManufacturerInformation,
const char *  InstallationDescription1 = 0,
const char *  InstallationDescription2 = 0,
bool  UsePgm = false 
)

Setting up PGN 126998 Message "Configuration information".

Free-form alphanumeric fields describing the installation (e.g., starboard engine room location) of the device and installation notes (e.g., calibration data).

Parameters
N2kMsgReference to a N2kMsg Object, ready to be send
ManufacturerInformationManufacturer Information
InstallationDescription1Installation Description, Field 1
InstallationDescription2Installation Description, Field 2
UsePgmUse program memory, default = false

Definition at line 2823 of file NMEA2000.cpp.

◆ SetN2kPGN59392()

void SetN2kPGN59392 ( tN2kMsg N2kMsg,
unsigned char  Control,
unsigned char  GroupFunction,
unsigned long  PGN 
)

ISO Acknowledgement.

Setting up PGN 59392 Message "ISO Acknowledgement".

Definition at line 2732 of file NMEA2000.cpp.

◆ SetN2kPGN59904()

void SetN2kPGN59904 ( tN2kMsg N2kMsg,
uint8_t  Destination,
unsigned long  RequestedPGN 
)

Setting up PGN 59904 Message "ISO request".

As defined by ISO, this message has a data length of 3 bytes with no padding added to complete the single frame. The appropriate response to this message is based on the PGN being requested, and whether the receiver supports the requested PGN.

Parameters
N2kMsgReference to a N2kMsg Object, ready to be send
DestinationAddress of the destination
RequestedPGNPGN being requested

Definition at line 2887 of file NMEA2000.cpp.

◆ SetN2kPGN60928() [1/2]

void SetN2kPGN60928 ( tN2kMsg N2kMsg,
uint64_t  Name 
)

Setting up PGN 60928 Message "ISO Address Claim".

This network management message is used to claim a network address and to respond with device information (NAME) requested by the ISO Request or Complex Request Group Function. This PGN contains several fields that are Request Parameters that can be used to control the expected response to requests for this PGN.

Parameters
N2kMsgReference to a N2kMsg Object, ready to be send
NameName of the device

Definition at line 2762 of file NMEA2000.cpp.

◆ SetN2kPGN60928() [2/2]

void SetN2kPGN60928 ( tN2kMsg N2kMsg,
unsigned long  UniqueNumber,
int  ManufacturerCode,
unsigned char  DeviceFunction,
unsigned char  DeviceClass,
unsigned char  DeviceInstance = 0,
unsigned char  SystemInstance = 0,
unsigned char  IndustryGroup = 4 
)

Setting up PGN 60928 Message "ISO Address Claim".

This network management message is used to claim a network address and to respond with device information (NAME) requested by the ISO Request or Complex Request Group Function. This PGN contains several fields that are Request Parameters that can be used to control the expected response to requests for this PGN.

Parameters
N2kMsgReference to a N2kMsg Object, ready to be send
UniqueNumberUnique Number (ISO Identity Number)
ManufacturerCodeManufacturer Code
DeviceFunctionDevice Function (ISO Function)
DeviceClassDevice Class
DeviceInstanceDevice Instance
SystemInstanceSystem Instance (ISO Device Class Instance)
IndustryGroupIndustry Group

Definition at line 2746 of file NMEA2000.cpp.

◆ StrLen()

size_t StrLen ( const char *  str)

Definition at line 2816 of file NMEA2000.cpp.

◆ TPCtsPackets()

unsigned char TPCtsPackets ( unsigned char  nPackets)

Definition at line 1704 of file NMEA2000.cpp.

Variable Documentation

◆ DefInstallationDescription1

const char DefInstallationDescription1[] = ""

Default Installation Description (Field1)

Definition at line 620 of file NMEA2000.cpp.

◆ DefInstallationDescription2

const char DefInstallationDescription2[] = ""

Default Installation Description (Field2)

Definition at line 624 of file NMEA2000.cpp.

◆ DefManufacturerInformation

const char DefManufacturerInformation[] = "NMEA2000 library, https://github.com/ttlappalainen/NMEA2000"

Default Manufacturer Information.

Definition at line 616 of file NMEA2000.cpp.

◆ DefProductInformation

const tNMEA2000::tProductInformation DefProductInformation
Initial value:
= {
2101,
666,
"Arduino N2k->PC",
"1.0.0.0",
"1.0.0",
"00000001",
0,
1
}

Default Product Information.

This structure holds the default Product Information of the device:

  • N2kVersion = 2101
  • ProductCode = 666
  • N2kModelID = Arduino N2k->PC
  • N2kSwCode = 1.0.0.0
  • N2kModelVersion = 1.0.0
  • N2kModelSerialCode = 00000001
  • CertificationLevel = 0
  • LoadEquivalency = 1

Definition at line 602 of file NMEA2000.cpp.

◆ DefReceiveMessages

const unsigned long DefReceiveMessages[]
Initial value:
= {
59392L,
59904L,
60928L,
65240L,
126208L,
0}
#define TP_DT
Multi packet data transfer.
Definition: NMEA2000.cpp:119
#define TP_CM
Multi packet connection management, TP.CM.
Definition: NMEA2000.cpp:117

Default list of Received Messages.

List of default transmit PGNs:

  • 59392L ISO Acknowledgement, pri=6, period=NA
  • 59904L ISO Request, pri=6, period=NA
  • 60416L Multi packet data transfer, TP.DT, pri=6, period=NA
  • 60160L Multi packet connection management, TP.CM, pri=6, period=NA
  • 60928L ISO Address Claim
  • 65240L Commanded Address
  • 126208L NMEA Request/Command/Acknowledge group function

This list is terminated by 0.

Definition at line 194 of file NMEA2000.cpp.

◆ DefTransmitMessages

const unsigned long DefTransmitMessages[]
Initial value:
= {
59392L,
59904L,
60928L,
126208L,
126464L,
126993L,
126996L,
126998L,
0}

Default list of Transmit Messages.

\

List of default transmit PGNs:

  • 59392L ISO Acknowledgement, pri=6, period=NA
  • 59904L ISO Request, pri=6, period=NA
  • 60416L Multi packet data transfer, TP.DT, pri=6, period=NA
  • 60160L Multi packet connection management, TP.CM, pri=6, period=NA
  • 60928L ISO Address Claim, pri=6, period=NA
  • 126208L NMEA Request/Command/Acknowledge group function, pri=3, period=NA
  • 126464L PGN List (Transmit and Receive), pri=6, period=NA
  • 126993L Heartbeat, pri=7, period=60000
  • 126996L Product information, pri=6, period=NA
  • 126998L Configuration information, pri=6, period=NA

This list is terminated by 0.

Definition at line 160 of file NMEA2000.cpp.