NMEA2000 Library  0.1
Library to handle NMEA 2000 Communication written in C++
tN2kMsg Class Reference

This class contains all the data of an NMEA2000 message. More...

#include <N2kMsg.h>

Public Member Functions

 tN2kMsg (unsigned char _Source=15, unsigned char _Priority=6, unsigned long _PGN=0, int _DataLen=0)
 Construct a new t N2k Msg object. More...
 
void Add1ByteDouble (double v, double precision, double UndefVal=N2kDoubleNA)
 Add double value to the buffer using 1 byte. More...
 
void Add1ByteUDouble (double v, double precision, double UndefVal=N2kDoubleNA)
 Add double value to the buffer using 1 byte. More...
 
void Add2ByteDouble (double v, double precision, double UndefVal=N2kDoubleNA)
 Add double value to the buffer using 2 bytes. More...
 
void Add2ByteInt (int16_t v)
 Add integer value to the buffer using 2 bytes The value will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void Add2ByteUDouble (double v, double precision, double UndefVal=N2kDoubleNA)
 Add double value to the buffer using 2 bytes. More...
 
void Add2ByteUInt (uint16_t v)
 Add unsigned integer value to the buffer using 2 bytes The value will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void Add3ByteDouble (double v, double precision, double UndefVal=N2kDoubleNA)
 Add double value to the buffer using 3 bytes. More...
 
void Add3ByteInt (int32_t v)
 Add integer value to the buffer using 3 bytes The value will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void Add4ByteDouble (double v, double precision, double UndefVal=N2kDoubleNA)
 Add double value to the buffer using 4 bytes. More...
 
void Add4ByteUDouble (double v, double precision, double UndefVal=N2kDoubleNA)
 Add double value to the buffer using 4 bytes. More...
 
void Add4ByteUInt (uint32_t v)
 Add unsigned integer value to the buffer using 4 bytes The value will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void Add8ByteDouble (double v, double precision, double UndefVal=N2kDoubleNA)
 Add double value to the buffer using 8 bytes. More...
 
void AddAISStr (const char *str, int len)
 Add string value to the buffer after filtering characters as defined in ITU-R M.1371-1 The string will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void AddBuf (const void *buf, size_t bufLen)
 Add byte array to the buffer. More...
 
void AddByte (unsigned char v)
 Add byte value to the buffer The byte will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void AddFloat (float v, float UndefVal=N2kFloatNA)
 Add float value to the buffer This method adds a float value to the message buffer using SetBufFloat The value will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void AddStr (const char *str, int len, bool UsePgm=false, unsigned char fillChar=0xff)
 Add string value to the buffer The string will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void AddUInt64 (uint64_t v)
 Add unsigned integer value to the buffer using 8 bytes The value will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void AddVarStr (const char *str, bool UsePgm=false)
 Add string value to the buffer This method determines the length of the string by it self using strlen(). The string will be added to the end (indicated by DataLen) of the byte array Data. More...
 
void CheckDestination () const
 Validation check for the message destination We can send to specified destination only for PGN:s low byte=0. More...
 
virtual void Clear ()
 Clears the content of the N2kMsg object The method sets the PGN, DataLen and MsgTime to zero. More...
 
void ForceSource (unsigned char _Source) const
 Set the Source of the message. More...
 
double Get1ByteDouble (double precision, int &Index, double def=N2kDoubleNA) const
 Get a double from 1 bytes out of Data The fixed point integer mechanism is used. More...
 
double Get1ByteUDouble (double precision, int &Index, double def=N2kDoubleNA) const
 Get a double from 1 bytes out of Data The fixed point integer mechanism is used. More...
 
double Get2ByteDouble (double precision, int &Index, double def=N2kDoubleNA) const
 Get a double from 2 bytes out of Data The fixed point integer mechanism is used. More...
 
int16_t Get2ByteInt (int &Index, int16_t def=0x7fff) const
 Get an integer from 2 bytes out of Data. More...
 
double Get2ByteUDouble (double precision, int &Index, double def=N2kDoubleNA) const
 Get a double from 2 bytes out of Data The fixed point integer mechanism is used. More...
 
uint16_t Get2ByteUInt (int &Index, uint16_t def=0xffff) const
 Get an unsigned integer from 2 bytes out of Data. More...
 
double Get3ByteDouble (double precision, int &Index, double def=N2kDoubleNA) const
 Get a double from 3 bytes out of Data The fixed point integer mechanism is used. More...
 
uint32_t Get3ByteUInt (int &Index, uint32_t def=0xffffffff) const
 Get an unsigned integer from 3 bytes out of Data. More...
 
double Get4ByteDouble (double precision, int &Index, double def=N2kDoubleNA) const
 Get a double from 4 bytes out of Data The fixed point integer mechanism is used. More...
 
double Get4ByteUDouble (double precision, int &Index, double def=N2kDoubleNA) const
 Get a double from 4 bytes out of Data The fixed point integer mechanism is used. More...
 
uint32_t Get4ByteUInt (int &Index, uint32_t def=0xffffffff) const
 Get an unsigned integer from 4 bytes out of Data. More...
 
double Get8ByteDouble (double precision, int &Index, double def=N2kDoubleNA) const
 Get a double from 8 bytes out of Data The fixed point integer mechanism is used. More...
 
int GetAvailableDataLength () const
 Get the Available Data Length The method calculates the available data length with MaxDataLen - DataLen. More...
 
bool GetBuf (void *buf, size_t Length, int &Index) const
 Get a byte array out of Data. More...
 
unsigned char GetByte (int &Index) const
 Get the value from a byte out of Data. More...
 
float GetFloat (int &Index, float def=N2kFloatNA) const
 Get a float out of Data. More...
 
int GetRemainingDataLength (int Index) const
 Get the Remaining Data Length. More...
 
bool GetStr (char *StrBuf, size_t Length, int &Index) const
 Get a string out of Data. More...
 
bool GetStr (size_t StrBufSize, char *StrBuf, size_t Length, unsigned char nulChar, int &Index) const
 Get a string out of Data. More...
 
uint64_t GetUInt64 (int &Index, uint64_t def=0xffffffffffffffffULL) const
 Get an unsigned integer from 8 bytes out of Data. More...
 
bool GetVarStr (size_t &StrBufSize, char *StrBuf, int &Index) const
 Get a string out of Data This method determines the length of the string by it self, using the byte (index -2) inside Data. More...
 
void Init (unsigned char _Priority, unsigned long _PGN, unsigned char _Source, unsigned char _Destination=0xff)
 Initialisation of the N2kMsg object. More...
 
bool IsTPMessage () const
 Determine if the message is flagged as MultiPacket Message. More...
 
bool IsValid () const
 Checks if the Message Meta Content is valid Basic check if the message object is valid, mean datalen >0 and PGN != 0. More...
 
void Print (N2kStream *port, bool NoData=false) const
 Print out the whole content of the N2kMsg Object. More...
 
void SendInActisenseFormat (N2kStream *port) const
 Print out the whole content of the N2kMsg Object using the Actisense Format. More...
 
bool Set2ByteUInt (uint16_t v, int &Index)
 Set a 2byte unsigned integer in Data. More...
 
bool SetByte (uint8_t v, int &Index)
 Set a byte in Data. More...
 
void SetIsTPMessage (bool tp=true)
 Set the MultiPacket Message status. More...
 
void SetPGN (unsigned long _PGN)
 Set the Parameter Group Number of the message *. More...
 

Public Attributes

unsigned char Data [MaxDataLen]
 Byte array which carries all the data of the NMEA2000 message. More...
 
int DataLen
 Number of bytes already stored in tN2kMsg::Data of this message. More...
 
unsigned char Destination
 Destination of the NMEA2000 message. More...
 
unsigned long MsgTime
 timestamp (ms since start [max 49days]) of the NMEA2000 message More...
 
unsigned long PGN
 Parameter Group Number (PGN) of the NMEA2000 message. More...
 
unsigned char Priority
 Priority of the NMEA2000 message. More...
 
unsigned char Source
 Source of the NMEA2000 message. More...
 

Static Public Attributes

static const int MaxDataLen =223
 Maximum number of bytes that can be stored in the data buffer With fast packet the first frame can have 6 byte and rest 31 frames 7 bytes. More...
 

Protected Member Functions

void ResetData ()
 Fills the whole data buffer with 0xff. More...
 

Protected Attributes

bool TPMessage
 Message is a MultiPacket Message. More...
 

Detailed Description

This class contains all the data of an NMEA2000 message.

The class tN2kMsg holds all necessary data of an NMEA2000 message. An object of this class will be passed to the SetN2kPGNxxxx function and there it is "filled" with the corresponding data. To extract data out of a NMEA2000 message, the ParseN2kPGNxxxx functions can be used.

See also
N2kMessages.h

Definition at line 655 of file N2kMsg.h.

Constructor & Destructor Documentation

◆ tN2kMsg()

tN2kMsg::tN2kMsg ( unsigned char  _Source = 15,
unsigned char  _Priority = 6,
unsigned long  _PGN = 0,
int  _DataLen = 0 
)

Construct a new t N2k Msg object.

Parameters
_SourceSource address of the NMEA2000 device sending this message [range 0 .. 251] default = 15
_PriorityPriority of the Message [0 .. 7] default = 6
_PGNParameter Group Number [decimal]
_DataLenLength off the data field

Definition at line 60 of file N2kMsg.cpp.

Member Function Documentation

◆ Add1ByteDouble()

void tN2kMsg::Add1ByteDouble ( double  v,
double  precision,
double  UndefVal = N2kDoubleNA 
)

Add double value to the buffer using 1 byte.

The fixed point integer mechanism is used. The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
vvalue to add
UndefVal"not available" value

Definition at line 165 of file N2kMsg.cpp.

◆ Add1ByteUDouble()

void tN2kMsg::Add1ByteUDouble ( double  v,
double  precision,
double  UndefVal = N2kDoubleNA 
)

Add double value to the buffer using 1 byte.

The fixed point integer mechanism is used. The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
vvalue to add
UndefVal"not available" value

Definition at line 174 of file N2kMsg.cpp.

◆ Add2ByteDouble()

void tN2kMsg::Add2ByteDouble ( double  v,
double  precision,
double  UndefVal = N2kDoubleNA 
)

Add double value to the buffer using 2 bytes.

The fixed point integer mechanism is used. The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
vvalue to add
UndefVal"not available" value

Definition at line 147 of file N2kMsg.cpp.

◆ Add2ByteInt()

void tN2kMsg::Add2ByteInt ( int16_t  v)

Add integer value to the buffer using 2 bytes The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
vvalue to add

Definition at line 183 of file N2kMsg.cpp.

◆ Add2ByteUDouble()

void tN2kMsg::Add2ByteUDouble ( double  v,
double  precision,
double  UndefVal = N2kDoubleNA 
)

Add double value to the buffer using 2 bytes.

The fixed point integer mechanism is used. The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
vvalue to add
UndefVal"not available" value

Definition at line 156 of file N2kMsg.cpp.

◆ Add2ByteUInt()

void tN2kMsg::Add2ByteUInt ( uint16_t  v)

Add unsigned integer value to the buffer using 2 bytes The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
vvalue to add

Definition at line 188 of file N2kMsg.cpp.

◆ Add3ByteDouble()

void tN2kMsg::Add3ByteDouble ( double  v,
double  precision,
double  UndefVal = N2kDoubleNA 
)

Add double value to the buffer using 3 bytes.

The fixed point integer mechanism is used. The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
vvalue to add
UndefVal"not available" value

Definition at line 138 of file N2kMsg.cpp.

◆ Add3ByteInt()

void tN2kMsg::Add3ByteInt ( int32_t  v)

Add integer value to the buffer using 3 bytes The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
vvalue to add

Definition at line 193 of file N2kMsg.cpp.

◆ Add4ByteDouble()

void tN2kMsg::Add4ByteDouble ( double  v,
double  precision,
double  UndefVal = N2kDoubleNA 
)

Add double value to the buffer using 4 bytes.

The fixed point integer mechanism is used. The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
vvalue to add
UndefVal"not available" value

Definition at line 120 of file N2kMsg.cpp.

◆ Add4ByteUDouble()

void tN2kMsg::Add4ByteUDouble ( double  v,
double  precision,
double  UndefVal = N2kDoubleNA 
)

Add double value to the buffer using 4 bytes.

The fixed point integer mechanism is used. The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
vvalue to add
UndefVal"not available" value

Definition at line 129 of file N2kMsg.cpp.

◆ Add4ByteUInt()

void tN2kMsg::Add4ByteUInt ( uint32_t  v)

Add unsigned integer value to the buffer using 4 bytes The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
vvalue to add

Definition at line 198 of file N2kMsg.cpp.

◆ Add8ByteDouble()

void tN2kMsg::Add8ByteDouble ( double  v,
double  precision,
double  UndefVal = N2kDoubleNA 
)

Add double value to the buffer using 8 bytes.

The fixed point integer mechanism is used. The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
vvalue to add
UndefVal"not available" value

Definition at line 110 of file N2kMsg.cpp.

◆ AddAISStr()

void tN2kMsg::AddAISStr ( const char *  str,
int  len 
)

Add string value to the buffer after filtering characters as defined in ITU-R M.1371-1 The string will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
strString as pointer to a char array
lenLength of the string

Definition at line 221 of file N2kMsg.cpp.

◆ AddBuf()

void tN2kMsg::AddBuf ( const void *  buf,
size_t  bufLen 
)

Add byte array to the buffer.

The buffer will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
bufPointer to the byte array
bufLenNumber of bytes to add

Definition at line 242 of file N2kMsg.cpp.

◆ AddByte()

void tN2kMsg::AddByte ( unsigned char  v)

Add byte value to the buffer The byte will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
vvalue to add

Definition at line 208 of file N2kMsg.cpp.

◆ AddFloat()

void tN2kMsg::AddFloat ( float  v,
float  UndefVal = N2kFloatNA 
)

Add float value to the buffer This method adds a float value to the message buffer using SetBufFloat The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
vvalue to add
UndefVal"not available" value

Definition at line 101 of file N2kMsg.cpp.

◆ AddStr()

void tN2kMsg::AddStr ( const char *  str,
int  len,
bool  UsePgm = false,
unsigned char  fillChar = 0xff 
)

Add string value to the buffer The string will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
strString as pointer to a char array
lenLength of the string
UsePgm{bool} use the pgm_read_byte function
fillCharcharacter to for padding at end of strings

Definition at line 213 of file N2kMsg.cpp.

◆ AddUInt64()

void tN2kMsg::AddUInt64 ( uint64_t  v)

Add unsigned integer value to the buffer using 8 bytes The value will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
vvalue to add

Definition at line 203 of file N2kMsg.cpp.

◆ AddVarStr()

void tN2kMsg::AddVarStr ( const char *  str,
bool  UsePgm = false 
)

Add string value to the buffer This method determines the length of the string by it self using strlen(). The string will be added to the end (indicated by DataLen) of the byte array Data.

Parameters
strString as pointer to a char array
UsePgm{bool} use the pgm_read_byte function

Definition at line 234 of file N2kMsg.cpp.

◆ CheckDestination()

void tN2kMsg::CheckDestination ( ) const
inline

Validation check for the message destination We can send to specified destination only for PGN:s low byte=0.

  • PGN 060928 (0xEE00 ) ISO Address Claim
  • PGN 059392 (0xE800) - ISO Acknowledgment
  • ...

Definition at line 734 of file N2kMsg.h.

◆ Clear()

void tN2kMsg::Clear ( )
virtual

Clears the content of the N2kMsg object The method sets the PGN, DataLen and MsgTime to zero.

Definition at line 94 of file N2kMsg.cpp.

◆ ForceSource()

void tN2kMsg::ForceSource ( unsigned char  _Source) const
inline

Set the Source of the message.

Parameters
_SourceSource address of the NMEA2000 device sending this message [range 0 .. 251] default = 15

Definition at line 725 of file N2kMsg.h.

◆ Get1ByteDouble()

double tN2kMsg::Get1ByteDouble ( double  precision,
int &  Index,
double  def = N2kDoubleNA 
) const

Get a double from 1 bytes out of Data The fixed point integer mechanism is used.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
double value

Definition at line 296 of file N2kMsg.cpp.

◆ Get1ByteUDouble()

double tN2kMsg::Get1ByteUDouble ( double  precision,
int &  Index,
double  def = N2kDoubleNA 
) const

Get a double from 1 bytes out of Data The fixed point integer mechanism is used.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
double value

Definition at line 303 of file N2kMsg.cpp.

◆ Get2ByteDouble()

double tN2kMsg::Get2ByteDouble ( double  precision,
int &  Index,
double  def = N2kDoubleNA 
) const

Get a double from 2 bytes out of Data The fixed point integer mechanism is used.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
double value

Definition at line 310 of file N2kMsg.cpp.

◆ Get2ByteInt()

int16_t tN2kMsg::Get2ByteInt ( int &  Index,
int16_t  def = 0x7fff 
) const

Get an integer from 2 bytes out of Data.

Parameters
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
integer value

Definition at line 261 of file N2kMsg.cpp.

◆ Get2ByteUDouble()

double tN2kMsg::Get2ByteUDouble ( double  precision,
int &  Index,
double  def = N2kDoubleNA 
) const

Get a double from 2 bytes out of Data The fixed point integer mechanism is used.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
double value

Definition at line 317 of file N2kMsg.cpp.

◆ Get2ByteUInt()

uint16_t tN2kMsg::Get2ByteUInt ( int &  Index,
uint16_t  def = 0xffff 
) const

Get an unsigned integer from 2 bytes out of Data.

Parameters
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
integer value

Definition at line 268 of file N2kMsg.cpp.

◆ Get3ByteDouble()

double tN2kMsg::Get3ByteDouble ( double  precision,
int &  Index,
double  def = N2kDoubleNA 
) const

Get a double from 3 bytes out of Data The fixed point integer mechanism is used.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
double value

Definition at line 324 of file N2kMsg.cpp.

◆ Get3ByteUInt()

uint32_t tN2kMsg::Get3ByteUInt ( int &  Index,
uint32_t  def = 0xffffffff 
) const

Get an unsigned integer from 3 bytes out of Data.

Parameters
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
integer value

Definition at line 275 of file N2kMsg.cpp.

◆ Get4ByteDouble()

double tN2kMsg::Get4ByteDouble ( double  precision,
int &  Index,
double  def = N2kDoubleNA 
) const

Get a double from 4 bytes out of Data The fixed point integer mechanism is used.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
double value

Definition at line 331 of file N2kMsg.cpp.

◆ Get4ByteUDouble()

double tN2kMsg::Get4ByteUDouble ( double  precision,
int &  Index,
double  def = N2kDoubleNA 
) const

Get a double from 4 bytes out of Data The fixed point integer mechanism is used.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
double value

Definition at line 338 of file N2kMsg.cpp.

◆ Get4ByteUInt()

uint32_t tN2kMsg::Get4ByteUInt ( int &  Index,
uint32_t  def = 0xffffffff 
) const

Get an unsigned integer from 4 bytes out of Data.

Parameters
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
integer value

Definition at line 282 of file N2kMsg.cpp.

◆ Get8ByteDouble()

double tN2kMsg::Get8ByteDouble ( double  precision,
int &  Index,
double  def = N2kDoubleNA 
) const

Get a double from 8 bytes out of Data The fixed point integer mechanism is used.

Parameters
precisionthe value is rounded to the given precision (e.g. 0.01)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
double value

Definition at line 345 of file N2kMsg.cpp.

◆ GetAvailableDataLength()

int tN2kMsg::GetAvailableDataLength ( ) const
inline

Get the Available Data Length The method calculates the available data length with MaxDataLen - DataLen.

Returns
int Available Data Length

Definition at line 778 of file N2kMsg.h.

◆ GetBuf()

bool tN2kMsg::GetBuf ( void *  buf,
size_t  Length,
int &  Index 
) const

Get a byte array out of Data.

Parameters
bufPointer to byte array
LengthLength of byte array to be extracted
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
Returns
true data has been extracted
false not successful, no data available

Definition at line 430 of file N2kMsg.cpp.

◆ GetByte()

unsigned char tN2kMsg::GetByte ( int &  Index) const

Get the value from a byte out of Data.

Parameters
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
Returns
value represented in the byte array

Definition at line 254 of file N2kMsg.cpp.

◆ GetFloat()

float tN2kMsg::GetFloat ( int &  Index,
float  def = N2kFloatNA 
) const

Get a float out of Data.

Parameters
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
integer value

Definition at line 352 of file N2kMsg.cpp.

◆ GetRemainingDataLength()

int tN2kMsg::GetRemainingDataLength ( int  Index) const
inline

Get the Remaining Data Length.

Parameters
IndexPosition inside the buffer
Returns
int - Remaining Data length

Definition at line 769 of file N2kMsg.h.

◆ GetStr() [1/2]

bool tN2kMsg::GetStr ( char *  StrBuf,
size_t  Length,
int &  Index 
) const

Get a string out of Data.

Parameters
StrBufPointer to a char array as string
LengthLength of the string
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
Returns
true String data has been extracted
false not successful, no string data available

Definition at line 359 of file N2kMsg.cpp.

◆ GetStr() [2/2]

bool tN2kMsg::GetStr ( size_t  StrBufSize,
char *  StrBuf,
size_t  Length,
unsigned char  nulChar,
int &  Index 
) const

Get a string out of Data.

Parameters
StrBufSizeSize of String Buffer
StrBufPointer to a char array as string
LengthLength of the string
nulCharused "null Char" in the message (e.g. '@' in AIS)
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
Returns
true String data has been extracted
false not successful, no string data available

Definition at line 385 of file N2kMsg.cpp.

◆ GetUInt64()

uint64_t tN2kMsg::GetUInt64 ( int &  Index,
uint64_t  def = 0xffffffffffffffffULL 
) const

Get an unsigned integer from 8 bytes out of Data.

Parameters
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
defdefault value when data is unavailable
Returns
integer value

Definition at line 289 of file N2kMsg.cpp.

◆ GetVarStr()

bool tN2kMsg::GetVarStr ( size_t &  StrBufSize,
char *  StrBuf,
int &  Index 
) const

Get a string out of Data This method determines the length of the string by it self, using the byte (index -2) inside Data.

Parameters
StrBufSizeSize of String Buffer
StrBufPointer to a char array as string
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
Returns
true String data has been extracted
false not successful, no string data available

Definition at line 416 of file N2kMsg.cpp.

◆ Init()

void tN2kMsg::Init ( unsigned char  _Priority,
unsigned long  _PGN,
unsigned char  _Source,
unsigned char  _Destination = 0xff 
)

Initialisation of the N2kMsg object.

Parameters
_PriorityPriority of the Message [0 .. 7]
_PGNParameter Group Number [decimal]
_SourceSource address of the NMEA2000 device sending this message [range 0 .. 251]
_DestinationDestination address of the NMEA2000 device sending this message [range 0 .. 251]

Definition at line 75 of file N2kMsg.cpp.

◆ IsTPMessage()

bool tN2kMsg::IsTPMessage ( ) const
inline

Determine if the message is flagged as MultiPacket Message.

Returns
true Message is a MultiPacket Message
false Message is not a MultiPacket Message

Definition at line 699 of file N2kMsg.h.

◆ IsValid()

bool tN2kMsg::IsValid ( ) const
inline

Checks if the Message Meta Content is valid Basic check if the message object is valid, mean datalen >0 and PGN != 0.

Returns
true message is valid
false message is not valid

Definition at line 760 of file N2kMsg.h.

◆ Print()

void tN2kMsg::Print ( N2kStream port,
bool  NoData = false 
) const

Print out the whole content of the N2kMsg Object.

Parameters
portport where to stream, see N2kStream
NoDataif true the data buffer will not be printed

Definition at line 824 of file N2kMsg.cpp.

◆ ResetData()

void tN2kMsg::ResetData ( )
protected

Fills the whole data buffer with 0xff.

Definition at line 87 of file N2kMsg.cpp.

◆ SendInActisenseFormat()

void tN2kMsg::SendInActisenseFormat ( N2kStream port) const

Print out the whole content of the N2kMsg Object using the Actisense Format.

Parameters
portport where to stream, see N2kStream

Definition at line 853 of file N2kMsg.cpp.

◆ Set2ByteUInt()

bool tN2kMsg::Set2ByteUInt ( uint16_t  v,
int &  Index 
)

Set a 2byte unsigned integer in Data.

Parameters
vValue to add
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
Returns
true success
false Index is grater then DataLen

Definition at line 457 of file N2kMsg.cpp.

◆ SetByte()

bool tN2kMsg::SetByte ( uint8_t  v,
int &  Index 
)

Set a byte in Data.

Parameters
vValue to add
Indexposition inside the byte array Data, getting incremented according to the number of bytes extracted
Returns
true success
false Index is grater then DataLen

Definition at line 447 of file N2kMsg.cpp.

◆ SetIsTPMessage()

void tN2kMsg::SetIsTPMessage ( bool  tp = true)
inline

Set the MultiPacket Message status.

Parameters
tp{bool} true if message is an MultiPacket Message

Definition at line 692 of file N2kMsg.h.

◆ SetPGN()

void tN2kMsg::SetPGN ( unsigned long  _PGN)

Set the Parameter Group Number of the message *.

Parameters
_PGNParameter Group Number [decimal]

Definition at line 68 of file N2kMsg.cpp.

Member Data Documentation

◆ Data

unsigned char tN2kMsg::Data[MaxDataLen]

Byte array which carries all the data of the NMEA2000 message.

Definition at line 675 of file N2kMsg.h.

◆ DataLen

int tN2kMsg::DataLen

Number of bytes already stored in tN2kMsg::Data of this message.

Definition at line 673 of file N2kMsg.h.

◆ Destination

unsigned char tN2kMsg::Destination
mutable

Destination of the NMEA2000 message.

Definition at line 671 of file N2kMsg.h.

◆ MaxDataLen

const int tN2kMsg::MaxDataLen =223
static

Maximum number of bytes that can be stored in the data buffer With fast packet the first frame can have 6 byte and rest 31 frames 7 bytes.

Definition at line 663 of file N2kMsg.h.

◆ MsgTime

unsigned long tN2kMsg::MsgTime

timestamp (ms since start [max 49days]) of the NMEA2000 message

Definition at line 677 of file N2kMsg.h.

◆ PGN

unsigned long tN2kMsg::PGN

Parameter Group Number (PGN) of the NMEA2000 message.

Definition at line 667 of file N2kMsg.h.

◆ Priority

unsigned char tN2kMsg::Priority

Priority of the NMEA2000 message.

Definition at line 665 of file N2kMsg.h.

◆ Source

unsigned char tN2kMsg::Source
mutable

Source of the NMEA2000 message.

Definition at line 669 of file N2kMsg.h.

◆ TPMessage

bool tN2kMsg::TPMessage
protected

Message is a MultiPacket Message.

Definition at line 685 of file N2kMsg.h.


The documentation for this class was generated from the following files: