@@ -22,7 +22,6 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
*/
23
23
#include " N2kMessages.h"
24
24
#include < string.h>
25
- #include < ctype.h>
26
25
27
26
// *****************************************************************************
28
27
// System time
@@ -1609,24 +1608,6 @@ bool AppendN2kPGN129285(tN2kMsg &N2kMsg, uint16_t ID, const char* Name, double L
1609
1608
}
1610
1609
}
1611
1610
1612
- // *****************************************************************************
1613
- // AIS String helper
1614
- // make sure characters fall into range defined in table 14
1615
- // https://www.itu.int/dms_pubrec/itu-r/rec/m/R-REC-M.1371-1-200108-S!!PDF-E.pdf
1616
- #define MAXAISSTRBUFLEN 21
1617
- const char *StringToAISString (const char *str, char *AISStr, size_t AISStrBufSize)
1618
- {
1619
- if ( str == nullptr || AISStr == nullptr ) return nullptr ;
1620
- size_t i;
1621
- for (i = 0 ; str[i] != ' \0 ' && i < AISStrBufSize; i++ ) {
1622
- char c = toupper ((int )str[i]);
1623
- AISStr[i] = (c >= 0x20 && c <= 0x5F ) ? c : ' ?' ;
1624
- }
1625
- if ( i < AISStrBufSize ) AISStr[i]=' \0 ' ;
1626
-
1627
- return AISStr;
1628
- }
1629
-
1630
1611
// *****************************************************************************
1631
1612
// AIS static data A
1632
1613
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
1635
1616
double Draught, const char *Destination, tN2kAISVersion AISversion, tN2kGNSStype GNSStype,
1636
1617
tN2kAISDTE DTE, tN2kAISTransceiverInformation AISinfo)
1637
1618
{
1638
- char AISstrBuf[MAXAISSTRBUFLEN];
1639
1619
N2kMsg.SetPGN (129794L );
1640
1620
N2kMsg.Priority =6 ;
1641
1621
N2kMsg.AddByte ((Repeat & 0x03 )<<6 | (MessageID & 0x3f ));
1642
1622
N2kMsg.Add4ByteUInt (UserID);
1643
1623
N2kMsg.Add4ByteUInt (IMOnumber);
1644
- N2kMsg.AddStr ( StringToAISString ( Callsign, AISstrBuf, sizeof (AISstrBuf)), 7 , false , ' @ ' );
1645
- N2kMsg.AddStr ( StringToAISString ( Name, AISstrBuf, sizeof (AISstrBuf)), 20 , false , ' @ ' );
1624
+ N2kMsg.AddAISStr ( Callsign,7 );
1625
+ N2kMsg.AddAISStr ( Name, 20 );
1646
1626
N2kMsg.AddByte (VesselType);
1647
1627
N2kMsg.Add2ByteDouble (Length, 0.1 );
1648
1628
N2kMsg.Add2ByteDouble (Beam, 0.1 );
@@ -1651,7 +1631,7 @@ void SetN2kPGN129794(tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, u
1651
1631
N2kMsg.Add2ByteUInt (ETAdate);
1652
1632
N2kMsg.Add4ByteUDouble (ETAtime, 0.0001 );
1653
1633
N2kMsg.Add2ByteDouble (Draught, 0.01 );
1654
- N2kMsg.AddStr ( StringToAISString ( Destination, AISstrBuf, sizeof (AISstrBuf)), false , 20 , ' @ ' );
1634
+ N2kMsg.AddAISStr ( Destination, 20 );
1655
1635
N2kMsg.AddByte ((DTE & 0x01 )<<6 | (GNSStype & 0x0f )<<2 | (AISversion & 0x03 ));
1656
1636
N2kMsg.AddByte (0xe0 | (AISinfo & 0x1f ));
1657
1637
N2kMsg.AddByte (0xff );
@@ -1692,12 +1672,11 @@ bool ParseN2kPGN129794(const tN2kMsg &N2kMsg, uint8_t &MessageID, tN2kAISRepeat
1692
1672
// AIS static data class B part A
1693
1673
void SetN2kPGN129809 (tN2kMsg &N2kMsg, uint8_t MessageID, tN2kAISRepeat Repeat, uint32_t UserID, const char *Name)
1694
1674
{
1695
- char AISstrBuf[MAXAISSTRBUFLEN];
1696
1675
N2kMsg.SetPGN (129809L );
1697
1676
N2kMsg.Priority =6 ;
1698
1677
N2kMsg.AddByte ((Repeat & 0x03 )<<6 | (MessageID & 0x3f ));
1699
1678
N2kMsg.Add4ByteUInt (UserID);
1700
- N2kMsg.AddStr ( StringToAISString ( Name,AISstrBuf, sizeof (AISstrBuf)), 20 , false , ' @ ' );
1679
+ N2kMsg.AddAISStr ( Name, 20 );
1701
1680
}
1702
1681
1703
1682
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
1720
1699
uint8_t VesselType, const char *Vendor, const char *Callsign, double Length, double Beam,
1721
1700
double PosRefStbd, double PosRefBow, uint32_t MothershipID)
1722
1701
{
1723
- char AISstrBuf[MAXAISSTRBUFLEN];
1724
1702
N2kMsg.SetPGN (129810L );
1725
1703
N2kMsg.Priority =6 ;
1726
1704
N2kMsg.AddByte ((Repeat & 0x03 )<<6 | (MessageID & 0x3f ));
1727
1705
N2kMsg.Add4ByteUInt (UserID);
1728
1706
N2kMsg.AddByte (VesselType);
1729
- N2kMsg.AddStr ( StringToAISString ( Vendor, AISstrBuf, sizeof (AISstrBuf)), 7 , false , ' @ ' );
1730
- N2kMsg.AddStr ( StringToAISString ( Callsign, AISstrBuf, sizeof (AISstrBuf)), 7 , false , ' @ ' );
1707
+ N2kMsg.AddAISStr ( Vendor, 7 );
1708
+ N2kMsg.AddAISStr ( Callsign, 7 );
1731
1709
N2kMsg.Add2ByteUDouble (Length, 0.1 );
1732
1710
N2kMsg.Add2ByteUDouble (Beam, 0.1 );
1733
1711
N2kMsg.Add2ByteUDouble (PosRefStbd, 0.1 );
0 commit comments