Skip to content

Commit

Permalink
#49: better handling of VHW - optionally send 127250 for both mag/tru…
Browse files Browse the repository at this point in the history
…e, always send 128259 also if no heading is available
  • Loading branch information
andreas committed Mar 8, 2023
1 parent ef2a79f commit 2e58716
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/nmea0183ton2k/NMEA0183DataToN2K.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ class NMEA0183DataToN2KFunctions : public NMEA0183DataToN2K
boatData->VAR->getDataWithDefault(N2kDoubleNA),
boatData->DEV->getDataWithDefault(N2kDoubleNA)
);
send(n2kMsg,msg.sourceId);
send(n2kMsg,msg.sourceId,"127250M");
}

void convertHDT(const SNMEA0183Msg &msg){
Expand Down Expand Up @@ -570,7 +570,7 @@ class NMEA0183DataToN2KFunctions : public NMEA0183DataToN2K
UD(DEV);
tN2kMsg n2kMsg;
SetN2kMagneticHeading(n2kMsg,1,MHDG,DEV,VAR);
send(n2kMsg,msg.sourceId);
send(n2kMsg,msg.sourceId,"127250M");
}

void convertDPT(const SNMEA0183Msg &msg){
Expand Down Expand Up @@ -692,10 +692,19 @@ class NMEA0183DataToN2KFunctions : public NMEA0183DataToN2K
LOG_DEBUG(GwLog::DEBUG, "failed to parse VHW %s", msg.line);
return;
}
if (! updateDouble(boatData->STW,STW,msg.sourceId)) return;
if (! updateDouble(boatData->HDG,TrueHeading,msg.sourceId)) return;
if (MagneticHeading == NMEA0183DoubleNA) MagneticHeading=N2kDoubleNA;
tN2kMsg n2kMsg;
if (updateDouble(boatData->HDG,TrueHeading,msg.sourceId)){
SetN2kTrueHeading(n2kMsg,1,TrueHeading);
send(n2kMsg,msg.sourceId);
}
if(updateDouble(boatData->MHDG,MagneticHeading,msg.sourceId)){
SetN2kMagneticHeading(n2kMsg,1,MagneticHeading,
boatData->DEV->getDataWithDefault(N2kDoubleNA),
boatData->VAR->getDataWithDefault(N2kDoubleNA)
);
send(n2kMsg,msg.sourceId,"127250M"); //ensure both mag and true are sent
}
if (! updateDouble(boatData->STW,STW,msg.sourceId)) return;
SetN2kBoatSpeed(n2kMsg,1,STW);
send(n2kMsg,msg.sourceId);

Expand Down

0 comments on commit 2e58716

Please sign in to comment.