NMEA2000 Library  0.1
Library to handle NMEA 2000 Communication written in C++
N2kMsg.h File Reference

This File contains the class tN2kMsg and all necessary functions to handle a NMEA2000 Message. More...

#include "N2kStream.h"
#include "N2kDef.h"
#include <stdint.h>
Include dependency graph for N2kMsg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Macros

#define BIT(n)   (1 << n)
 

Functions

double GetBuf1ByteDouble (double precision, int &index, const unsigned char *buf, double def=0)
 Extracts the specified numbers of bytes out of the given buffer and converts it to a double value. More...
 
double GetBuf1ByteUDouble (double precision, int &index, const unsigned char *buf, double def=-1)
 Extracts 1 byte out of the given buffer and converts it to a double value. More...
 
double GetBuf2ByteDouble (double precision, int &index, const unsigned char *buf, double def=0)
 Extracts 2 bytes out of the given buffer and converts it to a double value. More...
 
int16_t GetBuf2ByteInt (int &index, const unsigned char *buf)
 Extracts 2 bytes out of the given buffer and converts it to an integer value. More...
 
double GetBuf2ByteUDouble (double precision, int &index, const unsigned char *buf, double def=-1)
 Extracts 2 bytes out of the given buffer and converts it to a double value. More...
 
uint16_t GetBuf2ByteUInt (int &index, const unsigned char *buf)
 Extracts 2 bytes out of the given buffer and converts it to an integer value. More...
 
double GetBuf3ByteDouble (double precision, int &index, const unsigned char *buf, double def=0)
 Extracts 3 bytes out of the given buffer and converts it to a double value. More...
 
uint32_t GetBuf3ByteUInt (int &index, const unsigned char *buf)
 Extracts 3 bytes out of the given buffer and converts it to an integer value. More...
 
double GetBuf4ByteDouble (double precision, int &index, const unsigned char *buf, double def=0)
 Extracts 4 bytes out of the given buffer and converts it to a double value. More...
 
double GetBuf4ByteUDouble (double precision, int &index, const unsigned char *buf, double def=-1)
 Extracts 4 bytes out of the given buffer and converts it to a double value. More...
 
uint32_t GetBuf4ByteUInt (int &index, const unsigned char *buf)
 Extracts 4 bytes out of the given buffer and converts it to an integer value. More...
 
double GetBuf8ByteDouble (double precision, int &index, const unsigned char *buf, double def=0)
 Extracts 8 bytes out of the given buffer and converts it to a double value. More...
 
uint64_t GetBuf8ByteUInt (int &index, const unsigned char *buf)
 Extracts 8 bytes out of the given buffer and converts it to an integer value. More...
 
double GetBufDouble (int &index, const unsigned char *buf, double def=0)
 Extracts bytes out of the given buffer and converts it to a double value. More...
 
float GetBufFloat (int &index, const unsigned char *buf, float def=0)
 Extracts the specified numbers of bytes out of the given buffer and converts it to an float value. More...
 
bool N2kIsNA (double v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (float v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (int16_t v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (int32_t v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (int64_t v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (int8_t v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (uint16_t v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (uint32_t v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (uint64_t v)
 Verify that the specified value is equal to "Not available". More...
 
bool N2kIsNA (uint8_t v)
 Verify that the specified value is equal to "Not available". More...
 
void PrintBuf (N2kStream *port, unsigned char len, const unsigned char *pData, bool AddLF=false)
 Print out a buffer (byte array) More...
 
void SetBuf1ByteDouble (double v, double precision, int &index, unsigned char *buf)
 Writes a double signed value into a byte array buffer using 1 byte. More...
 
void SetBuf1ByteUDouble (double v, double precision, int &index, unsigned char *buf)
 Writes a double unsigned value into a byte array buffer using 1 byte. More...
 
void SetBuf2ByteDouble (double v, double precision, int &index, unsigned char *buf)
 Writes a double signed value into a byte array buffer using 2 bytes. More...
 
void SetBuf2ByteInt (int16_t v, int &index, unsigned char *buf)
 Writes an integer value into a byte array buffer using 2 bytes To write a integer value into a certain position of an byte array buffer the function memcpy is used. More...
 
void SetBuf2ByteUDouble (double v, double precision, int &index, unsigned char *buf)
 Writes a double unsigned value into a byte array buffer using 2 bytes. More...
 
void SetBuf2ByteUInt (uint16_t v, int &index, unsigned char *buf)
 Writes an unsigned integer value into a byte array buffer using 2 bytes. More...
 
void SetBuf3ByteDouble (double v, double precision, int &index, unsigned char *buf)
 Writes a double signed value into a byte array buffer using 3 bytes. More...
 
void SetBuf3ByteInt (int32_t v, int &index, unsigned char *buf)
 Writes an integer value into a byte array buffer using 3 bytes To write a integer value into a certain position of an byte array buffer the function memcpy is used. More...
 
void SetBuf4ByteDouble (double v, double precision, int &index, unsigned char *buf)
 Writes a double signed value into a byte array buffer using 4 bytes. More...
 
void SetBuf4ByteUDouble (double v, double precision, int &index, unsigned char *buf)
 Writes a double unsigned value into a byte array buffer using 4 bytes. More...
 
void SetBuf4ByteUInt (uint32_t v, int &index, unsigned char *buf)
 Writes an unsigned integer value into a byte array buffer u ing 4 bytes To write a integer value into a certain position of an byte array buffer the function memcpy is used. More...
 
void SetBuf8ByteDouble (double v, double precision, int &index, unsigned char *buf)
 Writes a double signed value into a byte array buffer using 8 bytes. More...
 
void SetBufDouble (double v, int &index, unsigned char *buf)
 Writes a double value into a byte array buffer
More...
 
void SetBufFloat (float v, int &index, unsigned char *buf)
 Writes a float value into a byte array buffer. More...
 
void SetBufStr (const char *str, int len, int &index, unsigned char *buf, bool UsePgm=false, unsigned char fillChar=0x0)
 Writes a string into a byte array buffer. More...
 
void SetBufUInt64 (uint64_t v, int &index, unsigned char *buf)
 Writes an unsigned integer 64bit value into a byte array buffer using 8 bytes To write a integer value into a certain position of an byte array buffer the function memcpy is used. More...
 

Variables

const double N2kDoubleNA =-1e9
 Constant "Not Available" for a double value. More...
 
const float N2kFloatNA =-1e9
 Constant "Not Available" for a float value. More...
 
const int16_t N2kInt16NA =0x7fff
 Constant "Not Available" for a signed 16bit int value. More...
 
const int32_t N2kInt32NA =0x7fffffff
 Constant "Not Available" for a signed 32bit int value. More...
 
const int64_t N2kInt64NA =0x7fffffffffffffffLL
 Constant "Not Available" for a signed 64bit int value. More...
 
const int8_t N2kInt8NA =0x7f
 Constant "Not Available" for a signed 8bit value. More...
 
const uint16_t N2kUInt16NA =0xffff
 Constant "Not Available" for a unsigned 16bit int value. More...
 
const uint32_t N2kUInt32NA =0xffffffff
 Constant "Not Available" for a unsigned 32bit int value. More...
 
const uint64_t N2kUInt64NA =0xffffffffffffffffLL
 Constant "Not Available" for a unsigned 64bit int value. More...
 
const uint8_t N2kUInt8NA =0xff
 Constant "Not Available" for a unsigned 8bit int value. More...
 

Detailed Description

This File contains the class tN2kMsg and all necessary functions to handle a 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.
As all the data on the NMEA2000 messages is stored in a byte array, there are plenty of helper functions to inject or extract certain datatypes in and out of this byte array.

See also
Parse and Set Function in N2kMessages.h

Definition in file N2kMsg.h.

Macro Definition Documentation

◆ BIT

#define BIT (   n)    (1 << n)

Definition at line 70 of file N2kMsg.h.

Function Documentation

◆ GetBuf1ByteDouble()

double GetBuf1ByteDouble ( double  precision,
int &  index,
const unsigned char *  buf,
double  def = 0 
)

Extracts the specified numbers of bytes out of the given buffer and converts it to a double value.

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 tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 650 of file N2kMsg.cpp.

◆ GetBuf1ByteUDouble()

double GetBuf1ByteUDouble ( double  precision,
int &  index,
const unsigned char *  buf,
double  def = -1 
)

Extracts 1 byte out of the given buffer and converts it to a double value.

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 tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 658 of file N2kMsg.cpp.

◆ GetBuf2ByteDouble()

double GetBuf2ByteDouble ( double  precision,
int &  index,
const unsigned char *  buf,
double  def = 0 
)

Extracts 2 bytes out of the given buffer and converts it to a double value.

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 tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 666 of file N2kMsg.cpp.

◆ GetBuf2ByteInt()

int16_t GetBuf2ByteInt ( int &  index,
const unsigned char *  buf 
)

Extracts 2 bytes out of the given buffer and converts it to an integer value.

Parameters
indexposition inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
Returns
integer value

Definition at line 625 of file N2kMsg.cpp.

◆ GetBuf2ByteUDouble()

double GetBuf2ByteUDouble ( double  precision,
int &  index,
const unsigned char *  buf,
double  def = -1 
)

Extracts 2 bytes out of the given buffer and converts it to a double value.

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 tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 674 of file N2kMsg.cpp.

◆ GetBuf2ByteUInt()

uint16_t GetBuf2ByteUInt ( int &  index,
const unsigned char *  buf 
)

Extracts 2 bytes out of the given buffer and converts it to an integer value.

Parameters
indexposition inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
Returns
integer value

Definition at line 630 of file N2kMsg.cpp.

◆ GetBuf3ByteDouble()

double GetBuf3ByteDouble ( double  precision,
int &  index,
const unsigned char *  buf,
double  def = 0 
)

Extracts 3 bytes out of the given buffer and converts it to a double value.

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 tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 717 of file N2kMsg.cpp.

◆ GetBuf3ByteUInt()

uint32_t GetBuf3ByteUInt ( int &  index,
const unsigned char *  buf 
)

Extracts 3 bytes out of the given buffer and converts it to an integer value.

Parameters
indexposition inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
Returns
integer value

Definition at line 635 of file N2kMsg.cpp.

◆ GetBuf4ByteDouble()

double GetBuf4ByteDouble ( double  precision,
int &  index,
const unsigned char *  buf,
double  def = 0 
)

Extracts 4 bytes out of the given buffer and converts it to a double value.

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 tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 725 of file N2kMsg.cpp.

◆ GetBuf4ByteUDouble()

double GetBuf4ByteUDouble ( double  precision,
int &  index,
const unsigned char *  buf,
double  def = -1 
)

Extracts 4 bytes out of the given buffer and converts it to a double value.

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 tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 733 of file N2kMsg.cpp.

◆ GetBuf4ByteUInt()

uint32_t GetBuf4ByteUInt ( int &  index,
const unsigned char *  buf 
)

Extracts 4 bytes out of the given buffer and converts it to an integer value.

Parameters
indexposition inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
Returns
integer value

Definition at line 640 of file N2kMsg.cpp.

◆ GetBuf8ByteDouble()

double GetBuf8ByteDouble ( double  precision,
int &  index,
const unsigned char *  buf,
double  def = 0 
)

Extracts 8 bytes out of the given buffer and converts it to a double value.

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 tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 682 of file N2kMsg.cpp.

◆ GetBuf8ByteUInt()

uint64_t GetBuf8ByteUInt ( int &  index,
const unsigned char *  buf 
)

Extracts 8 bytes out of the given buffer and converts it to an integer value.

Parameters
indexposition inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
Returns
integer value

Definition at line 645 of file N2kMsg.cpp.

◆ GetBufDouble()

double GetBufDouble ( int &  index,
const unsigned char *  buf,
double  def = 0 
)

Extracts bytes out of the given buffer and converts it to a double value.

The fixed point integer mechanism is used.

Parameters
indexposition inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
double value

Definition at line 690 of file N2kMsg.cpp.

◆ GetBufFloat()

float GetBufFloat ( int &  index,
const unsigned char *  buf,
float  def = 0 
)

Extracts the specified numbers of bytes out of the given buffer and converts it to an float value.

Parameters
indexposition inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted
bufPointer to the byte array buffer
defdefault value that will be returned if the byte array equal to "not available"
Returns
float value

Definition at line 704 of file N2kMsg.cpp.

◆ N2kIsNA() [1/10]

bool N2kIsNA ( double  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{double} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 80 of file N2kMsg.h.

◆ N2kIsNA() [2/10]

bool N2kIsNA ( float  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{float} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 89 of file N2kMsg.h.

◆ N2kIsNA() [3/10]

bool N2kIsNA ( int16_t  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{int16_t} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 125 of file N2kMsg.h.

◆ N2kIsNA() [4/10]

bool N2kIsNA ( int32_t  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{int32_t} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 143 of file N2kMsg.h.

◆ N2kIsNA() [5/10]

bool N2kIsNA ( int64_t  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{int64_t} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 161 of file N2kMsg.h.

◆ N2kIsNA() [6/10]

bool N2kIsNA ( int8_t  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{int8_t} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 107 of file N2kMsg.h.

◆ N2kIsNA() [7/10]

bool N2kIsNA ( uint16_t  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{uint16_t} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 116 of file N2kMsg.h.

◆ N2kIsNA() [8/10]

bool N2kIsNA ( uint32_t  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{uint32_t} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 134 of file N2kMsg.h.

◆ N2kIsNA() [9/10]

bool N2kIsNA ( uint64_t  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{uint64_t} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 152 of file N2kMsg.h.

◆ N2kIsNA() [10/10]

bool N2kIsNA ( uint8_t  v)
inline

Verify that the specified value is equal to "Not available".

Parameters
v{uint8_t} Value to be verified
Returns
true: Value equal to "Not available"
false: Value not equal to "Not available"

Definition at line 98 of file N2kMsg.h.

◆ PrintBuf()

void PrintBuf ( N2kStream port,
unsigned char  len,
const unsigned char *  pData,
bool  AddLF = false 
)

Print out a buffer (byte array)

Parameters
portport where to stream, see N2kStream
lenNumber of bytes to be printed
pDataPointer to the buffer
AddLFtrue will add a LineFeed at the end

Definition at line 811 of file N2kMsg.cpp.

◆ SetBuf1ByteDouble()

void SetBuf1ByteDouble ( double  v,
double  precision,
int &  index,
unsigned char *  buf 
)

Writes a double signed value into a byte array buffer using 1 byte.

To write a double value into a certain position of an byte array buffer the function memcpy is used. Out of range will be handled. So if given value can not be converted to fixed integer, "out of range" constant will be set.

There are different functions depending on how many byte should be used in the buffer. The fixed point integer mechanism is used.

Parameters
v{double} Value to be stored in the Buffer
precisionthe value is rounded to the given precision (e.g. 0.01)
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 755 of file N2kMsg.cpp.

◆ SetBuf1ByteUDouble()

void SetBuf1ByteUDouble ( double  v,
double  precision,
int &  index,
unsigned char *  buf 
)

Writes a double unsigned value into a byte array buffer using 1 byte.

To write a double value into a certain position of an byte array buffer the function memcpy is used. Out of range will be handled. So if given value can not be converted to fixed integer, "out of range" constant will be set.

There are different functions depending on how many byte should be used in the buffer. The fixed point integer mechanism is used.

Parameters
v{double} Value to be stored in the Buffer
precisionthe value is rounded to the given precision (e.g. 0.01)
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 762 of file N2kMsg.cpp.

◆ SetBuf2ByteDouble()

void SetBuf2ByteDouble ( double  v,
double  precision,
int &  index,
unsigned char *  buf 
)

Writes a double signed value into a byte array buffer using 2 bytes.

To write a double value into a certain position of an byte array buffer the function memcpy is used. Out of range will be handled. So if given value can not be converted to fixed integer, "out of range" constant will be set.

There are different functions depending on how many byte should be used in the buffer. The fixed point integer mechanism is used.

Parameters
v{double} Value to be stored in the Buffer
precisionthe value is rounded to the given precision (e.g. 0.01)
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 741 of file N2kMsg.cpp.

◆ SetBuf2ByteInt()

void SetBuf2ByteInt ( int16_t  v,
int &  index,
unsigned char *  buf 
)

Writes an integer value into a byte array buffer using 2 bytes To write a integer value into a certain position of an byte array buffer the function memcpy is used.

There are different functions depending on how many byte should be used in the buffer

Parameters
vValue to be stored in the Buffer
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 769 of file N2kMsg.cpp.

◆ SetBuf2ByteUDouble()

void SetBuf2ByteUDouble ( double  v,
double  precision,
int &  index,
unsigned char *  buf 
)

Writes a double unsigned value into a byte array buffer using 2 bytes.

To write a double value into a certain position of an byte array buffer the function memcpy is used. Out of range will be handled. So if given value can not be converted to fixed integer, "out of range" constant will be set.

There are different functions depending on how many byte should be used in the buffer. The fixed point integer mechanism is used.

Parameters
v{double} Value to be stored in the Buffer
precisionthe value is rounded to the given precision (e.g. 0.01)
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 748 of file N2kMsg.cpp.

◆ SetBuf2ByteUInt()

void SetBuf2ByteUInt ( uint16_t  v,
int &  index,
unsigned char *  buf 
)

Writes an unsigned integer value into a byte array buffer using 2 bytes.

To write a integer value into a certain position of an byte array buffer the function memcpy is used.

There are different functions depending on how many byte should be used in the buffer

Parameters
vValue to be stored in the Buffer
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 774 of file N2kMsg.cpp.

◆ SetBuf3ByteDouble()

void SetBuf3ByteDouble ( double  v,
double  precision,
int &  index,
unsigned char *  buf 
)

Writes a double signed value into a byte array buffer using 3 bytes.

To write a double value into a certain position of an byte array buffer the function memcpy is used. Out of range will be handled. So if given value can not be converted to fixed integer, "out of range" constant will be set.

There are different functions depending on how many byte should be used in the buffer. The fixed point integer mechanism is used.

Parameters
v{double} Value to be stored in the Buffer
precisionthe value is rounded to the given precision (e.g. 0.01)
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 618 of file N2kMsg.cpp.

◆ SetBuf3ByteInt()

void SetBuf3ByteInt ( int32_t  v,
int &  index,
unsigned char *  buf 
)

Writes an integer value into a byte array buffer using 3 bytes To write a integer value into a certain position of an byte array buffer the function memcpy is used.

There are different functions depending on how many byte should be used in the buffer

Parameters
vValue to be stored in the Buffer
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 779 of file N2kMsg.cpp.

◆ SetBuf4ByteDouble()

void SetBuf4ByteDouble ( double  v,
double  precision,
int &  index,
unsigned char *  buf 
)

Writes a double signed value into a byte array buffer using 4 bytes.

To write a double value into a certain position of an byte array buffer the function memcpy is used. Out of range will be handled. So if given value can not be converted to fixed integer, "out of range" constant will be set.

There are different functions depending on how many byte should be used in the buffer. The fixed point integer mechanism is used.

Parameters
v{double} Value to be stored in the Buffer
precisionthe value is rounded to the given precision (e.g. 0.01)
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 604 of file N2kMsg.cpp.

◆ SetBuf4ByteUDouble()

void SetBuf4ByteUDouble ( double  v,
double  precision,
int &  index,
unsigned char *  buf 
)

Writes a double unsigned value into a byte array buffer using 4 bytes.

To write a double value into a certain position of an byte array buffer the function memcpy is used. Out of range will be handled. So if given value can not be converted to fixed integer, "out of range" constant will be set.

There are different functions depending on how many byte should be used in the buffer. The fixed point integer mechanism is used.

Parameters
v{double} Value to be stored in the Buffer
precisionthe value is rounded to the given precision (e.g. 0.01)
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 611 of file N2kMsg.cpp.

◆ SetBuf4ByteUInt()

void SetBuf4ByteUInt ( uint32_t  v,
int &  index,
unsigned char *  buf 
)

Writes an unsigned integer value into a byte array buffer u ing 4 bytes To write a integer value into a certain position of an byte array buffer the function memcpy is used.

There are different functions depending on how many byte should be used in the buffer

Parameters
vValue to be stored in the Buffer
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 784 of file N2kMsg.cpp.

◆ SetBuf8ByteDouble()

void SetBuf8ByteDouble ( double  v,
double  precision,
int &  index,
unsigned char *  buf 
)

Writes a double signed value into a byte array buffer using 8 bytes.

To write a double value into a certain position of an byte array buffer the function memcpy is used. Out of range will be handled. So if given value can not be converted to fixed integer, "out of range" constant will be set.

There are different functions depending on how many byte should be used in the buffer. The fixed point integer mechanism is used.

Parameters
v{double} Value to be stored in the Buffer
precisionthe value is rounded to the given precision (e.g. 0.01)
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 586 of file N2kMsg.cpp.

◆ SetBufDouble()

void SetBufDouble ( double  v,
int &  index,
unsigned char *  buf 
)

Writes a double value into a byte array buffer

Parameters
v{double} Value to be stored in the Buffer
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 551 of file N2kMsg.cpp.

◆ SetBufFloat()

void SetBufFloat ( float  v,
int &  index,
unsigned char *  buf 
)

Writes a float value into a byte array buffer.

To write a float value into a certain position of an byte array buffer the function memcpy is used. If the value represents "not available", the corresponding constant is copied into the buffer.

Parameters
v{float} Value to be stored in the Buffer
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 562 of file N2kMsg.cpp.

◆ SetBufStr()

void SetBufStr ( const char *  str,
int  len,
int &  index,
unsigned char *  buf,
bool  UsePgm = false,
unsigned char  fillChar = 0x0 
)

Writes a string into a byte array buffer.

Parameters
strString as pointer to a char array
lenLength of the string
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer
UsePgm{bool} use the pgm_read_byte function
fillCharfill the rest of the buffer with this character

Definition at line 794 of file N2kMsg.cpp.

◆ SetBufUInt64()

void SetBufUInt64 ( uint64_t  v,
int &  index,
unsigned char *  buf 
)

Writes an unsigned integer 64bit value into a byte array buffer using 8 bytes To write a integer value into a certain position of an byte array buffer the function memcpy is used.

There are different functions depending on how many byte should be used in the buffer

Parameters
vValue to be stored in the Buffer
indexPosition where the value should be placed inside the buffer
bufPointer to the byte array buffer

Definition at line 789 of file N2kMsg.cpp.

Variable Documentation

◆ N2kDoubleNA

const double N2kDoubleNA =-1e9

Constant "Not Available" for a double value.

Definition at line 49 of file N2kMsg.h.

◆ N2kFloatNA

const float N2kFloatNA =-1e9

Constant "Not Available" for a float value.

Definition at line 51 of file N2kMsg.h.

◆ N2kInt16NA

const int16_t N2kInt16NA =0x7fff

Constant "Not Available" for a signed 16bit int value.

Definition at line 59 of file N2kMsg.h.

◆ N2kInt32NA

const int32_t N2kInt32NA =0x7fffffff

Constant "Not Available" for a signed 32bit int value.

Definition at line 63 of file N2kMsg.h.

◆ N2kInt64NA

const int64_t N2kInt64NA =0x7fffffffffffffffLL

Constant "Not Available" for a signed 64bit int value.

Definition at line 67 of file N2kMsg.h.

◆ N2kInt8NA

const int8_t N2kInt8NA =0x7f

Constant "Not Available" for a signed 8bit value.

Definition at line 55 of file N2kMsg.h.

◆ N2kUInt16NA

const uint16_t N2kUInt16NA =0xffff

Constant "Not Available" for a unsigned 16bit int value.

Definition at line 57 of file N2kMsg.h.

◆ N2kUInt32NA

const uint32_t N2kUInt32NA =0xffffffff

Constant "Not Available" for a unsigned 32bit int value.

Definition at line 61 of file N2kMsg.h.

◆ N2kUInt64NA

const uint64_t N2kUInt64NA =0xffffffffffffffffLL

Constant "Not Available" for a unsigned 64bit int value.

Definition at line 65 of file N2kMsg.h.

◆ N2kUInt8NA

const uint8_t N2kUInt8NA =0xff

Constant "Not Available" for a unsigned 8bit int value.

Definition at line 53 of file N2kMsg.h.