From f66c408be4fdd29e472b47f274072a6959284d30 Mon Sep 17 00:00:00 2001 From: Andrew Wallace Date: Mon, 17 Oct 2016 09:18:32 +0100 Subject: [PATCH] Added parsing of PGN 130311 --- N2kMessages.cpp | 14 ++++++++++++++ N2kMessages.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/N2kMessages.cpp b/N2kMessages.cpp index eda5cee6..54ecd61c 100644 --- a/N2kMessages.cpp +++ b/N2kMessages.cpp @@ -1016,6 +1016,20 @@ void SetN2kPGN130311(tN2kMsg &N2kMsg, unsigned char SID, tN2kTempSource TempInst N2kMsg.Add2ByteUDouble(AtmosphericPressure,100); } +bool ParseN2kPGN130311(const tN2kMsg &N2kMsg, unsigned char &SID, tN2kTempSource &TempInstance, double &Temperature, + tN2kHumiditySource &HumidityInstance, double &Humidity, double &AtmosphericPressure) { + if (N2kMsg.PGN!=130311L) return false; + unsigned char vb; + int Index=0; + SID=N2kMsg.GetByte(Index); + vb=N2kMsg.GetByte(Index); TempInstance=(tN2kTempSource)(vb & 0x3f); HumidityInstance=(tN2kHumiditySource)(vb>>6 & 0x03); + Temperature=N2kMsg.Get2ByteUDouble(0.01,Index); + Humidity=N2kMsg.Get2ByteDouble(0.004,Index); + AtmosphericPressure=N2kMsg.Get2ByteUDouble(100,Index); + + return true; +} + //***************************************************************************** // Temperature // Temperatures should be in Kelvins diff --git a/N2kMessages.h b/N2kMessages.h index a4d5b8b4..703fe1da 100644 --- a/N2kMessages.h +++ b/N2kMessages.h @@ -1059,6 +1059,13 @@ inline void SetN2kEnvironmentalParameters(tN2kMsg &N2kMsg, unsigned char SID, tN SetN2kPGN130311(N2kMsg,SID,TempInstance,Temperature,HumidityInstance,Humidity,AtmosphericPressure); } +bool ParseN2kPGN130311(const tN2kMsg &N2kMsg, unsigned char &SID, tN2kTempSource &TempInstance, double &Temperature, + tN2kHumiditySource &HumidityInstance, double &Humidity, double &AtmosphericPressure); +inline bool ParseN2kEnvironmentalParameters(const tN2kMsg &N2kMsg, unsigned char &SID, tN2kTempSource &TempInstance, double &Temperature, + tN2kHumiditySource &HumidityInstance, double &Humidity, double &AtmosphericPressure) { + return ParseN2kPGN130311(N2kMsg,SID,TempInstance,Temperature,HumidityInstance,Humidity,AtmosphericPressure); +} + //***************************************************************************** // Temperature // Temperatures should be in Kelvins