NMEA2000 Library
0.1
Library to handle NMEA 2000 Communication written in C++
|
#include "N2kMsg.h"
#include "N2kTimer.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
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 > | |
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 > | |
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... | |
#define EndOfText 0x03 |
Definition at line 34 of file N2kMsg.cpp.
#define Escape 0x10 |
Definition at line 32 of file N2kMsg.cpp.
#define MaxActisenseMsgBuf 400 |
Definition at line 37 of file N2kMsg.cpp.
#define MsgTypeN2k 0x93 |
Definition at line 35 of file N2kMsg.cpp.
#define N2kInt16Min -32768 |
Definition at line 582 of file N2kMsg.cpp.
#define N2kInt16OR 0x7ffe |
Definition at line 574 of file N2kMsg.cpp.
#define N2kInt24Min -8388608L |
Definition at line 581 of file N2kMsg.cpp.
#define N2kInt24OR 8388606L |
Definition at line 580 of file N2kMsg.cpp.
#define N2kInt32Min -2147483648L |
Definition at line 579 of file N2kMsg.cpp.
#define N2kInt32OR 0x7ffffffe |
Definition at line 576 of file N2kMsg.cpp.
#define N2kInt8Min -128 |
Definition at line 583 of file N2kMsg.cpp.
#define N2kInt8OR 0x7e |
Definition at line 572 of file N2kMsg.cpp.
#define N2kUInt16OR 0xfffe |
Definition at line 575 of file N2kMsg.cpp.
#define N2kUInt32OR 0xfffffffe |
Definition at line 577 of file N2kMsg.cpp.
#define N2kUInt8OR 0xfe |
Definition at line 573 of file N2kMsg.cpp.
#define StartOfText 0x02 |
Definition at line 33 of file N2kMsg.cpp.
void AddByteEscapedToBuf | ( | unsigned char | byteToAdd, |
uint8_t & | idx, | ||
unsigned char * | buf, | ||
int & | byteSum | ||
) |
Definition at line 840 of file N2kMsg.cpp.
int16_t byteswap | ( | int16_t | val | ) |
Definition at line 485 of file N2kMsg.cpp.
int32_t byteswap | ( | int32_t | val | ) |
Definition at line 499 of file N2kMsg.cpp.
int64_t byteswap | ( | int64_t | val | ) |
Definition at line 516 of file N2kMsg.cpp.
int8_t byteswap | ( | int8_t | val | ) |
Definition at line 475 of file N2kMsg.cpp.
T byteswap | ( | T | val | ) |
uint16_t byteswap | ( | uint16_t | val | ) |
Definition at line 480 of file N2kMsg.cpp.
uint32_t byteswap | ( | uint32_t | val | ) |
Definition at line 491 of file N2kMsg.cpp.
uint64_t byteswap | ( | uint64_t | val | ) |
Definition at line 504 of file N2kMsg.cpp.
uint8_t byteswap | ( | uint8_t | val | ) |
Definition at line 470 of file N2kMsg.cpp.
T GetBuf | ( | size_t | len, |
int & | index, | ||
const unsigned char * | buf | ||
) |
Definition at line 522 of file N2kMsg.cpp.
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.
precision | the value is rounded to the given precision (e.g. 0.01) |
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 650 of file N2kMsg.cpp.
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.
precision | the value is rounded to the given precision (e.g. 0.01) |
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 658 of file N2kMsg.cpp.
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.
precision | the value is rounded to the given precision (e.g. 0.01) |
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 666 of file N2kMsg.cpp.
int16_t GetBuf2ByteInt | ( | int & | index, |
const unsigned char * | buf | ||
) |
Extracts 2 bytes out of the given buffer and converts it to an integer value.
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
Definition at line 625 of file N2kMsg.cpp.
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.
precision | the value is rounded to the given precision (e.g. 0.01) |
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 674 of file N2kMsg.cpp.
uint16_t GetBuf2ByteUInt | ( | int & | index, |
const unsigned char * | buf | ||
) |
Extracts 2 bytes out of the given buffer and converts it to an integer value.
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
Definition at line 630 of file N2kMsg.cpp.
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.
precision | the value is rounded to the given precision (e.g. 0.01) |
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 717 of file N2kMsg.cpp.
uint32_t GetBuf3ByteUInt | ( | int & | index, |
const unsigned char * | buf | ||
) |
Extracts 3 bytes out of the given buffer and converts it to an integer value.
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
Definition at line 635 of file N2kMsg.cpp.
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.
precision | the value is rounded to the given precision (e.g. 0.01) |
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 725 of file N2kMsg.cpp.
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.
precision | the value is rounded to the given precision (e.g. 0.01) |
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 733 of file N2kMsg.cpp.
uint32_t GetBuf4ByteUInt | ( | int & | index, |
const unsigned char * | buf | ||
) |
Extracts 4 bytes out of the given buffer and converts it to an integer value.
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
Definition at line 640 of file N2kMsg.cpp.
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.
precision | the value is rounded to the given precision (e.g. 0.01) |
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 682 of file N2kMsg.cpp.
uint64_t GetBuf8ByteUInt | ( | int & | index, |
const unsigned char * | buf | ||
) |
Extracts 8 bytes out of the given buffer and converts it to an integer value.
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
Definition at line 645 of file N2kMsg.cpp.
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.
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 690 of file N2kMsg.cpp.
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.
index | position inside the byte array tN2kMsg::Data, getting incremented according to the number of bytes extracted |
buf | Pointer to the byte array buffer |
def | default value that will be returned if the byte array equal to "not available" |
Definition at line 704 of file N2kMsg.cpp.
void PrintBuf | ( | N2kStream * | port, |
unsigned char | len, | ||
const unsigned char * | pData, | ||
bool | AddLF = false |
||
) |
Print out a buffer (byte array)
port | port where to stream, see N2kStream |
len | Number of bytes to be printed |
pData | Pointer to the buffer |
AddLF | true will add a LineFeed at the end |
Definition at line 811 of file N2kMsg.cpp.
double round | ( | double | val | ) |
Definition at line 52 of file N2kMsg.cpp.
void SetBuf | ( | T | v, |
size_t | len, | ||
int & | index, | ||
unsigned char * | buf | ||
) |
Definition at line 539 of file N2kMsg.cpp.
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.
v | {double} Value to be stored in the Buffer |
precision | the value is rounded to the given precision (e.g. 0.01) |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 755 of file N2kMsg.cpp.
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.
v | {double} Value to be stored in the Buffer |
precision | the value is rounded to the given precision (e.g. 0.01) |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 762 of file N2kMsg.cpp.
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.
v | {double} Value to be stored in the Buffer |
precision | the value is rounded to the given precision (e.g. 0.01) |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 741 of file N2kMsg.cpp.
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
v | Value to be stored in the Buffer |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 769 of file N2kMsg.cpp.
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.
v | {double} Value to be stored in the Buffer |
precision | the value is rounded to the given precision (e.g. 0.01) |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 748 of file N2kMsg.cpp.
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
v | Value to be stored in the Buffer |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 774 of file N2kMsg.cpp.
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.
v | {double} Value to be stored in the Buffer |
precision | the value is rounded to the given precision (e.g. 0.01) |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 618 of file N2kMsg.cpp.
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
v | Value to be stored in the Buffer |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 779 of file N2kMsg.cpp.
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.
v | {double} Value to be stored in the Buffer |
precision | the value is rounded to the given precision (e.g. 0.01) |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 604 of file N2kMsg.cpp.
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.
v | {double} Value to be stored in the Buffer |
precision | the value is rounded to the given precision (e.g. 0.01) |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 611 of file N2kMsg.cpp.
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
v | Value to be stored in the Buffer |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 784 of file N2kMsg.cpp.
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.
v | {double} Value to be stored in the Buffer |
precision | the value is rounded to the given precision (e.g. 0.01) |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 586 of file N2kMsg.cpp.
void SetBufDouble | ( | double | v, |
int & | index, | ||
unsigned char * | buf | ||
) |
Writes a double value into a byte array buffer
v | {double} Value to be stored in the Buffer |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 551 of file N2kMsg.cpp.
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.
v | {float} Value to be stored in the Buffer |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 562 of file N2kMsg.cpp.
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.
str | String as pointer to a char array |
len | Length of the string |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
UsePgm | {bool} use the pgm_read_byte function |
fillChar | fill the rest of the buffer with this character |
Definition at line 794 of file N2kMsg.cpp.
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
v | Value to be stored in the Buffer |
index | Position where the value should be placed inside the buffer |
buf | Pointer to the byte array buffer |
Definition at line 789 of file N2kMsg.cpp.