Skip to content

Commit

Permalink
add support for pgn 127257
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas committed Apr 3, 2022
1 parent 16a2ea3 commit 7d653c4
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions lib/nmea0183ton2k/NMEA0183DataToN2K.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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};
Expand Down
17 changes: 17 additions & 0 deletions lib/nmea2kto0183/N2kDataToNMEA0183.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/xdrmappings/GwXDRMappings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion lib/xdrmappings/GwXDRMappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ typedef enum {
XDRBATCHEM=7, //unused
XDRGEAR=8, //unused
XDRBAT=9,
XDRENGINE=10
XDRENGINE=10,
XDRATTITUDE=11
} GwXDRCategory;
class GwXDRType{
public:
Expand All @@ -36,6 +37,7 @@ class GwXDRType{
GENERIC=9,
DISPLACEMENT=10,
RPM=11,
DISPLACEMENTD=12,
UNKNOWN=99
}TypeCode;
typedef double (* convert)(double);
Expand Down
9 changes: 9 additions & 0 deletions web/xdrconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}
]
}
}

0 comments on commit 7d653c4

Please sign in to comment.