NMEA2000 Library  0.1
Library to handle NMEA 2000 Communication written in C++
N2kMessagesEnumToStr.h File Reference

This File contains functions to convert enums from N2kMessages.h to const char. More...

#include "N2kMessages.h"
Include dependency graph for N2kMessagesEnumToStr.h:

Go to the source code of this file.

Macros

#define MakeN2kEnumTypeToStrFunc(enumType, strs)
 Macro function for converting various N2k Enums to a const char. More...
 

Functions

 MakeN2kEnumTypeToStrFunc (tN2kBatChem, tN2kBatChemStrs)
 Converting the N2k enum tN2kBatChem to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kBatEqSupport, tN2kBatEqSupportStrs)
 Converting the N2k enum tN2kBatEqSupport to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kBatNomVolt, tN2kBatNomVoltStrs)
 Converting the N2k enum tN2kBatNomVolt to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kBatType, tN2kBatTypeStrs)
 Converting the N2k enum tN2kBatType to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kDCType, tN2kDCTypeStrs)
 Converting the N2k enum tN2kDCType to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kFluidType, tN2kFluidTypeStrs)
 Converting the N2k enum tN2kFluidType to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kGNSSmethod, tN2kGNSSmethodStrs)
 Converting the N2k enum tN2kGNSSmethod to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kGNSStype, tN2kGNSStypeStrs)
 Converting the N2k enum tN2kTimeSource to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kHeadingReference, tN2kHeadingReferenceStrs)
 Converting the N2k enum tN2kHeadingReference to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kHumiditySource, tN2kHumidityStrs)
 Converting the N2k enum tN2kHumiditySource to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kMagneticVariation, tN2kSpeedWaterReferenceTypeStrs)
 Converting the N2k enum tN2kMagneticVariation to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kOnOff, tN2kOnOffStrs)
 Converting the N2k enum tN2kOnOff to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kPressureSource, tN2kPressureStrs)
 Converting the N2k enum tN2kPressureSource to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kRudderDirectionOrder, tN2kRudderDirectionOrderStrs)
 Converting the N2k enum tN2kRudderDirectionOrder to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kSpeedWaterReferenceType, tN2kSpeedWaterReferenceTypeStrs)
 Converting the N2k enum tN2kSpeedWaterReferenceType to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kTempSource, tN2kTempSourceStrs)
 Converting the N2k enum tN2kTempSource to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kTimeSource, tN2kTimeSourceStrs)
 Converting the N2k enum tN2kTimeSource to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kTransmissionGear, tN2kTransmissionGearStrs)
 Converting the N2k enum tN2kTransmissionGear to a const char. More...
 
 MakeN2kEnumTypeToStrFunc (tN2kXTEMode, tN2kXTEModeStrs)
 Converting the N2k enum tN2kXTEModeStrs to a const char. More...
 
template<typename T >
void PrintN2kEnumType (T a, Stream *OutputStream, bool addLF=true)
 Print function for the enum values. More...
 

Variables

const char * N2kEnumTypeEmpty =""
 Default value if no string representation is found. More...
 
const char * tN2kBatChemStrs [] = { "lead acid", "LiIon", "NiCad", "NiMh"}
 string representation of the N2k enum tN2kBatChem More...
 
const char * tN2kBatEqSupportStrs [] = { "no", "yes", "error"}
 string representation of the N2k enum tN2kBatEqSupport More...
 
const char * tN2kBatNomVoltStrs [] = { "6V", "12V", "24V", "32V", "62V", "42V", "48V"}
 string representation of the N2k enum tN2kBatNomVolt More...
 
const char * tN2kBatTypeStrs [] = { "flooded", "gel", "AGM"}
 string representation of the N2k enum tN2kBatType More...
 
const char * tN2kDCTypeStrs [] = { "battery", "altenator", "converter", "solar cell", "wind generator"}
 string representation of the N2k enum tN2kDCType More...
 
const char * tN2kFluidTypeStrs []
 string representation of the N2k enum tN2kFluidType More...
 
const char * tN2kGNSSmethodStrs [] = { "no GNSS", "GNSS fix", "DGNSS", "precise GNSS" }
 string representation of the N2k enum tN2kGNSSmethod More...
 
const char * tN2kGNSStypeStrs [] = { "GPS", "GLONASS", "GPS+GLONASS", "GPS+SBAS/WAAS", "GPS+SBAS/WAAS+GLONASS", "Chayka", "integrated", "surveyed", "Galileo" }
 string representation of the N2k enum tN2kGNSStype More...
 
const char * tN2kHeadingReferenceStrs [] = { "true", "magnetic" }
 string representation of the N2k enum tN2kHeadingReference More...
 
const char * tN2kHumidityStrs [] = { "inside", "outside" }
 string representation of the N2k enum tN2kHumiditySource More...
 
const char * tN2kMagneticVariationStrs [] = { "Manual","Automatic Chart","Automatic Table","Automatic Calculation","WMM 2000","WMM 2005","WMM 2010","WMM 2015","WMM 2020" }
 string representation of the N2k enum tN2kMagneticVariation More...
 
const char * tN2kOnOffStrs [] = { "0", "1", "err", "NA" }
 string representation of the N2k enum tN2kOnOff More...
 
const char * tN2kPressureStrs [] = { "atmospheric", "water", "steam", "compressed air", "hydraulic", "filter", "altimete setting", "oil", "fuel" }
 string representation of the N2k enum tN2kPressureSource More...
 
const char * tN2kRudderDirectionOrderStrs [] = { "no direction order", "move to starboard", "move to port" }
 string representation of the N2k enum tN2kRudderDirectionOrder More...
 
const char * tN2kSpeedWaterReferenceTypeStrs [] = {"Paddle wheel","Pitot tube","Doppler","Correlation (ultra sound)","Electro Magnetic"}
 string representation of the N2k enum tN2kSpeedWaterReferenceType More...
 
const char * tN2kTempSourceStrs []
 string representation of the N2k enum tN2kTempSource More...
 
const char * tN2kTimeSourceStrs [] = { "GPS", "GLONASS", "radio station", "local cesium clock", "local rubidium clock", "local crystal clock" }
 string representation of the N2k enum tN2kTimeSource More...
 
const char * tN2kTransmissionGearStrs [] = { "forward", "neutral", "reverse", "unknown"}
 string representation of the N2k enum tN2kTransmissionGear More...
 
const char *const tN2kXTEModeStrs [] = { "Autonomous", "Differential", "Estimated", "Simulator" }
 string representation of the N2k enum tN2kXTEModeStrs More...
 

Detailed Description

This File contains functions to convert enums from N2kMessages.h to const char.

This is collection of functions for handling enums of NMEA2000 bus messages. There are basically 2 functions in the library to convert enums derived from N2kMessages to const char *:

const char * N2kEnumTypeToStr(enumType enumVal)

This functions returns a const char * value thats representing the given enum Value. By detecting the enumType, the right text output is chosen.

void PrintN2kEnumType (T a, Stream *OutputStream, bool addLF=true)

This prints the corresponding text output to the given output stream.

Note
If you do not need enums in clear text, you do not need this library.

Definition in file N2kMessagesEnumToStr.h.

Macro Definition Documentation

◆ MakeN2kEnumTypeToStrFunc

#define MakeN2kEnumTypeToStrFunc (   enumType,
  strs 
)
Value:
const char * N2kEnumTypeToStr(enumType enumVal) { \
if ( enumVal<(sizeof(strs)/sizeof(const char *)) ) { \
return strs[enumVal]; \
} else { return N2kEnumTypeEmpty; }\
}
const char * N2kEnumTypeEmpty
Default value if no string representation is found.

Macro function for converting various N2k Enums to a const char.

This generic macro defines a way to use a specific version of N2kEnumTypeToStr(enumType enumVal) depending on which enumType is given as parameter.

In NMEA2000 messages there are several enumerations defined and used for the states of different systems. E.g tN2kBatType holds all the available battery types like "flooded", "gel", "AGM". If you need the "real" values of these enums written to a string (e.g. for debugging), you can use these functions.

Usage of the function N2kEnumTypeToStr(enumType enumVal):

const char* tmp;
tmp = N2kEnumTypeToStr(batCem);
Serial.print(tmp); // Output to serial => Gel
@ N2kDCbt_Gel
battery type is GEL
Definition: N2kTypes.h:308
tN2kBatType
Enumeration of Battery types according to PGN 127513.
Definition: N2kTypes.h:306

Definition at line 102 of file N2kMessagesEnumToStr.h.

Function Documentation

◆ MakeN2kEnumTypeToStrFunc() [1/19]

MakeN2kEnumTypeToStrFunc ( tN2kBatChem  ,
tN2kBatChemStrs   
)

Converting the N2k enum tN2kBatChem to a const char.

◆ MakeN2kEnumTypeToStrFunc() [2/19]

MakeN2kEnumTypeToStrFunc ( tN2kBatEqSupport  ,
tN2kBatEqSupportStrs   
)

Converting the N2k enum tN2kBatEqSupport to a const char.

◆ MakeN2kEnumTypeToStrFunc() [3/19]

MakeN2kEnumTypeToStrFunc ( tN2kBatNomVolt  ,
tN2kBatNomVoltStrs   
)

Converting the N2k enum tN2kBatNomVolt to a const char.

◆ MakeN2kEnumTypeToStrFunc() [4/19]

MakeN2kEnumTypeToStrFunc ( tN2kBatType  ,
tN2kBatTypeStrs   
)

Converting the N2k enum tN2kBatType to a const char.

◆ MakeN2kEnumTypeToStrFunc() [5/19]

MakeN2kEnumTypeToStrFunc ( tN2kDCType  ,
tN2kDCTypeStrs   
)

Converting the N2k enum tN2kDCType to a const char.

◆ MakeN2kEnumTypeToStrFunc() [6/19]

MakeN2kEnumTypeToStrFunc ( tN2kFluidType  ,
tN2kFluidTypeStrs   
)

Converting the N2k enum tN2kFluidType to a const char.

◆ MakeN2kEnumTypeToStrFunc() [7/19]

MakeN2kEnumTypeToStrFunc ( tN2kGNSSmethod  ,
tN2kGNSSmethodStrs   
)

Converting the N2k enum tN2kGNSSmethod to a const char.

◆ MakeN2kEnumTypeToStrFunc() [8/19]

MakeN2kEnumTypeToStrFunc ( tN2kGNSStype  ,
tN2kGNSStypeStrs   
)

Converting the N2k enum tN2kTimeSource to a const char.

◆ MakeN2kEnumTypeToStrFunc() [9/19]

MakeN2kEnumTypeToStrFunc ( tN2kHeadingReference  ,
tN2kHeadingReferenceStrs   
)

Converting the N2k enum tN2kHeadingReference to a const char.

◆ MakeN2kEnumTypeToStrFunc() [10/19]

MakeN2kEnumTypeToStrFunc ( tN2kHumiditySource  ,
tN2kHumidityStrs   
)

Converting the N2k enum tN2kHumiditySource to a const char.

◆ MakeN2kEnumTypeToStrFunc() [11/19]

MakeN2kEnumTypeToStrFunc ( tN2kMagneticVariation  ,
tN2kSpeedWaterReferenceTypeStrs   
)

Converting the N2k enum tN2kMagneticVariation to a const char.

◆ MakeN2kEnumTypeToStrFunc() [12/19]

MakeN2kEnumTypeToStrFunc ( tN2kOnOff  ,
tN2kOnOffStrs   
)

Converting the N2k enum tN2kOnOff to a const char.

◆ MakeN2kEnumTypeToStrFunc() [13/19]

MakeN2kEnumTypeToStrFunc ( tN2kPressureSource  ,
tN2kPressureStrs   
)

Converting the N2k enum tN2kPressureSource to a const char.

◆ MakeN2kEnumTypeToStrFunc() [14/19]

MakeN2kEnumTypeToStrFunc ( tN2kRudderDirectionOrder  ,
tN2kRudderDirectionOrderStrs   
)

Converting the N2k enum tN2kRudderDirectionOrder to a const char.

◆ MakeN2kEnumTypeToStrFunc() [15/19]

MakeN2kEnumTypeToStrFunc ( tN2kSpeedWaterReferenceType  ,
tN2kSpeedWaterReferenceTypeStrs   
)

Converting the N2k enum tN2kSpeedWaterReferenceType to a const char.

◆ MakeN2kEnumTypeToStrFunc() [16/19]

MakeN2kEnumTypeToStrFunc ( tN2kTempSource  ,
tN2kTempSourceStrs   
)

Converting the N2k enum tN2kTempSource to a const char.

◆ MakeN2kEnumTypeToStrFunc() [17/19]

MakeN2kEnumTypeToStrFunc ( tN2kTimeSource  ,
tN2kTimeSourceStrs   
)

Converting the N2k enum tN2kTimeSource to a const char.

◆ MakeN2kEnumTypeToStrFunc() [18/19]

MakeN2kEnumTypeToStrFunc ( tN2kTransmissionGear  ,
tN2kTransmissionGearStrs   
)

Converting the N2k enum tN2kTransmissionGear to a const char.

◆ MakeN2kEnumTypeToStrFunc() [19/19]

MakeN2kEnumTypeToStrFunc ( tN2kXTEMode  ,
tN2kXTEModeStrs   
)

Converting the N2k enum tN2kXTEModeStrs to a const char.

◆ PrintN2kEnumType()

template<typename T >
void PrintN2kEnumType ( a,
Stream *  OutputStream,
bool  addLF = true 
)

Print function for the enum values.

This function template generation an text output to the defined stream. Corresponding to the type of the enum value, the correct function (and therefore output text) is chosen.

Template Parameters
TType of the enum
Parameters
aenum value
OutputStreamstream handler for the output
addLFadd a line feed (default = true)

Definition at line 69 of file N2kMessagesEnumToStr.h.

Variable Documentation

◆ N2kEnumTypeEmpty

const char* N2kEnumTypeEmpty =""

Default value if no string representation is found.

Definition at line 55 of file N2kMessagesEnumToStr.h.

◆ tN2kBatChemStrs

const char* tN2kBatChemStrs[] = { "lead acid", "LiIon", "NiCad", "NiMh"}

string representation of the N2k enum tN2kBatChem

Definition at line 198 of file N2kMessagesEnumToStr.h.

◆ tN2kBatEqSupportStrs

const char* tN2kBatEqSupportStrs[] = { "no", "yes", "error"}

string representation of the N2k enum tN2kBatEqSupport

Definition at line 180 of file N2kMessagesEnumToStr.h.

◆ tN2kBatNomVoltStrs

const char* tN2kBatNomVoltStrs[] = { "6V", "12V", "24V", "32V", "62V", "42V", "48V"}

string representation of the N2k enum tN2kBatNomVolt

Definition at line 189 of file N2kMessagesEnumToStr.h.

◆ tN2kBatTypeStrs

const char* tN2kBatTypeStrs[] = { "flooded", "gel", "AGM"}

string representation of the N2k enum tN2kBatType

Definition at line 171 of file N2kMessagesEnumToStr.h.

◆ tN2kDCTypeStrs

const char* tN2kDCTypeStrs[] = { "battery", "altenator", "converter", "solar cell", "wind generator"}

string representation of the N2k enum tN2kDCType

Definition at line 207 of file N2kMessagesEnumToStr.h.

◆ tN2kFluidTypeStrs

const char* tN2kFluidTypeStrs[]
Initial value:
= { "Fuel", "Water", "Gray water", "Live well", "Oil", "Black water", "Gasoline Fuel",
"Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved",
"Error", "Unavailable",}

string representation of the N2k enum tN2kFluidType

Definition at line 150 of file N2kMessagesEnumToStr.h.

◆ tN2kGNSSmethodStrs

const char* tN2kGNSSmethodStrs[] = { "no GNSS", "GNSS fix", "DGNSS", "precise GNSS" }

string representation of the N2k enum tN2kGNSSmethod

Definition at line 141 of file N2kMessagesEnumToStr.h.

◆ tN2kGNSStypeStrs

const char* tN2kGNSStypeStrs[] = { "GPS", "GLONASS", "GPS+GLONASS", "GPS+SBAS/WAAS", "GPS+SBAS/WAAS+GLONASS", "Chayka", "integrated", "surveyed", "Galileo" }

string representation of the N2k enum tN2kGNSStype

Definition at line 132 of file N2kMessagesEnumToStr.h.

◆ tN2kHeadingReferenceStrs

const char* tN2kHeadingReferenceStrs[] = { "true", "magnetic" }

string representation of the N2k enum tN2kHeadingReference

Definition at line 112 of file N2kMessagesEnumToStr.h.

◆ tN2kHumidityStrs

const char* tN2kHumidityStrs[] = { "inside", "outside" }

string representation of the N2k enum tN2kHumiditySource

Definition at line 243 of file N2kMessagesEnumToStr.h.

◆ tN2kMagneticVariationStrs

const char* tN2kMagneticVariationStrs[] = { "Manual","Automatic Chart","Automatic Table","Automatic Calculation","WMM 2000","WMM 2005","WMM 2010","WMM 2015","WMM 2020" }

string representation of the N2k enum tN2kMagneticVariation

Definition at line 271 of file N2kMessagesEnumToStr.h.

◆ tN2kOnOffStrs

const char* tN2kOnOffStrs[] = { "0", "1", "err", "NA" }

string representation of the N2k enum tN2kOnOff

Definition at line 225 of file N2kMessagesEnumToStr.h.

◆ tN2kPressureStrs

const char* tN2kPressureStrs[] = { "atmospheric", "water", "steam", "compressed air", "hydraulic", "filter", "altimete setting", "oil", "fuel" }

string representation of the N2k enum tN2kPressureSource

Definition at line 234 of file N2kMessagesEnumToStr.h.

◆ tN2kRudderDirectionOrderStrs

const char* tN2kRudderDirectionOrderStrs[] = { "no direction order", "move to starboard", "move to port" }

string representation of the N2k enum tN2kRudderDirectionOrder

Definition at line 252 of file N2kMessagesEnumToStr.h.

◆ tN2kSpeedWaterReferenceTypeStrs

const char* tN2kSpeedWaterReferenceTypeStrs[] = {"Paddle wheel","Pitot tube","Doppler","Correlation (ultra sound)","Electro Magnetic"}

string representation of the N2k enum tN2kSpeedWaterReferenceType

Definition at line 261 of file N2kMessagesEnumToStr.h.

◆ tN2kTempSourceStrs

const char* tN2kTempSourceStrs[]
Initial value:
= { "sea", "outside", "inside", "engine room", "main cabin", "live well", "bait well", "refridgeration",
"heating system", "dew point", "apparent wind chill", "theoretical wind chill", "heat index", "freezer", "exhaust gas"}

string representation of the N2k enum tN2kTempSource

Definition at line 161 of file N2kMessagesEnumToStr.h.

◆ tN2kTimeSourceStrs

const char* tN2kTimeSourceStrs[] = { "GPS", "GLONASS", "radio station", "local cesium clock", "local rubidium clock", "local crystal clock" }

string representation of the N2k enum tN2kTimeSource

Definition at line 122 of file N2kMessagesEnumToStr.h.

◆ tN2kTransmissionGearStrs

const char* tN2kTransmissionGearStrs[] = { "forward", "neutral", "reverse", "unknown"}

string representation of the N2k enum tN2kTransmissionGear

Definition at line 216 of file N2kMessagesEnumToStr.h.

◆ tN2kXTEModeStrs

const char* const tN2kXTEModeStrs[] = { "Autonomous", "Differential", "Estimated", "Simulator" }

string representation of the N2k enum tN2kXTEModeStrs

Definition at line 280 of file N2kMessagesEnumToStr.h.