Skip to content

Commit

Permalink
add pgn 130314 - not tested yet
Browse files Browse the repository at this point in the history
  • Loading branch information
sarfata committed Jun 5, 2017
1 parent ddfb1fe commit 45955aa
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
24 changes: 24 additions & 0 deletions N2kMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,30 @@ bool ParseN2kPGN130312(const tN2kMsg &N2kMsg, unsigned char &SID, unsigned char
return true;
}

//*****************************************************************************
// Actual Pressure
// Pressure should be in Pascals
void SetN2kPGN130314(tN2kMsg &N2kMsg, unsigned char SID, unsigned char PressureInstance,
tN2kPressureSource PressureSource, double ActualPressure) {
N2kMsg.SetPGN(130314L);
N2kMsg.Priority = 6;
N2kMsg.AddByte(SID);
N2kMsg.AddByte((unsigned char) PressureInstance);
N2kMsg.AddByte((unsigned char) PressureSource);
N2kMsg.Add4ByteUDouble(ActualPressure,10000);
}

bool ParseN2kPGN130314(const tN2kMsg &N2kMsg, unsigned char &SID, unsigned char &PressureInstance,
tN2kPressureSource &PressureSource, double ActualPressure) {
if (N2kMsg.PGN != 130314L) return false;
int Index = 0;
SID=N2kMsg.GetByte(Index);
PressureInstance=N2kMsg.GetByte(Index);
PressureSource=(tN2kPressureSource)N2kMsg.GetByte(Index);
ActualPressure=N2kMsg.Get4ByteUDouble(10000, Index);
return true;
}

//*****************************************************************************
// Temperature extended range
// Temperatures should be in Kelvins
Expand Down
32 changes: 32 additions & 0 deletions N2kMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ enum tN2kHumiditySource {
N2khs_Undef=1
};

enum tN2kPressureSource {
N2kps_Atmospheric = 0,
N2kps_Water = 1,
N2kps_Steam = 2,
N2kps_CompressedAir = 3,
N2kps_Hydraulic = 4
};

enum tN2kTimeSource {
N2ktimes_GPS=0,
N2ktimes_GLONASS=1,
Expand Down Expand Up @@ -1269,6 +1277,30 @@ inline bool ParseN2kTemperature(const tN2kMsg &N2kMsg, unsigned char &SID, unsig
return ParseN2kPGN130312(N2kMsg, SID, TempInstance, TempSource, ActualTemperature, SetTemperature);
}

//*****************************************************************************
// Pressure
// Pressures should be in Pascals
// Input:
// - SID Sequence ID.
// - PressureInstance This should be unic at least on one device. May be best to have it unic over all devices sending this PGN.
// - PressureSource see tN2kPressureSource
// - Pressure Atmospheric pressure in Pascals. Use function mBarToPascal, if you like to use mBar
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN130314(tN2kMsg &N2kMsg, unsigned char SID, unsigned char PressureInstance,
tN2kPressureSource PressureSource, double Pressure);
inline void SetN2kPressure(tN2kMsg &N2kMsg, unsigned char SID, unsigned char PressureInstance,
tN2kPressureSource PressureSource, double Pressure) {
SetN2kPGN130314(N2kMsg, SID, PressureInstance, PressureSource, Pressure);
}
bool ParseN2kPGN130314(const tN2kMsg &N2kMsg, unsigned char &SID, unsigned char &PressureInstance,
tN2kPressureSource &PressureSource, double Pressure);
inline bool ParseN2kPressure(tN2kMsg &N2kMsg, unsigned char &SID, unsigned char &PressureInstance,
tN2kPressureSource &PressureSource, double &Pressure) {
ParseN2kPGN130314(N2kMsg, SID, PressureInstance, PressureSource, Pressure);
}


//*****************************************************************************
// Temperature
// Temperatures should be in Kelvins
Expand Down

0 comments on commit 45955aa

Please sign in to comment.