diff --git a/Readme.md b/Readme.md index 26e14bde..12dcade4 100644 --- a/Readme.md +++ b/Readme.md @@ -145,6 +145,12 @@ For details refer to the [example description](lib/exampletask/Readme.md). Changelog --------- +[20220403](../../releases/tag/20220403) +********* +* add support for PGN 127257 pitch/roll/yaw +* only convert RMC and GGA if valid status [#38](../../issues/38) +* only send 129539 if GSA fix mode is 2 or 3 [#39](../../issues/39) + [20220320](../../releases/tag/20220320) ********* * accept lowercase characters in NMEA0183 checksum [#33](../../issues/33) diff --git a/lib/nmea0183ton2k/NMEA0183DataToN2K.cpp b/lib/nmea0183ton2k/NMEA0183DataToN2K.cpp index d9fabbab..0258f8cc 100644 --- a/lib/nmea0183ton2k/NMEA0183DataToN2K.cpp +++ b/lib/nmea0183ton2k/NMEA0183DataToN2K.cpp @@ -288,6 +288,11 @@ class NMEA0183DataToN2KFunctions : public NMEA0183DataToN2K } } break; + case XDRATTITUDE: + if (fillFieldList(current,fields,3)){ + SetN2kPGN127257(n2kMsg,current.mapping.instanceId,fields[0],fields[1],fields[2]); + send(n2kMsg,msg.sourceId,buildN2KKey(n2kMsg,current.mapping)); + } default: continue; } @@ -976,9 +981,9 @@ class NMEA0183DataToN2KFunctions : public NMEA0183DataToN2K converters.registerConverter( 129283UL, String(F("XTE")), &NMEA0183DataToN2KFunctions::convertXTE); - unsigned long *xdrpgns=new unsigned long[7]{127505UL,127508UL,130312UL,130313UL,130314UL,127489UL,127488UL}; + unsigned long *xdrpgns=new unsigned long[8]{127505UL,127508UL,130312UL,130313UL,130314UL,127489UL,127488UL,127257UL}; converters.registerConverter( - 7, + 8, xdrpgns, F("XDR"), &NMEA0183DataToN2KFunctions::convertXDR); unsigned long *aispgns=new unsigned long[7]{129810UL,129809UL,129040UL,129039UL,129802UL,129794UL,129038UL}; diff --git a/lib/nmea2kto0183/N2kDataToNMEA0183.cpp b/lib/nmea2kto0183/N2kDataToNMEA0183.cpp index b101f6c8..3e900fde 100644 --- a/lib/nmea2kto0183/N2kDataToNMEA0183.cpp +++ b/lib/nmea2kto0183/N2kDataToNMEA0183.cpp @@ -1389,6 +1389,22 @@ class N2kToNMEA0183Functions : public N2kDataToNMEA0183 } finalizeXdr(); } + void Handle127257(const tN2kMsg &msg){ + unsigned char instance=-1; + double values[3]; + for (int i=0;i<3;i++) values[i]=N2kDoubleNA; + //yaw,pitch,roll + if (! ParseN2kPGN127257(msg,instance, + values[0],values[1],values[2])){ + LOG_DEBUG(GwLog::DEBUG,"unable to parse PGN %d",msg.PGN); + } + for (int i=0;i<3;i++){ + GwXDRFoundMapping mapping=xdrMappings->getMapping(XDRATTITUDE,0,i,instance); + if (! updateDouble(&mapping,values[i])) continue; + addToXdr(mapping.buildXdrEntry(values[i])); + } + finalizeXdr(); + } void Handle127488(const tN2kMsg &msg){ unsigned char instance=-1; double speed=N2kDoubleNA,pressure=N2kDoubleNA; @@ -1478,6 +1494,7 @@ class N2kToNMEA0183Functions : public N2kDataToNMEA0183 converters.registerConverter(127489UL, &N2kToNMEA0183Functions::Handle127489); converters.registerConverter(127488UL, &N2kToNMEA0183Functions::Handle127488); converters.registerConverter(130316UL, &N2kToNMEA0183Functions::Handle130316); + converters.registerConverter(127257UL, &N2kToNMEA0183Functions::Handle127257); #define HANDLE_AIS #ifdef HANDLE_AIS converters.registerConverter(129038UL, &N2kToNMEA0183Functions::HandleAISClassAPosReport); // AIS Class A Position Report, Message Type 1 diff --git a/lib/xdrmappings/GwXDRMappings.cpp b/lib/xdrmappings/GwXDRMappings.cpp index a08cfc10..04b4f3df 100644 --- a/lib/xdrmappings/GwXDRMappings.cpp +++ b/lib/xdrmappings/GwXDRMappings.cpp @@ -53,6 +53,7 @@ GwXDRType *types[] = { new GwXDRType(GwXDRType::FLOW, "R", "I", ps2ph, ph2ps), new GwXDRType(GwXDRType::GENERIC, "G", ""), new GwXDRType(GwXDRType::DISPLACEMENT, "A", "P"), + new GwXDRType(GwXDRType::DISPLACEMENTD, "A", "D",DegToRad,RadToDeg), new GwXDRType(GwXDRType::RPM,"T","R"), //important to have 2x NULL! NULL, @@ -121,7 +122,7 @@ bool GwXDRMappingDef::handleToken(String tok, int index, GwXDRMappingDef *def) case 0: //category i = tok.toInt(); - if (i < XDRTEMP || i > XDRENGINE) + if (i < XDRTEMP || i > XDRATTITUDE) return false; def->category = (GwXDRCategory)i; return true; diff --git a/lib/xdrmappings/GwXDRMappings.h b/lib/xdrmappings/GwXDRMappings.h index a51d3f2e..cd90781f 100644 --- a/lib/xdrmappings/GwXDRMappings.h +++ b/lib/xdrmappings/GwXDRMappings.h @@ -19,7 +19,8 @@ typedef enum { XDRBATCHEM=7, //unused XDRGEAR=8, //unused XDRBAT=9, - XDRENGINE=10 + XDRENGINE=10, + XDRATTITUDE=11 } GwXDRCategory; class GwXDRType{ public: @@ -36,6 +37,7 @@ class GwXDRType{ GENERIC=9, DISPLACEMENT=10, RPM=11, + DISPLACEMENTD=12, UNKNOWN=99 }TypeCode; typedef double (* convert)(double); diff --git a/web/xdrconfig.json b/web/xdrconfig.json index 6e528f7a..dab61e60 100644 --- a/web/xdrconfig.json +++ b/web/xdrconfig.json @@ -323,5 +323,14 @@ {"l":"EngineBoostPressure","t":0}, {"l":"EngineTiltTrim","t":10} ] + }, + "Attitude":{ + "d":"127257", + "id":11, + "fields":[ + {"l":"Yaw","t":12}, + {"l":"Pitch","t":12}, + {"l":"Roll","t":12} + ] } }