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

Go to the source code of this file.

Macros

#define EndOfText   0x03
 
#define Escape   0x10
 
#define MaxActisenseMsgBuf   400
 
#define MsgTypeN2k   0x93
 
#define N2kInt16Min   -32768
 
#define N2kInt16OR   0x7ffe
 
#define N2kInt24Min   -8388608L
 
#define N2kInt24OR   8388606L
 
#define N2kInt32Min   -2147483648L
 
#define N2kInt32OR   0x7ffffffe
 
#define N2kInt8Min   -128
 
#define N2kInt8OR   0x7e
 
#define N2kUInt16OR   0xfffe
 
#define N2kUInt32OR   0xfffffffe
 
#define N2kUInt8OR   0xfe
 
#define StartOfText   0x02
 

Functions

void AddByteEscapedToBuf (unsigned char byteToAdd, uint8_t &idx, unsigned char *buf, int &byteSum)
 
template<>
int16_t byteswap (int16_t val)
 
template<>
int32_t byteswap (int32_t val)
 
template<>
int64_t byteswap (int64_t val)
 
template<>
int8_t byteswap (int8_t val)
 
template<typename T >
byteswap (T val)
 
template<>
uint16_t byteswap (uint16_t val)
 
template<>
uint32_t byteswap (uint32_t val)
 
template<>
uint64_t byteswap (uint64_t val)
 
template<>
uint8_t byteswap (uint8_t val)
 
template<typename T >
GetBuf (size_t len, int &index, const unsigned char *buf)
 
double GetBuf1ByteDouble (double precision, int &index, const unsigned char *buf, double def)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 Extracts the specified numbers of bytes out of the given buffer and converts it to an float value. More...
 
void PrintBuf (N2kStream *port, unsigned char len, const unsigned char *pData, bool AddLF)
 Print out a buffer (byte array) More...
 
double round (double val)
 
template<typename T >
void SetBuf (T v, size_t len, int &index, unsigned char *buf)
 
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, unsigned char fillChar)
 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...
 

Macro Definition Documentation

◆ EndOfText

#define EndOfText   0x03

Definition at line 34 of file N2kMsg.cpp.

◆ Escape

#define Escape   0x10

Definition at line 32 of file N2kMsg.cpp.

◆ MaxActisenseMsgBuf

#define MaxActisenseMsgBuf   400

Definition at line 37 of file N2kMsg.cpp.

◆ MsgTypeN2k

#define MsgTypeN2k   0x93

Definition at line 35 of file N2kMsg.cpp.

◆ N2kInt16Min

#define N2kInt16Min   -32768

Definition at line 582 of file N2kMsg.cpp.

◆ N2kInt16OR

#define N2kInt16OR   0x7ffe

Definition at line 574 of file N2kMsg.cpp.

◆ N2kInt24Min

#define N2kInt24Min   -8388608L

Definition at line 581 of file N2kMsg.cpp.

◆ N2kInt24OR

#define N2kInt24OR   8388606L

Definition at line 580 of file N2kMsg.cpp.

◆ N2kInt32Min

#define N2kInt32Min   -2147483648L

Definition at line 579 of file N2kMsg.cpp.

◆ N2kInt32OR

#define N2kInt32OR   0x7ffffffe

Definition at line 576 of file N2kMsg.cpp.

◆ N2kInt8Min

#define N2kInt8Min   -128

Definition at line 583 of file N2kMsg.cpp.

◆ N2kInt8OR

#define N2kInt8OR   0x7e

Definition at line 572 of file N2kMsg.cpp.

◆ N2kUInt16OR

#define N2kUInt16OR   0xfffe

Definition at line 575 of file N2kMsg.cpp.

◆ N2kUInt32OR

#define N2kUInt32OR   0xfffffffe

Definition at line 577 of file N2kMsg.cpp.

◆ N2kUInt8OR

#define N2kUInt8OR   0xfe

Definition at line 573 of file N2kMsg.cpp.

◆ StartOfText

#define StartOfText   0x02

Definition at line 33 of file N2kMsg.cpp.

Function Documentation

◆ AddByteEscapedToBuf()

void AddByteEscapedToBuf ( unsigned char  byteToAdd,
uint8_t &  idx,
unsigned char *  buf,
int &  byteSum 
)

Definition at line 840 of file N2kMsg.cpp.

◆ byteswap() [1/9]

template<>
int16_t byteswap ( int16_t  val)

Definition at line 485 of file N2kMsg.cpp.

◆ byteswap() [2/9]

template<>
int32_t byteswap ( int32_t  val)

Definition at line 499 of file N2kMsg.cpp.

◆ byteswap() [3/9]

template<>
int64_t byteswap ( int64_t  val)

Definition at line 516 of file N2kMsg.cpp.

◆ byteswap() [4/9]

template<>
int8_t byteswap ( int8_t  val)

Definition at line 475 of file N2kMsg.cpp.

◆ byteswap() [5/9]

template<typename T >
T byteswap ( val)

◆ byteswap() [6/9]

template<>
uint16_t byteswap ( uint16_t  val)

Definition at line 480 of file N2kMsg.cpp.

◆ byteswap() [7/9]

template<>
uint32_t byteswap ( uint32_t  val)

Definition at line 491 of file N2kMsg.cpp.

◆ byteswap() [8/9]

template<>
uint64_t byteswap ( uint64_t  val)

Definition at line 504 of file N2kMsg.cpp.

◆ byteswap() [9/9]

template<>
uint8_t byteswap ( uint8_t  val)

Definition at line 470 of file N2kMsg.cpp.

◆ GetBuf()

template<typename T >
T GetBuf ( size_t  len,
int &  index,
const unsigned char *  buf 
)

Definition at line 522 of file N2kMsg.cpp.

◆ 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.

◆ 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.

◆ round()

double round ( double  val)

Definition at line 52 of file N2kMsg.cpp.

◆ SetBuf()

template<typename T >
void SetBuf ( v,
size_t  len,
int &  index,
unsigned char *  buf 
)

Definition at line 539 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.