From f904812b671d40a24083dd7c197c3c236eeef737 Mon Sep 17 00:00:00 2001 From: Timo Lappalainen Date: Sat, 24 Feb 2024 08:46:49 +0200 Subject: [PATCH 1/7] Fix for changes --- Documents/src/changes.md | 3 ++- library.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Documents/src/changes.md b/Documents/src/changes.md index 327c1ee9..eb728293 100644 --- a/Documents/src/changes.md +++ b/Documents/src/changes.md @@ -4,7 +4,8 @@ ## 23.02.2024 - Compatibility change: Parsers ParseN2kPGN129809, ParseN2kPGN129810 and ParseN2kPGN129794 parameter list - Added bufer length fields for Name, Callsign, and Destination + Added buffer length fields for Name, Callsign, and Destination +- Fixed PGN 129809, 129810, 129794 string handling. AIS strings uses @ for padding. ## 09.02.2024 diff --git a/library.json b/library.json index 2f61627a..e74558f4 100644 --- a/library.json +++ b/library.json @@ -13,7 +13,7 @@ "url": "http://www.kave.fi", "maintainer": true }, - "version": "4.20.3", + "version": "4.21.1", "license": "MIT", "frameworks": "*", "platforms": "*" From c998950e3cd8424b60bb5f27c62ea8ec81972a64 Mon Sep 17 00:00:00 2001 From: Luis Soltero Date: Mon, 26 Feb 2024 08:52:10 -0500 Subject: [PATCH 2/7] (char *)->(const char *) for AIS set functions) --- src/N2kMessages.cpp | 3 ++- src/N2kMessages.h | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/N2kMessages.cpp b/src/N2kMessages.cpp index 43f6d567..1e9ae1e1 100644 --- a/src/N2kMessages.cpp +++ b/src/N2kMessages.cpp @@ -1616,7 +1616,8 @@ bool AppendN2kPGN129285(tN2kMsg &N2kMsg, uint16_t ID, const char* Name, double L #define MAXAISSTRBUFLEN 21 const char *StringToAISString(const char *str, char *AISStr, size_t AISStrBufSize) { - int i; + if ( str == nullptr || AISStr == nullptr) return nullptr; + size_t i; for (i = 0; str[i] != '\0' && i < AISStrBufSize; i++ ) { char c = toupper((int)str[i]); AISStr[i] = (c >= 0x20 && c <= 0x5F) ? c : '?'; diff --git a/src/N2kMessages.h b/src/N2kMessages.h index 766cf922..e8c58d42 100644 --- a/src/N2kMessages.h +++ b/src/N2kMessages.h @@ -4330,9 +4330,9 @@ void SetN2kPGN129794(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, u * of the source code. See parameter details on \ref SetN2kPGN129794 */ inline void SetN2kAISClassAStatic(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, - uint32_t IMOnumber, char *Callsign, char *Name, uint8_t VesselType, double Length, + uint32_t IMOnumber, const char *Callsign, const char *Name, uint8_t VesselType, double Length, double Beam, double PosRefStbd, double PosRefBow, uint16_t ETAdate, double ETAtime, - double Draught, char *Destination, tN2kAISVersion AISversion, tN2kGNSStype GNSStype, + double Draught, char const *Destination, tN2kAISVersion AISversion, tN2kGNSStype GNSStype, tN2kAISDTE DTE, tN2kAISTransceiverInformation AISinfo) { SetN2kPGN129794(N2kMsg, MessageID, Repeat, UserID, IMOnumber, Callsign, Name, VesselType, Length, Beam, PosRefStbd, PosRefBow, ETAdate, ETAtime, Draught, Destination, AISversion, GNSStype, DTE, AISinfo); @@ -4452,7 +4452,7 @@ void SetN2kPGN129809(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, u * Alias of PGN 129809. This alias was introduced to improve the readability * of the source code. See parameter details on \ref SetN2kPGN129809 */ -inline void SetN2kAISClassBStaticPartA(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, char *Name) { +inline void SetN2kAISClassBStaticPartA(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, const char *Name) { SetN2kPGN129809(N2kMsg, MessageID, Repeat, UserID, Name); } @@ -4533,7 +4533,7 @@ inline bool ParseN2kAISClassBStaticPartA(const tN2kMsg &N2kMsg, uint8_t &Message * */ void SetN2kPGN129810(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, - uint8_t VesselType, char *Vendor, char *Callsign, double Length, double Beam, + uint8_t VesselType, const char *Vendor, const char *Callsign, double Length, double Beam, double PosRefStbd, double PosRefBow, uint32_t MothershipID); /************************************************************************//** @@ -4544,7 +4544,7 @@ void SetN2kPGN129810(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, u * of the source code. See parameter details on \ref SetN2kPGN129810 */ inline void SetN2kAISClassBStaticPartB(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, - uint8_t VesselType, char *Vendor, char *Callsign, double Length, double Beam, + uint8_t VesselType, const char *Vendor, const char *Callsign, double Length, double Beam, double PosRefStbd, double PosRefBow, uint32_t MothershipID) { SetN2kPGN129810(N2kMsg, MessageID, Repeat, UserID, VesselType, Vendor, Callsign, Length, Beam, PosRefStbd, PosRefBow, MothershipID); From 97f9926dbe4dd516d3a10917dd6e3c3e9239fab5 Mon Sep 17 00:00:00 2001 From: Luis Soltero Date: Mon, 26 Feb 2024 17:26:01 -0500 Subject: [PATCH 3/7] Ensure that AIS strings are ITU-R M.1371-1 compliant --- Documents/src/changes.md | 6 ++++++ library.properties | 2 +- src/N2kMessages.cpp | 34 ++++++---------------------------- src/N2kMessages.h | 8 ++++---- src/N2kMsg.cpp | 17 +++++++++++++++++ src/N2kMsg.h | 9 +++++++++ 6 files changed, 43 insertions(+), 33 deletions(-) diff --git a/Documents/src/changes.md b/Documents/src/changes.md index eb728293..099c0655 100644 --- a/Documents/src/changes.md +++ b/Documents/src/changes.md @@ -1,6 +1,12 @@ # Changes to the Library {#changes} \tableofcontents +## 26.02.2024 + +- changed (char *) arguments to (const char *) in Set functions for PGN 129809, 129810, 129794 +- Added AddAISStr() method to N2kMsg class which filters AIS strings to make complient with ITU-R M.1371-1 +- modified Set functions for PGN 129809, 129810, 129794 to use AddAISStr() + ## 23.02.2024 - Compatibility change: Parsers ParseN2kPGN129809, ParseN2kPGN129810 and ParseN2kPGN129794 parameter list diff --git a/library.properties b/library.properties index 5844cec0..5e7cd2ea 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=NMEA2000 -version=4.21.1 +version=4.21.2 author=Timo Lappalainen maintainer=Kave Oy sentence=NMEA 2000 library for building compatible devices for NMEA 2000 bus. diff --git a/src/N2kMessages.cpp b/src/N2kMessages.cpp index 1e9ae1e1..e56c215a 100644 --- a/src/N2kMessages.cpp +++ b/src/N2kMessages.cpp @@ -22,7 +22,6 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "N2kMessages.h" #include -#include //***************************************************************************** // System time @@ -1609,24 +1608,6 @@ bool AppendN2kPGN129285(tN2kMsg &N2kMsg, uint16_t ID, const char* Name, double L } } -//***************************************************************************** -// AIS String helper -// make sure characters fall into range defined in table 14 -// https://www.itu.int/dms_pubrec/itu-r/rec/m/R-REC-M.1371-1-200108-S!!PDF-E.pdf -#define MAXAISSTRBUFLEN 21 -const char *StringToAISString(const char *str, char *AISStr, size_t AISStrBufSize) -{ - if ( str == nullptr || AISStr == nullptr) return nullptr; - size_t i; - for (i = 0; str[i] != '\0' && i < AISStrBufSize; i++ ) { - char c = toupper((int)str[i]); - AISStr[i] = (c >= 0x20 && c <= 0x5F) ? c : '?'; - } - if ( i < AISStrBufSize ) AISStr[i]='\0'; - - return AISStr; -} - //***************************************************************************** // AIS static data A void SetN2kPGN129794(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, @@ -1635,14 +1616,13 @@ void SetN2kPGN129794(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, u double Draught, const char *Destination, tN2kAISVersion AISversion, tN2kGNSStype GNSStype, tN2kAISDTE DTE, tN2kAISTransceiverInformation AISinfo) { - char AISstrBuf[MAXAISSTRBUFLEN]; N2kMsg.SetPGN(129794L); N2kMsg.Priority=6; N2kMsg.AddByte((Repeat & 0x03)<<6 | (MessageID & 0x3f)); N2kMsg.Add4ByteUInt(UserID); N2kMsg.Add4ByteUInt(IMOnumber); - N2kMsg.AddStr(StringToAISString(Callsign, AISstrBuf, sizeof(AISstrBuf)), 7, false, '@'); - N2kMsg.AddStr(StringToAISString(Name, AISstrBuf, sizeof(AISstrBuf)), 20, false, '@'); + N2kMsg.AddAISStr(Callsign,7); + N2kMsg.AddAISStr(Name, 20); N2kMsg.AddByte(VesselType); N2kMsg.Add2ByteDouble(Length, 0.1); N2kMsg.Add2ByteDouble(Beam, 0.1); @@ -1651,7 +1631,7 @@ void SetN2kPGN129794(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, u N2kMsg.Add2ByteUInt(ETAdate); N2kMsg.Add4ByteUDouble(ETAtime, 0.0001); N2kMsg.Add2ByteDouble(Draught, 0.01); - N2kMsg.AddStr(StringToAISString(Destination, AISstrBuf, sizeof(AISstrBuf)), false, 20, '@'); + N2kMsg.AddAISStr(Destination, 20); N2kMsg.AddByte((DTE & 0x01)<<6 | (GNSStype & 0x0f)<<2 | (AISversion & 0x03)); N2kMsg.AddByte(0xe0 | (AISinfo & 0x1f)); N2kMsg.AddByte(0xff); @@ -1692,12 +1672,11 @@ bool ParseN2kPGN129794(const tN2kMsg &N2kMsg, uint8_t &MessageID, tN2kAISRepeat // AIS static data class B part A void SetN2kPGN129809(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, const char *Name) { - char AISstrBuf[MAXAISSTRBUFLEN]; N2kMsg.SetPGN(129809L); N2kMsg.Priority=6; N2kMsg.AddByte((Repeat & 0x03)<<6 | (MessageID & 0x3f)); N2kMsg.Add4ByteUInt(UserID); - N2kMsg.AddStr(StringToAISString(Name,AISstrBuf, sizeof(AISstrBuf)), 20, false, '@'); + N2kMsg.AddAISStr(Name, 20); } bool ParseN2kPGN129809(const tN2kMsg &N2kMsg, uint8_t &MessageID, tN2kAISRepeat &Repeat, uint32_t &UserID, char *Name, size_t NameBufSize) @@ -1720,14 +1699,13 @@ void SetN2kPGN129810(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, u uint8_t VesselType, const char *Vendor, const char *Callsign, double Length, double Beam, double PosRefStbd, double PosRefBow, uint32_t MothershipID) { - char AISstrBuf[MAXAISSTRBUFLEN]; N2kMsg.SetPGN(129810L); N2kMsg.Priority=6; N2kMsg.AddByte((Repeat & 0x03)<<6 | (MessageID & 0x3f)); N2kMsg.Add4ByteUInt(UserID); N2kMsg.AddByte(VesselType); - N2kMsg.AddStr(StringToAISString(Vendor, AISstrBuf, sizeof(AISstrBuf)), 7, false, '@'); - N2kMsg.AddStr(StringToAISString(Callsign, AISstrBuf, sizeof(AISstrBuf)), 7, false, '@'); + N2kMsg.AddAISStr(Vendor, 7); + N2kMsg.AddAISStr(Callsign, 7); N2kMsg.Add2ByteUDouble(Length, 0.1); N2kMsg.Add2ByteUDouble(Beam, 0.1); N2kMsg.Add2ByteUDouble(PosRefStbd, 0.1); diff --git a/src/N2kMessages.h b/src/N2kMessages.h index e8c58d42..c4c95e31 100644 --- a/src/N2kMessages.h +++ b/src/N2kMessages.h @@ -4287,7 +4287,7 @@ inline bool ParseN2kPGNSatellitesInView(const tN2kMsg& N2kMsg, uint8_t SVIndex, * \param IMOnumber Ship identification number by IMO * [1 .. 999999999]; 0 = not available = default * Not applicable to SAR aircraft - * \param Callsign Call Sign - 7x -> 6 bit ASCII characters, + * \param Callsign Call Sign - 7x -> 6 bit ASCII characters conversion as per ITU-R M.1371-1, * \param Name Name of the vessel; * Maximum 20 characters 6 bit ASCII; * For SAR aircraft, it should be set @@ -4359,7 +4359,7 @@ inline void SetN2kAISClassAStatic(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRep * \param IMOnumber Ship identification number by IMO * [1 .. 999999999]; 0 = not available = default * Not applicable to SAR aircraft - * \param Callsign Call Sign - 7x -> 6 bit ASCII characters, + * \param Callsign Call Sign * \param CallsignBufSize size of Callsign buffer * \param Name Name of the vessel; * Maximum 20 characters 6 bit ASCII; @@ -4524,7 +4524,7 @@ inline bool ParseN2kAISClassBStaticPartA(const tN2kMsg &N2kMsg, uint8_t &Message * Not applicable to SAR aircraft * \param Vendor Unique identification of the Unit by a number as * defined by the manufacturer - * \param Callsign Call Sign - 7x -> 6 bit ASCII characters + * \param Callsign Call Sign - 7x -> 6 bit ASCII characters conversion as per ITU-R M.1371-1 * \param Length Length/Diameter in meters * \param Beam Beam/Diameter in meters * \param PosRefStbd Position Reference Point from Starboard @@ -4578,7 +4578,7 @@ inline void SetN2kAISClassBStaticPartB(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kA * \param Vendor Unique identification of the Unit by a number as * defined by the manufacturer * \param VendorBufSize size of Vendor buffer - * \param Callsign Call Sign - 7x -> 6 bit ASCII characters + * \param Callsign Call Sign * \param CallsignBufSize size of Callsign buffer * \param Length Length/Diameter in meters * \param Beam Beam/Diameter in meters diff --git a/src/N2kMsg.cpp b/src/N2kMsg.cpp index 1cca4eac..f1bfa291 100644 --- a/src/N2kMsg.cpp +++ b/src/N2kMsg.cpp @@ -26,6 +26,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include //#include // For testing used memory #define Escape 0x10 @@ -213,6 +214,22 @@ void tN2kMsg::AddStr(const char *str, int len, bool UsePgm, unsigned char fillCh SetBufStr(str,len,DataLen,Data,UsePgm,fillChar); } +//***************************************************************************** +// Add AIS String +// make sure characters fall into range defined in table 14 +// https://www.itu.int/dms_pubrec/itu-r/rec/m/R-REC-M.1371-1-200108-S!!PDF-E.pdf +void tN2kMsg::AddAISStr(const char *str, int len) { + char AISStr[21]; // Max AIS strlen defined in ITU-R M.1371-1 + size_t i; + for (i = 0; str[i] != '\0' && i < sizeof(AISStr); i++ ) { + char c = toupper((int)str[i]); + AISStr[i] = (c >= 0x20 && c <= 0x5F) ? c : '?'; + } + AISStr[i]='\0'; + AddStr(AISStr,len,false,'@'); +} + + //***************************************************************************** void tN2kMsg::AddVarStr(const char *str, bool UsePgm) { int len=(str!=0?strlen(str):0); diff --git a/src/N2kMsg.h b/src/N2kMsg.h index ad6d1ed6..bc137bd3 100644 --- a/src/N2kMsg.h +++ b/src/N2kMsg.h @@ -950,6 +950,15 @@ class tN2kMsg */ void AddStr(const char *str, int len, bool UsePgm=false, unsigned char fillChar=0xff); + /************************************************************************//** + * \brief Add string value to the buffer after filtering characters as defined in ITU-R M.1371-1 + * The string will be added to the end (indicated by \ref DataLen) of + * the byte array \ref Data. + * \param str String as pointer to a char array + * \param len Length of the string + */ + void AddAISStr(const char *str, int len); + /************************************************************************//** * \brief Add string value to the buffer * This method determines the length of the string by it self using strlen(). From 032d1700b239cb3c9e97e59c0f4ecc543b72b2c7 Mon Sep 17 00:00:00 2001 From: Luis Soltero Date: Thu, 29 Feb 2024 10:33:13 -0500 Subject: [PATCH 4/7] streamline N2kMsg::AddAISStr to reduce memory footprint. update comments for PGN129794/809/810 --- src/N2kMessages.h | 17 +++++++++++------ src/N2kMsg.cpp | 15 ++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/N2kMessages.h b/src/N2kMessages.h index c4c95e31..c51bab9e 100644 --- a/src/N2kMessages.h +++ b/src/N2kMessages.h @@ -4287,12 +4287,13 @@ inline bool ParseN2kPGNSatellitesInView(const tN2kMsg& N2kMsg, uint8_t SVIndex, * \param IMOnumber Ship identification number by IMO * [1 .. 999999999]; 0 = not available = default * Not applicable to SAR aircraft - * \param Callsign Call Sign - 7x -> 6 bit ASCII characters conversion as per ITU-R M.1371-1, + * \param Callsign Call Sign - Max. 7 chars will be used. Input string will be converted to contain only SixBit ASCII character set (see. ITU-R M.1371-1) * \param Name Name of the vessel; - * Maximum 20 characters 6 bit ASCII; + * Maximum 20 characters; * For SAR aircraft, it should be set * to “SAR AIRCRAFT NNNNNNN” where NNNNNNN equals * the aircraft registration number + * Input string will be converted to contain only SixBit ASCII character set (see. ITU-R M.1371-1) * \param VesselType Vessel Type * 0 = not available or no ship = default * 1-99 = as defined in § 3.3.2 @@ -4307,7 +4308,8 @@ inline bool ParseN2kPGNSatellitesInView(const tN2kMsg& N2kMsg, uint8_t SVIndex, * \param ETAtime EstimatedTimeOfArrival -seconds since midnight (UTC) * \param Draught Maximum present static draught * \param Destination Destination - - * Maximum 20 characters using 6-bit ASCII + * Maximum 20 characters + * Input string will be converted to contain only SixBit ASCII character set (see. ITU-R M.1371-1) * \param AISversion AIS version, see \ref tN2kAISVersion * \param GNSStype Type of GNSS, see \ref tN2kGNSStype * \param DTE Data terminal equipment (DTE) ready @@ -4437,10 +4439,11 @@ inline bool ParseN2kAISClassAStatic(const tN2kMsg &N2kMsg, uint8_t &MessageID, t * see \ref tN2kAISRepeat * \param UserID MMSI Number * \param Name Name of the vessel; - * Maximum 20 characters 6 bit ASCII; + * Maximum 20 characters; * For SAR aircraft, it should be set * to “SAR AIRCRAFT NNNNNNN” where NNNNNNN equals * the aircraft registration number + * Input string will be converted to contain only SixBit ASCII character set (see. ITU-R M.1371-1) * */ void SetN2kPGN129809(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, const char *Name); @@ -4475,10 +4478,11 @@ inline void SetN2kAISClassBStaticPartA(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kA * see \ref tN2kAISRepeat * \param UserID MMSI Number * \param Name Name of the vessel; - * Maximum 20 characters 6 bit ASCII; + * Maximum 20 characters; * For SAR aircraft, it should be set * to “SAR AIRCRAFT NNNNNNN” where NNNNNNN equals * the aircraft registration number + * Input string will be converted to contain only SixBit ASCII character set (see. ITU-R M.1371-1) * \param NameBufSize size of Name buffer * * \return true Parsing of PGN Message successful @@ -4524,7 +4528,8 @@ inline bool ParseN2kAISClassBStaticPartA(const tN2kMsg &N2kMsg, uint8_t &Message * Not applicable to SAR aircraft * \param Vendor Unique identification of the Unit by a number as * defined by the manufacturer - * \param Callsign Call Sign - 7x -> 6 bit ASCII characters conversion as per ITU-R M.1371-1 + * Max. 7 chars will be used. Input string will be converted to contain only SixBit ASCII character set (see. ITU-R M.1371-1) + * \param Callsign Call Sign - Max. 7 chars will be used. Input string will be converted to contain only SixBit ASCII character set (see. ITU-R M.1371-1) * \param Length Length/Diameter in meters * \param Beam Beam/Diameter in meters * \param PosRefStbd Position Reference Point from Starboard diff --git a/src/N2kMsg.cpp b/src/N2kMsg.cpp index f1bfa291..9dfa2179 100644 --- a/src/N2kMsg.cpp +++ b/src/N2kMsg.cpp @@ -28,6 +28,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include //#include // For testing used memory +#include #define Escape 0x10 #define StartOfText 0x02 @@ -219,14 +220,14 @@ void tN2kMsg::AddStr(const char *str, int len, bool UsePgm, unsigned char fillCh // make sure characters fall into range defined in table 14 // https://www.itu.int/dms_pubrec/itu-r/rec/m/R-REC-M.1371-1-200108-S!!PDF-E.pdf void tN2kMsg::AddAISStr(const char *str, int len) { - char AISStr[21]; // Max AIS strlen defined in ITU-R M.1371-1 - size_t i; - for (i = 0; str[i] != '\0' && i < sizeof(AISStr); i++ ) { - char c = toupper((int)str[i]); - AISStr[i] = (c >= 0x20 && c <= 0x5F) ? c : '?'; + unsigned char *buf=Data+DataLen; + for (; len>0 && *str!=0 && DataLen= 0x20 && c <= 0x5F) ? c : '?'; } - AISStr[i]='\0'; - AddStr(AISStr,len,false,'@'); + + len=std::min(len,MaxDataLen-DataLen); + if ( len>0 ) memset(buf,'@',len); } From ee2bc68b3a71537eabff37068ac374e30ae479f3 Mon Sep 17 00:00:00 2001 From: Luis Soltero Date: Tue, 5 Mar 2024 16:14:32 -0500 Subject: [PATCH 5/7] remote dependency on std::min --- src/N2kMsg.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/N2kMsg.cpp b/src/N2kMsg.cpp index 9dfa2179..090f1ee0 100644 --- a/src/N2kMsg.cpp +++ b/src/N2kMsg.cpp @@ -28,7 +28,6 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include //#include // For testing used memory -#include #define Escape 0x10 #define StartOfText 0x02 @@ -226,7 +225,7 @@ void tN2kMsg::AddAISStr(const char *str, int len) { *buf=(c >= 0x20 && c <= 0x5F) ? c : '?'; } - len=std::min(len,MaxDataLen-DataLen); + if ( len > MaxDataLen-DataLen ) len=MaxDataLen-DataLen; if ( len>0 ) memset(buf,'@',len); } From 606ca1efa8e731246feef08f15ef2d4d8760d55f Mon Sep 17 00:00:00 2001 From: Luis Soltero Date: Wed, 6 Mar 2024 17:20:38 -0500 Subject: [PATCH 6/7] updated comment --- Documents/src/changes.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documents/src/changes.md b/Documents/src/changes.md index 099c0655..a5b528fb 100644 --- a/Documents/src/changes.md +++ b/Documents/src/changes.md @@ -1,6 +1,12 @@ # Changes to the Library {#changes} \tableofcontents +## 06.03.2024 + +-- reduced memory footprint for N2kMsg::AddAISStr +-- bumped library version +-- Ensure that strings added by N2kMsg::AddAISStr are 6 bit ASCII ITU-R M.1371-1 table 14 compliant + ## 26.02.2024 - changed (char *) arguments to (const char *) in Set functions for PGN 129809, 129810, 129794 From fa2d2cc385b481bb2bef5704ecb5c28cc1e3977d Mon Sep 17 00:00:00 2001 From: Luis Soltero Date: Wed, 6 Mar 2024 17:23:54 -0500 Subject: [PATCH 7/7] bump library version --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index e74558f4..b0a81ef1 100644 --- a/library.json +++ b/library.json @@ -13,7 +13,7 @@ "url": "http://www.kave.fi", "maintainer": true }, - "version": "4.21.1", + "version": "4.21.2", "license": "MIT", "frameworks": "*", "platforms": "*"