Skip to content

Commit

Permalink
Some small improvements and document update
Browse files Browse the repository at this point in the history
- Added entertainment fastpacket PGNs to fastpacket list.
- Added electric fastpcket PGNs 127490, 127491, 127494, 127495 to fastpacket list.
- Added elevator fastpacket PGN 128538 to fastpacket list.
- Moved FindSourceDeviceIndex to public
- Added IsOpen
- Added GetForwardStream
- Document update by trixpan
- Added fluid type enum to N2kMessagesEnumToStr.h
- Added support for NMEA2000_ArduinoCAN to NMEA2000_CAN.h by jboynes
  • Loading branch information
ttlappalainen committed Dec 8, 2023
1 parent 89b451e commit 1199e82
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 22 deletions.
12 changes: 12 additions & 0 deletions Documents/src/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changes to the Library {#changes}
\tableofcontents
## 08.12.2023

- Added entertainment fastpacket PGNs to fastpacket list.
- Added electric fastpcket PGNs 127490, 127491, 127494, 127495 to fastpacket list.
- Added elevator fastpacket PGN 128538 to fastpacket list.
- Moved FindSourceDeviceIndex to public
- Added IsOpen
- Added GetForwardStream
- Document update by trixpan
- Added fluid type enum to N2kMessagesEnumToStr.h
- Added support for NMEA2000_ArduinoCAN to NMEA2000_CAN.h by jboynes

## 04.10.2023

- Fix use N2kMillis instead of millis on N2kDeviceList by nicklasb.
Expand Down
51 changes: 42 additions & 9 deletions src/NMEA2000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ void N2kPrintFreeMemory(const char *Source) {
#define MaxHeartbeatInterval 655320UL

/** \brief Max frames, which can be received at time */
#define TP_MAX_FRAMES 5
#define TP_MAX_FRAMES 5
/** \brief Multi packet connection management, TP.CM */
#define TP_CM 60416L
#define TP_CM 60416L
/** \brief Multi packet data transfer */
#define TP_DT 60160L
#define TP_DT 60160L
/** \brief Multi packet connection management, Broadcast Announce Message */
#define TP_CM_BAM 32
/** \brief Multi packet connection management, Request To Send */
Expand All @@ -130,13 +130,13 @@ void N2kPrintFreeMemory(const char *Source) {

/** \brief Already in one or more connection managed sessions and cannot
* support another */
#define TP_CM_AbortBusy 1
#define TP_CM_AbortBusy 1
/** \brief System resources were needed for another task so this connection
* managed session was terminated */
#define TP_CM_AbortNoResources 2
#define TP_CM_AbortNoResources 2
/** \brief A timeout occurred and this is the connection abort to close the s
* ession */
#define TP_CM_AbortTimeout 3
#define TP_CM_AbortTimeout 3

/************************************************************************//**
* \
Expand Down Expand Up @@ -339,6 +339,10 @@ bool IsMandatoryFastPacketMessage(unsigned long PGN) {
* - 127233L: Man Overboard Notification(MOB), pri=3, period=NA
* - 127237L: Heading/Track control, pri=2, period=250
* - 127489L: Engine parameters dynamic, pri=2, period=500
* - 127490L: Electric Drive Status (Dynamic), pri=1, period=1500
* - 127491L: Electric Energy Storage Status (Dynamic), pri=7, period=1500
* - 127494L: Electric Drive Information, pri=4, period=NA
* - 127495L: Electric Energy Storage Information, pri=6, period=NA
* - 127496L: Trip fuel consumption, vessel, pri=5, period=1000
* - 127497L: Trip fuel consumption, engine, pri=5, period=1000
* - 127498L: Engine parameters static, pri=5, period=NA
Expand All @@ -353,7 +357,8 @@ bool IsMandatoryFastPacketMessage(unsigned long PGN) {
* - 127513L: Battery configuration status, pri=6, period=NA
* - 127514L: AGS Status, pri=6, period=1500
* - 128275L: Distance log, pri=6, period=1000
* - 128520L: Tracked Target Data, pri=2, period=1000
* - 128520L: Tracked target data, pri=2, period=1000
* - 128538L: Elevator car status, pri=6, period=100
* - 129029L: GNSS Position Data, pri=3, period=1000
* - 129038L: AIS Class A Position Report, pri=4, period=NA
* - 129039L: AIS Class B Position Report, pri=4, period=NA
Expand Down Expand Up @@ -420,7 +425,18 @@ bool IsMandatoryFastPacketMessage(unsigned long PGN) {
* - 130567L: Watermaker Input Setting and Status, pri=6, period=2500
* - 130577L: Direction Data PGN, pri=3, period=1000
* - 130578L: Vessel Speed Components, pri=2, period=250
* \return false
* - 130569L: Current File and Status, pri=6, period=500
* - 130570L: Library Data File, pri=6, period=NA
* - 130571L: Library Data Group, pri=6, period=NA
* - 130572L: Library Data Search, pri=6, period=NA
* - 130573L: Supported Source Data, pri=6, period=NA
* - 130574L: Supported Zone Data, pri=6, period=NA
* - 130580L: System Configuration Status, pri=6, period=NA
* - 130581L: Zone Configuration Status, pri=6, period=NA
* - 130583L: Available Audio EQ Presets, pri=6, period=NA
* - 130584L: Bluetooth Devices, pri=6, period=NA
* - 130586L: Zone Configuration Status, pri=6, period=NA
* \return false
*/
bool IsDefaultFastPacketMessage(unsigned long PGN) {
switch (PGN) {
Expand All @@ -433,6 +449,10 @@ bool IsDefaultFastPacketMessage(unsigned long PGN) {
case 127233L: // Man Overboard Notification(MOB), pri=3, period=NA
case 127237L: // Heading/Track control, pri=2, period=250
case 127489L: // Engine parameters dynamic, pri=2, period=500
case 127490L: // Electric Drive Status (Dynamic), pri=1, period=1500
case 127491L: // Electric Energy Storage Status (Dynamic), pri=7, period=1500
case 127494L: // Electric Drive Information, pri=4, period=NA
case 127495L: // Electric Energy Storage Information, pri=6, period=NA
case 127496L: // Trip fuel consumption, vessel, pri=5, period=1000
case 127497L: // Trip fuel consumption, engine, pri=5, period=1000
case 127498L: // Engine parameters static, pri=5, period=NA
Expand All @@ -448,6 +468,7 @@ bool IsDefaultFastPacketMessage(unsigned long PGN) {
case 127514L: // AGS Status, pri=6, period=1500
case 128275L: // Distance log, pri=6, period=1000
case 128520L: // Tracked Target Data, pri=2, period=1000
case 128538L: // Elevator car status, pri=6, period=100
case 129029L: // GNSS Position Data, pri=3, period=1000
case 129038L: // AIS Class A Position Report, pri=4, period=NA
case 129039L: // AIS Class B Position Report, pri=4, period=NA
Expand Down Expand Up @@ -514,6 +535,18 @@ bool IsDefaultFastPacketMessage(unsigned long PGN) {
case 130567L: // Watermaker Input Setting and Status, pri=6, period=2500
case 130577L: // Direction Data PGN, pri=3, period=1000
case 130578L: // Vessel Speed Components, pri=2, period=250
// Entertainment PGNs
case 130569L: // Current File and Status, pri=6, period=500
case 130570L: // Library Data File, pri=6, period=NA
case 130571L: // Library Data Group, pri=6, period=NA
case 130572L: // Library Data Search, pri=6, period=NA
case 130573L: // Supported Source Data, pri=6, period=NA
case 130574L: // Supported Zone Data, pri=6, period=NA
case 130580L: // System Configuration Status, pri=6, period=NA
case 130581L: // Zone Configuration Status, pri=6, period=NA
case 130583L: // Available Audio EQ Presets, pri=6, period=NA
case 130584L: // Bluetooth Devices, pri=6, period=NA
case 130586L: // Zone Configuration Status, pri=6, period=NA
return true;
}
return false;
Expand Down Expand Up @@ -2009,7 +2042,7 @@ uint8_t tNMEA2000::SetN2kCANBufMsg(unsigned long canId, unsigned char len, unsig
}

//*****************************************************************************
int tNMEA2000::FindSourceDeviceIndex(unsigned char Source) {
int tNMEA2000::FindSourceDeviceIndex(unsigned char Source) const {
int i=DeviceCount;

if ( Source<=253 ) {
Expand Down
51 changes: 38 additions & 13 deletions src/NMEA2000.h
Original file line number Diff line number Diff line change
Expand Up @@ -732,14 +732,22 @@ class tNMEA2000

/************************************************************************//**
* \enum tOpenState
* \brief State of ...
* \brief Library open state.
*
* \todo Finalize Description....
* Open state is internal library open state used to avoid anu blocking call.
*/
typedef enum {
/** Open has not yet been called. Buffers are still uninitialized.
*/
os_None ///< State none
/** Trying to open CAN driver.
*/
,os_OpenCAN ///< State Open CAN
/** CAN driver open succeed. Wait CAN driver stabilize.
*/
,os_WaitOpen ///< State Wait Open
/** Open and running.
*/
,os_Open ///< State Open
} tOpenState;

Expand Down Expand Up @@ -1417,14 +1425,6 @@ class tNMEA2000
*/
bool IsMySource(unsigned char Source);

/**********************************************************************//**
* \brief Finds a device on \ref Devices by its source address
*
* \param Source Source address of the device
* \return int DeviceIndex, not found = -1
*/
int FindSourceDeviceIndex(unsigned char Source);

/**********************************************************************//**
* \brief Get the Sequence Counter for the PGN
*
Expand Down Expand Up @@ -1684,6 +1684,14 @@ class tNMEA2000
*/
tNMEA2000();

/**********************************************************************//**
* \brief Finds a device on \ref Devices by its source address
*
* \param Source Source address of the device
* \return int DeviceIndex, not found = -1
*/
int FindSourceDeviceIndex(unsigned char Source) const;

/*********************************************************************//**
* \brief Set the Device Counter
*
Expand All @@ -1700,8 +1708,6 @@ class tNMEA2000
*/
void SetDeviceCount(const uint8_t _DeviceCount);

//

/*********************************************************************//**
* \brief Set the maximum buffersize of \ref N2kCANMsgBuf
*
Expand Down Expand Up @@ -2431,6 +2437,13 @@ class tNMEA2000
*/
void SetForwardStream(N2kStream* _stream) { ForwardStream=_stream; }

/*********************************************************************//**
* \brief Read current Forward Stream object
*
* \return current Forward Stream object or 0 if not set.
*/
N2kStream* GetForwardStream() const { return ForwardStream; }

/*********************************************************************//**
* \brief Open the CAN device
*
Expand All @@ -2445,6 +2458,14 @@ class tNMEA2000
*/
bool Open();

/*********************************************************************//**
* \brief Test is NMEA2000 open and running.
*
* \return true
* \return false
*/
inline bool IsOpen() const { return OpenState==os_Open; }

/*********************************************************************//**
* \brief Restart the device
*
Expand Down Expand Up @@ -2482,7 +2503,11 @@ class tNMEA2000
* See example TemperatureMonitor.ino.
*
* \param N2kMsg Reference to a N2kMsg Object
* \param DeviceIndex index of the device on \ref Devices
* \param DeviceIndex index of the device on \ref Devices \n
* Setting DeviceIndex to -1 forces library
* to use source address of N2kMsg instead of
* device source address. This is usefull with
* e.g., passthrough gateway devices.
* \return true -> Success
* \return false
*/
Expand Down

0 comments on commit 1199e82

Please sign in to comment.