NMEA2000 Library  0.1
Library to handle NMEA 2000 Communication written in C++
N2kMsg.h
Go to the documentation of this file.
1/*
2 * N2kMsg.h
3 *
4 * Copyright (c) 2015-2024 Timo Lappalainen, Kave Oy, www.kave.fi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22*/
23
24/**************************************************************************/
41#ifndef _tN2kMsg_H_
42#define _tN2kMsg_H_
43
44#include "N2kStream.h"
45#include "N2kDef.h"
46#include <stdint.h>
47
49const double N2kDoubleNA=-1e9;
51const float N2kFloatNA=-1e9;
53const uint8_t N2kUInt8NA=0xff;
55const int8_t N2kInt8NA=0x7f;
57const uint16_t N2kUInt16NA=0xffff;
59const int16_t N2kInt16NA=0x7fff;
61const uint32_t N2kUInt32NA=0xffffffff;
63const int32_t N2kInt32NA=0x7fffffff;
65const uint64_t N2kUInt64NA=0xffffffffffffffffLL;
67const int64_t N2kInt64NA=0x7fffffffffffffffLL;
68
69#ifndef BIT
70#define BIT(n) (1 << n)
71#endif
72
73/**************************************************************************/
80inline bool N2kIsNA(double v) { return v==N2kDoubleNA; }
81
82/**************************************************************************/
89inline bool N2kIsNA(float v) { return v==N2kFloatNA; }
90
91/**************************************************************************/
98inline bool N2kIsNA(uint8_t v) { return v==N2kUInt8NA; }
99
100/**************************************************************************/
107inline bool N2kIsNA(int8_t v) { return v==N2kInt8NA; }
108
109/**************************************************************************/
116inline bool N2kIsNA(uint16_t v) { return v==N2kUInt16NA; }
117
118/**************************************************************************/
125inline bool N2kIsNA(int16_t v) { return v==N2kInt16NA; }
126
127/**************************************************************************/
134inline bool N2kIsNA(uint32_t v) { return v==N2kUInt32NA; }
135
136/**************************************************************************/
143inline bool N2kIsNA(int32_t v) { return v==N2kInt32NA; }
144
145/**************************************************************************/
152inline bool N2kIsNA(uint64_t v) { return v==N2kUInt64NA; }
153
154/**************************************************************************/
161inline bool N2kIsNA(int64_t v) { return v==N2kInt64NA; }
162
163/**************************************************************************/
174void SetBufFloat(float v, int &index, unsigned char *buf);
175
176/**************************************************************************/
184void SetBufDouble(double v, int &index, unsigned char *buf);
185
186
187/**************************************************************************/
203void SetBuf8ByteDouble(double v, double precision, int &index, unsigned char *buf);
204
205/**************************************************************************/
221void SetBuf4ByteDouble(double v, double precision, int &index, unsigned char *buf);
222
223/**************************************************************************/
239void SetBuf4ByteUDouble(double v, double precision, int &index, unsigned char *buf);
240
241/**************************************************************************/
257void SetBuf3ByteDouble(double v, double precision, int &index, unsigned char *buf);
258
259/**************************************************************************/
275void SetBuf2ByteDouble(double v, double precision, int &index, unsigned char *buf);
276
277/**************************************************************************/
293void SetBuf2ByteUDouble(double v, double precision, int &index, unsigned char *buf);
294
295/**************************************************************************/
311void SetBuf1ByteDouble(double v, double precision, int &index, unsigned char *buf);
312
313/**************************************************************************/
329void SetBuf1ByteUDouble(double v, double precision, int &index, unsigned char *buf);
330
331/**************************************************************************/
343void SetBuf2ByteInt(int16_t v, int &index, unsigned char *buf);
344
345/**************************************************************************/
359void SetBuf2ByteUInt(uint16_t v, int &index, unsigned char *buf);
360
361/**************************************************************************/
373void SetBuf3ByteInt(int32_t v, int &index, unsigned char *buf);
374
375/**************************************************************************/
388void SetBuf4ByteUInt(uint32_t v, int &index, unsigned char *buf);
389
390/**************************************************************************/
403void SetBufUInt64(uint64_t v, int &index, unsigned char *buf);
404
405/**************************************************************************/
415void SetBufStr(const char *str, int len, int &index, unsigned char *buf, bool UsePgm=false, unsigned char fillChar=0x0);
416
417/**************************************************************************/
427int16_t GetBuf2ByteInt(int &index, const unsigned char *buf);
428
429/**************************************************************************/
439uint16_t GetBuf2ByteUInt(int &index, const unsigned char *buf);
440
441/**************************************************************************/
451uint32_t GetBuf3ByteUInt(int &index, const unsigned char *buf);
452
453/**************************************************************************/
463uint32_t GetBuf4ByteUInt(int &index, const unsigned char *buf);
464
465/**************************************************************************/
475uint64_t GetBuf8ByteUInt(int &index, const unsigned char *buf);
476
477/**************************************************************************/
492double GetBuf1ByteDouble(double precision, int &index, const unsigned char *buf, double def=0);
493
494/**************************************************************************/
509double GetBuf1ByteUDouble(double precision, int &index, const unsigned char *buf, double def=-1);
510
511/**************************************************************************/
526double GetBuf2ByteDouble(double precision, int &index, const unsigned char *buf, double def=0);
527
528/**************************************************************************/
543double GetBuf2ByteUDouble(double precision, int &index, const unsigned char *buf, double def=-1);
544
545/**************************************************************************/
560double GetBuf3ByteDouble(double precision, int &index, const unsigned char *buf, double def=0);
561
562/**************************************************************************/
577double GetBuf4ByteDouble(double precision, int &index, const unsigned char *buf, double def=0);
578
579/**************************************************************************/
594double GetBuf4ByteUDouble(double precision, int &index, const unsigned char *buf, double def=-1);
595
596/**************************************************************************/
611double GetBuf8ByteDouble(double precision, int &index, const unsigned char *buf, double def=0);
612
613/**************************************************************************/
627double GetBufDouble(int &index, const unsigned char *buf, double def=0);
628
629/**************************************************************************/
641float GetBufFloat(int &index, const unsigned char *buf, float def=0);
642
643/**************************************************************************/
656{
657public:
658 /************************************************************************/
663 static const int MaxDataLen=223;
665 unsigned char Priority;
667 unsigned long PGN;
669 mutable unsigned char Source;
671 mutable unsigned char Destination;
675 unsigned char Data[MaxDataLen];
677 unsigned long MsgTime;
678protected:
680 void ResetData();
681
682#if !defined(N2K_NO_ISO_MULTI_PACKET_SUPPORT)
683protected:
686public:
687
688 /************************************************************************/
692 void SetIsTPMessage(bool tp=true) { TPMessage=tp; }
693
694 /************************************************************************/
699 bool IsTPMessage() const { return TPMessage; }
700
701#endif
702public:
703 /************************************************************************/
712 tN2kMsg(unsigned char _Source=15, unsigned char _Priority=6, unsigned long _PGN=0, int _DataLen=0);
713
714 /************************************************************************/
718 void SetPGN(unsigned long _PGN);
719
720 /************************************************************************/
725 void ForceSource(unsigned char _Source) const { Source=_Source; }
726
727 /************************************************************************/
734 void CheckDestination() const { if ( (PGN & 0xff)!=0 ) Destination=0xff; }
735
736 /************************************************************************/
746 void Init(unsigned char _Priority, unsigned long _PGN, unsigned char _Source, unsigned char _Destination=0xff);
747
748 /************************************************************************/
752 virtual void Clear();
753
754 /************************************************************************/
760 bool IsValid() const { return (PGN!=0 && DataLen>0); }
761
762 /************************************************************************/
769 int GetRemainingDataLength(int Index) const { return DataLen>Index?DataLen-Index:0; }
770
771 /************************************************************************/
779
780 /************************************************************************/
788 void AddFloat(float v, float UndefVal=N2kFloatNA);
789
790 /************************************************************************/
801 void Add8ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA);
802
803 /************************************************************************/
814 void Add4ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA);
815
816 /************************************************************************/
827 void Add4ByteUDouble(double v, double precision, double UndefVal=N2kDoubleNA);
828
829 /************************************************************************/
840 void Add3ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA);
841
842 /************************************************************************/
853 void Add2ByteUDouble(double v, double precision, double UndefVal=N2kDoubleNA);
854
855 /************************************************************************/
866 void Add2ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA);
867
868 /************************************************************************/
879 void Add1ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA);
880
881 /************************************************************************/
892 void Add1ByteUDouble(double v, double precision, double UndefVal=N2kDoubleNA);
893
894 /************************************************************************/
900 void Add2ByteInt(int16_t v);
901
902 /************************************************************************/
908 void Add2ByteUInt(uint16_t v);
909
910 /************************************************************************/
916 void Add3ByteInt(int32_t v);
917
918 /************************************************************************/
924 void Add4ByteUInt(uint32_t v);
925
926 /************************************************************************/
932 void AddUInt64(uint64_t v);
933
934 /************************************************************************/
940 void AddByte(unsigned char v);
941
942 /************************************************************************/
951 void AddStr(const char *str, int len, bool UsePgm=false, unsigned char fillChar=0xff);
952
953 /************************************************************************/
960 void AddAISStr(const char *str, int len);
961
962 /************************************************************************/
971 void AddVarStr(const char *str, bool UsePgm=false);
972
973 /************************************************************************/
982 void AddBuf(const void *buf, size_t bufLen);
983
984 /************************************************************************/
992 unsigned char GetByte(int &Index) const;
993
994 /************************************************************************/
1003 int16_t Get2ByteInt(int &Index, int16_t def=0x7fff) const;
1004
1005 /************************************************************************/
1014 uint16_t Get2ByteUInt(int &Index, uint16_t def=0xffff) const;
1015
1016 /************************************************************************/
1025 uint32_t Get3ByteUInt(int &Index, uint32_t def=0xffffffff) const;
1026
1027 /************************************************************************/
1036 uint32_t Get4ByteUInt(int &Index, uint32_t def=0xffffffff) const;
1037
1038 /************************************************************************/
1047 uint64_t GetUInt64(int &Index, uint64_t def=0xffffffffffffffffULL) const;
1048
1049 /************************************************************************/
1060 double Get1ByteDouble(double precision, int &Index, double def=N2kDoubleNA) const;
1061
1062 /************************************************************************/
1073 double Get1ByteUDouble(double precision, int &Index, double def=N2kDoubleNA) const;
1074
1075 /************************************************************************/
1086 double Get2ByteDouble(double precision, int &Index, double def=N2kDoubleNA) const;
1087
1088 /************************************************************************/
1099 double Get2ByteUDouble(double precision, int &Index, double def=N2kDoubleNA) const;
1100
1101 /************************************************************************/
1112 double Get3ByteDouble(double precision, int &Index, double def=N2kDoubleNA) const;
1113
1114 /************************************************************************/
1125 double Get4ByteDouble(double precision, int &Index, double def=N2kDoubleNA) const;
1126
1127 /************************************************************************/
1138 double Get4ByteUDouble(double precision, int &Index, double def=N2kDoubleNA) const;
1139
1140 /************************************************************************/
1151 double Get8ByteDouble(double precision, int &Index, double def=N2kDoubleNA) const;
1152
1153 /************************************************************************/
1162 float GetFloat(int &Index, float def=N2kFloatNA) const;
1163
1164 /************************************************************************/
1176 bool GetStr(char *StrBuf, size_t Length, int &Index) const;
1177
1178 /************************************************************************/
1192 bool GetStr(size_t StrBufSize, char *StrBuf, size_t Length, unsigned char nulChar, int &Index) const;
1193
1194 /************************************************************************/
1208 bool GetVarStr(size_t &StrBufSize, char *StrBuf, int &Index) const;
1209
1210 /************************************************************************/
1221 bool GetBuf(void *buf, size_t Length, int &Index) const;
1222
1223 /************************************************************************/
1233 bool SetByte(uint8_t v, int &Index);
1234
1235 /************************************************************************/
1245 bool Set2ByteUInt(uint16_t v, int &Index);
1246
1247 /************************************************************************/
1253 void Print(N2kStream *port, bool NoData=false) const;
1254
1255 /************************************************************************/
1261 void SendInActisenseFormat(N2kStream *port) const;
1262};
1263
1264/************************************************************************/
1272void PrintBuf(N2kStream *port, unsigned char len, const unsigned char *pData, bool AddLF=false);
1273
1274#endif
Type definitions and utility macros used in the NMEA2000 libraries.
const uint32_t N2kUInt32NA
Constant "Not Available" for a unsigned 32bit int value.
Definition: N2kMsg.h:61
void SetBufDouble(double v, int &index, unsigned char *buf)
Writes a double value into a byte array buffer
Definition: N2kMsg.cpp:551
uint16_t GetBuf2ByteUInt(int &index, const unsigned char *buf)
Extracts 2 bytes out of the given buffer and converts it to an integer value.
Definition: N2kMsg.cpp:630
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.
Definition: N2kMsg.cpp:650
void PrintBuf(N2kStream *port, unsigned char len, const unsigned char *pData, bool AddLF=false)
Print out a buffer (byte array)
Definition: N2kMsg.cpp:811
int16_t GetBuf2ByteInt(int &index, const unsigned char *buf)
Extracts 2 bytes out of the given buffer and converts it to an integer value.
Definition: N2kMsg.cpp:625
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 certai...
Definition: N2kMsg.cpp:769
const double N2kDoubleNA
Constant "Not Available" for a double value.
Definition: N2kMsg.h:49
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.
Definition: N2kMsg.cpp:717
void SetBuf2ByteUDouble(double v, double precision, int &index, unsigned char *buf)
Writes a double unsigned value into a byte array buffer using 2 bytes.
Definition: N2kMsg.cpp:748
const uint64_t N2kUInt64NA
Constant "Not Available" for a unsigned 64bit int value.
Definition: N2kMsg.h:65
const int8_t N2kInt8NA
Constant "Not Available" for a signed 8bit value.
Definition: N2kMsg.h:55
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.
Definition: N2kMsg.cpp:682
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.
Definition: N2kMsg.cpp:725
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.
Definition: N2kMsg.cpp:690
void SetBuf3ByteDouble(double v, double precision, int &index, unsigned char *buf)
Writes a double signed value into a byte array buffer using 3 bytes.
Definition: N2kMsg.cpp:618
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.
Definition: N2kMsg.cpp:794
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.
Definition: N2kMsg.cpp:704
const int16_t N2kInt16NA
Constant "Not Available" for a signed 16bit int value.
Definition: N2kMsg.h:59
void SetBuf2ByteDouble(double v, double precision, int &index, unsigned char *buf)
Writes a double signed value into a byte array buffer using 2 bytes.
Definition: N2kMsg.cpp:741
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.
Definition: N2kMsg.cpp:658
const int64_t N2kInt64NA
Constant "Not Available" for a signed 64bit int value.
Definition: N2kMsg.h:67
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.
Definition: N2kMsg.cpp:733
void SetBufFloat(float v, int &index, unsigned char *buf)
Writes a float value into a byte array buffer.
Definition: N2kMsg.cpp:562
uint64_t GetBuf8ByteUInt(int &index, const unsigned char *buf)
Extracts 8 bytes out of the given buffer and converts it to an integer value.
Definition: N2kMsg.cpp:645
void SetBuf4ByteDouble(double v, double precision, int &index, unsigned char *buf)
Writes a double signed value into a byte array buffer using 4 bytes.
Definition: N2kMsg.cpp:604
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.
Definition: N2kMsg.cpp:674
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 valu...
Definition: N2kMsg.cpp:789
const int32_t N2kInt32NA
Constant "Not Available" for a signed 32bit int value.
Definition: N2kMsg.h:63
const float N2kFloatNA
Constant "Not Available" for a float value.
Definition: N2kMsg.h:51
void SetBuf4ByteUDouble(double v, double precision, int &index, unsigned char *buf)
Writes a double unsigned value into a byte array buffer using 4 bytes.
Definition: N2kMsg.cpp:611
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 certai...
Definition: N2kMsg.cpp:779
const uint16_t N2kUInt16NA
Constant "Not Available" for a unsigned 16bit int value.
Definition: N2kMsg.h:57
const uint8_t N2kUInt8NA
Constant "Not Available" for a unsigned 8bit int value.
Definition: N2kMsg.h:53
void SetBuf2ByteUInt(uint16_t v, int &index, unsigned char *buf)
Writes an unsigned integer value into a byte array buffer using 2 bytes.
Definition: N2kMsg.cpp:774
void SetBuf8ByteDouble(double v, double precision, int &index, unsigned char *buf)
Writes a double signed value into a byte array buffer using 8 bytes.
Definition: N2kMsg.cpp:586
void SetBuf1ByteUDouble(double v, double precision, int &index, unsigned char *buf)
Writes a double unsigned value into a byte array buffer using 1 byte.
Definition: N2kMsg.cpp:762
uint32_t GetBuf4ByteUInt(int &index, const unsigned char *buf)
Extracts 4 bytes out of the given buffer and converts it to an integer value.
Definition: N2kMsg.cpp:640
bool N2kIsNA(double v)
Verify that the specified value is equal to "Not available".
Definition: N2kMsg.h:80
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...
Definition: N2kMsg.cpp:784
void SetBuf1ByteDouble(double v, double precision, int &index, unsigned char *buf)
Writes a double signed value into a byte array buffer using 1 byte.
Definition: N2kMsg.cpp:755
uint32_t GetBuf3ByteUInt(int &index, const unsigned char *buf)
Extracts 3 bytes out of the given buffer and converts it to an integer value.
Definition: N2kMsg.cpp:635
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.
Definition: N2kMsg.cpp:666
This File contains an I/O stream used in the NMEA2000 libraries.
Streaming Class to handle all Streams generated by the Library.
Definition: N2kStream.h:60
This class contains all the data of an NMEA2000 message.
Definition: N2kMsg.h:656
unsigned char Data[MaxDataLen]
Byte array which carries all the data of the NMEA2000 message.
Definition: N2kMsg.h:675
void Add2ByteUDouble(double v, double precision, double UndefVal=N2kDoubleNA)
Add double value to the buffer using 2 bytes.
Definition: N2kMsg.cpp:156
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 ...
Definition: N2kMsg.cpp:101
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...
Definition: N2kMsg.cpp:213
void Add2ByteUInt(uint16_t v)
Add unsigned integer value to the buffer using 2 bytes The value will be added to the end (indicated ...
Definition: N2kMsg.cpp:188
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.
Definition: N2kMsg.cpp:324
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.
Definition: N2kMsg.cpp:331
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.
Definition: N2kMsg.cpp:296
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,...
Definition: N2kMsg.cpp:416
void Add4ByteUDouble(double v, double precision, double UndefVal=N2kDoubleNA)
Add double value to the buffer using 4 bytes.
Definition: N2kMsg.cpp:129
void Add2ByteInt(int16_t v)
Add integer value to the buffer using 2 bytes The value will be added to the end (indicated by DataLe...
Definition: N2kMsg.cpp:183
int GetRemainingDataLength(int Index) const
Get the Remaining Data Length.
Definition: N2kMsg.h:769
void Add4ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA)
Add double value to the buffer using 4 bytes.
Definition: N2kMsg.cpp:120
void Add3ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA)
Add double value to the buffer using 3 bytes.
Definition: N2kMsg.cpp:138
bool IsTPMessage() const
Determine if the message is flagged as MultiPacket Message.
Definition: N2kMsg.h:699
bool IsValid() const
Checks if the Message Meta Content is valid Basic check if the message object is valid,...
Definition: N2kMsg.h:760
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 arr...
Definition: N2kMsg.cpp:208
void ResetData()
Fills the whole data buffer with 0xff.
Definition: N2kMsg.cpp:87
void Add2ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA)
Add double value to the buffer using 2 bytes.
Definition: N2kMsg.cpp:147
void Add1ByteUDouble(double v, double precision, double UndefVal=N2kDoubleNA)
Add double value to the buffer using 1 byte.
Definition: N2kMsg.cpp:174
bool Set2ByteUInt(uint16_t v, int &Index)
Set a 2byte unsigned integer in Data.
Definition: N2kMsg.cpp:457
void Add1ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA)
Add double value to the buffer using 1 byte.
Definition: N2kMsg.cpp:165
void ForceSource(unsigned char _Source) const
Set the Source of the message.
Definition: N2kMsg.h:725
void Print(N2kStream *port, bool NoData=false) const
Print out the whole content of the N2kMsg Object.
Definition: N2kMsg.cpp:824
void AddUInt64(uint64_t v)
Add unsigned integer value to the buffer using 8 bytes The value will be added to the end (indicated ...
Definition: N2kMsg.cpp:203
void AddBuf(const void *buf, size_t bufLen)
Add byte array to the buffer.
Definition: N2kMsg.cpp:242
uint16_t Get2ByteUInt(int &Index, uint16_t def=0xffff) const
Get an unsigned integer from 2 bytes out of Data.
Definition: N2kMsg.cpp:268
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.
Definition: N2kMsg.cpp:310
unsigned char Source
Source of the NMEA2000 message.
Definition: N2kMsg.h:669
void Add8ByteDouble(double v, double precision, double UndefVal=N2kDoubleNA)
Add double value to the buffer using 8 bytes.
Definition: N2kMsg.cpp:110
static const int MaxDataLen
Maximum number of bytes that can be stored in the data buffer With fast packet the first frame can ha...
Definition: N2kMsg.h:663
float GetFloat(int &Index, float def=N2kFloatNA) const
Get a float out of Data.
Definition: N2kMsg.cpp:352
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.
Definition: N2kMsg.cpp:317
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 strle...
Definition: N2kMsg.cpp:234
unsigned char Priority
Priority of the NMEA2000 message.
Definition: N2kMsg.h:665
bool SetByte(uint8_t v, int &Index)
Set a byte in Data.
Definition: N2kMsg.cpp:447
uint32_t Get3ByteUInt(int &Index, uint32_t def=0xffffffff) const
Get an unsigned integer from 3 bytes out of Data.
Definition: N2kMsg.cpp:275
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.
Definition: N2kMsg.cpp:303
void Add3ByteInt(int32_t v)
Add integer value to the buffer using 3 bytes The value will be added to the end (indicated by DataLe...
Definition: N2kMsg.cpp:193
virtual void Clear()
Clears the content of the N2kMsg object The method sets the PGN, DataLen and MsgTime to zero.
Definition: N2kMsg.cpp:94
unsigned long MsgTime
timestamp (ms since start [max 49days]) of the NMEA2000 message
Definition: N2kMsg.h:677
void Add4ByteUInt(uint32_t v)
Add unsigned integer value to the buffer using 4 bytes The value will be added to the end (indicated ...
Definition: N2kMsg.cpp:198
void CheckDestination() const
Validation check for the message destination We can send to specified destination only for PGN:s low ...
Definition: N2kMsg.h:734
bool TPMessage
Message is a MultiPacket Message.
Definition: N2kMsg.h:685
void SetPGN(unsigned long _PGN)
Set the Parameter Group Number of the message *.
Definition: N2kMsg.cpp:68
unsigned char GetByte(int &Index) const
Get the value from a byte out of Data.
Definition: N2kMsg.cpp:254
uint64_t GetUInt64(int &Index, uint64_t def=0xffffffffffffffffULL) const
Get an unsigned integer from 8 bytes out of Data.
Definition: N2kMsg.cpp:289
int16_t Get2ByteInt(int &Index, int16_t def=0x7fff) const
Get an integer from 2 bytes out of Data.
Definition: N2kMsg.cpp:261
bool GetBuf(void *buf, size_t Length, int &Index) const
Get a byte array out of Data.
Definition: N2kMsg.cpp:430
int GetAvailableDataLength() const
Get the Available Data Length The method calculates the available data length with MaxDataLen - DataL...
Definition: N2kMsg.h:778
bool GetStr(char *StrBuf, size_t Length, int &Index) const
Get a string out of Data.
Definition: N2kMsg.cpp:359
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 wil...
Definition: N2kMsg.cpp:221
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.
Definition: N2kMsg.cpp:338
void Init(unsigned char _Priority, unsigned long _PGN, unsigned char _Source, unsigned char _Destination=0xff)
Initialisation of the N2kMsg object.
Definition: N2kMsg.cpp:75
void SetIsTPMessage(bool tp=true)
Set the MultiPacket Message status.
Definition: N2kMsg.h:692
tN2kMsg(unsigned char _Source=15, unsigned char _Priority=6, unsigned long _PGN=0, int _DataLen=0)
Construct a new t N2k Msg object.
Definition: N2kMsg.cpp:60
void SendInActisenseFormat(N2kStream *port) const
Print out the whole content of the N2kMsg Object using the Actisense Format.
Definition: N2kMsg.cpp:853
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.
Definition: N2kMsg.cpp:345
uint32_t Get4ByteUInt(int &Index, uint32_t def=0xffffffff) const
Get an unsigned integer from 4 bytes out of Data.
Definition: N2kMsg.cpp:282
int DataLen
Number of bytes already stored in tN2kMsg::Data of this message.
Definition: N2kMsg.h:673
unsigned long PGN
Parameter Group Number (PGN) of the NMEA2000 message.
Definition: N2kMsg.h:667
unsigned char Destination
Destination of the NMEA2000 message.
Definition: N2kMsg.h:671