55#if !defined(N2K_NO_GROUP_FUNCTION_SUPPORT)
59#define N2kPGNIsoAddressClaim 60928L
61#define N2kPGNProductInformation 126996L
63#define N2kPGNConfigurationInformation 126998L
70#define Max_N2kModelID_len 32
74#define Max_N2kSwCode_len 32
78#define Max_N2kModelVersion_len 32
82#define Max_N2kModelSerialCode_len 32
90#define Max_N2kProductInfoStrLen 33
99#define Max_N2kConfigurationInfoField_len 71
102#define Max_N2kMsgBuf_Time 100
104#define N2kMessageGroups 2
106#define N2kMaxCanBusAddress 251
108#define N2kNullCanBusAddress 254
170 static void SetCharBuf(
const char *str,
size_t MaxLen,
char *buf);
181 static void ClearSetCharBuf(
const char *str,
size_t MaxLen,
char *buf);
193 template <
typename T>
static T
N2kMax(T a, T b) {
return (a>b?a:b); }
205 template <
typename T>
static T
N2kMin(T a, T b) {
return (a<b?a:b); }
262 void Set(
const char *_ModelSerialCode,
263 unsigned short _ProductCode=0xffff,
264 const char *_ModelID=0,
265 const char *_SwCode=0,
266 const char *_ModelVersion=0,
267 unsigned char _LoadEquivalency=0xff,
268 unsigned short _N2kVersion=0xffff,
269 unsigned char _CertificationLevel=0xff
271 N2kVersion=(_N2kVersion!=0xffff?_N2kVersion:2101);
349 } tUnionDeviceInformation;
645 PGN=_PGN; pNext=0; pNMEA2000=0;
814#if !defined(N2K_NO_ISO_MULTI_PACKET_SUPPORT)
822#if !defined(N2K_NO_HEARTBEAT_SUPPORT)
824 #define DefaultHeartbeatInterval 60000
844#if !defined(N2K_NO_ISO_MULTI_PACKET_SUPPORT)
848#if !defined(N2K_NO_HEARTBEAT_SUPPORT)
926 #if !defined(N2K_NO_ISO_MULTI_PACKET_SUPPORT)
1079 bool (*
ISORqstHandler)(
unsigned long RequestedPGN,
unsigned char Requester,
int DeviceIndex);
1081#if !defined(N2K_NO_GROUP_FUNCTION_SUPPORT)
1105 virtual bool CANSendFrame(
unsigned long id,
unsigned char len,
const unsigned char *buf,
bool wait_sent=
true)=0;
1135 virtual bool CANGetFrame(
unsigned long &
id,
unsigned char &len,
unsigned char *buf)=0;
1160#if defined(DEBUG_NMEA2000_ISR)
1161 virtual void TestISR() {;}
1186 bool SendFrame(
unsigned long id,
unsigned char len,
const unsigned char *buf,
bool wait_sent=
true);
1236#if !defined(N2K_NO_ISO_MULTI_PACKET_SUPPORT)
1252 void FindFreeCANMsgIndex(
unsigned long PGN,
unsigned char Source,
unsigned char Destination,
bool TPMsg, uint8_t &MsgIndex);
1268 void FindFreeCANMsgIndex(
unsigned long PGN,
unsigned char Source,
unsigned char Destination, uint8_t &MsgIndex);
1283 uint8_t
SetN2kCANBufMsg(
unsigned long canId,
unsigned char len,
unsigned char *buf);
1328 bool CheckKnownMessage(
unsigned long PGN,
bool &SystemMessage,
bool &FastPacket);
1396#if !defined(N2K_NO_GROUP_FUNCTION_SUPPORT)
1610#if !defined(N2K_NO_ISO_MULTI_PACKET_SUPPORT)
1624 bool TestHandleTPMessage(
unsigned long PGN,
unsigned char Source,
unsigned char Destination,
1625 unsigned char len,
unsigned char *buf,
1660 void SendTPCM_CTS(
unsigned long PGN,
unsigned char Destination,
int iDev,
unsigned char nPackets,
unsigned char NextPacketNumber);
1671 void SendTPCM_EndAck(
unsigned long PGN,
unsigned char Destination,
int iDev, uint16_t nBytes,
unsigned char nPackets);
1681 void SendTPCM_Abort(
unsigned long PGN,
unsigned char Destination,
int iDev,
unsigned char AbortCode);
1732#if !defined(N2K_NO_GROUP_FUNCTION_SUPPORT)
1905 unsigned short _ProductCode=0xffff,
1906 const char *_ModelID=0,
1907 const char *_SwCode=0,
1908 const char *_ModelVersion=0,
1909 unsigned char _LoadEquivalency=0xff,
1910 unsigned short _N2kVersion=0xffff,
1911 unsigned char _CertificationLevel=0xff,
1960 const char *InstallationDescription1=0,
1961 const char *InstallationDescription2=0);
1984 const char *InstallationDescription1=0,
1985 const char *InstallationDescription2=0);
1987#if !defined(N2K_NO_GROUP_FUNCTION_SUPPORT)
1997 bool IsTxPGN(
unsigned long PGN,
int iDev=0);
2031 void GetModelID(
char *buf,
size_t max_len,
int iDev=0)
const;
2040 void GetSwCode(
char *buf,
size_t max_len,
int iDev=0)
const;
2334 unsigned char _DeviceFunction=0xff,
2335 unsigned char _DeviceClass=0xff,
2336 uint16_t _ManufacturerCode=0xffff,
2337 unsigned char _IndustryGroup=4,
2360 uint8_t _DeviceInstanceLower=0xff,
2361 uint8_t _DeviceInstanceUpper=0xff,
2362 uint8_t _SystemInstance=0xff,
2398 void SendIsoAddressClaim(
unsigned char Destination=0xff,
int DeviceIndex=0,
unsigned long FromNow=0);
2400#if !defined(N2K_NO_ISO_MULTI_PACKET_SUPPORT)
2439 void SendTxPGNList(
unsigned char Destination,
int DeviceIndex,
bool UseTP=
false);
2451 void SendRxPGNList(
unsigned char Destination,
int DeviceIndex,
bool UseTP=
false);
2453 void SendTxPGNList(
unsigned char Destination,
int DeviceIndex);
2454 void SendRxPGNList(
unsigned char Destination,
int DeviceIndex);
2481#if !defined(N2K_NO_HEARTBEAT_SUPPORT)
2549 void SetHeartbeatInterval(
unsigned long interval,
bool SetAsDefault=
true,
int iDev=-1) __attribute__ ((deprecated));
2793 void SetISORqstHandler(
bool(*ISORequestHandler)(
unsigned long RequestedPGN,
unsigned char Requester,
int DeviceIndex));
2795#if !defined(N2K_NO_GROUP_FUNCTION_SUPPORT)
2990 static bool IsBroadcast(
unsigned char Source) {
return Source==0xff; }
3008void SetN2kPGN59392(
tN2kMsg &N2kMsg,
unsigned char Control,
unsigned char GroupFunction,
unsigned long PGN);
3040 unsigned char DeviceFunction,
unsigned char DeviceClass,
3041 unsigned char DeviceInstance=0,
unsigned char SystemInstance=0,
unsigned char IndustryGroup=4
3064 unsigned char DeviceFunction,
unsigned char DeviceClass,
3065 unsigned char DeviceInstance=0,
unsigned char SystemInstance=0,
unsigned char IndustryGroup=4
3067 SetN2kPGN60928(N2kMsg, UniqueNumber, ManufacturerCode, DeviceFunction, DeviceClass,
3068 DeviceInstance, SystemInstance, IndustryGroup);
3097 const char *ModelID,
const char *SwCode,
3098 const char *ModelVersion,
const char *ModelSerialCode,
3099 unsigned char CertificationLevel=1,
unsigned char LoadEquivalency=1);
3108 const char *ModelID,
const char *SwCode,
3109 const char *ModelVersion,
const char *ModelSerialCode,
3110 unsigned char CertificationLevel=1,
unsigned char LoadEquivalency=1) {
3112 ModelID,SwCode,ModelVersion,ModelSerialCode,
3113 CertificationLevel,LoadEquivalency);
3140 int ModelIDSize,
char *ModelID,
int SwCodeSize,
char *SwCode,
3141 int ModelVersionSize,
char * ModelVersion,
int ModelSerialCodeSize,
char *ModelSerialCode,
3142 unsigned char &CertificationLevel,
unsigned char &LoadEquivalency);
3158 const char *ManufacturerInformation,
3159 const char *InstallationDescription1=0,
3160 const char *InstallationDescription2=0,
3170 const char *ManufacturerInformation,
3171 const char *InstallationDescription1=0,
3172 const char *InstallationDescription2=0,
3173 bool UsePgm=
false) {
3175 ManufacturerInformation,
3176 InstallationDescription1,
3177 InstallationDescription2,
3202 size_t &ManufacturerInformationSize,
char *ManufacturerInformation,
3203 size_t &InstallationDescription1Size,
char *InstallationDescription1,
3204 size_t &InstallationDescription2Size,
char *InstallationDescription2);
File declares tN2kCANMsg class used internally on tNMEA2000.
Base and default group function PGN 126208 message handler class.
tN2kGroupFunctionCode
FunctionCode for the group function.
This File contains the class tN2kMsg and all necessary functions to handle a NMEA2000 Message.
This File contains an I/O stream used in the NMEA2000 libraries.
The file contains function and classes for best timing performance.
void SetN2kProductInformation(tN2kMsg &N2kMsg, unsigned int N2kVersion, unsigned int ProductCode, const char *ModelID, const char *SwCode, const char *ModelVersion, const char *ModelSerialCode, unsigned char CertificationLevel=1, unsigned char LoadEquivalency=1)
Setting up Message "Product information" - PGN 126996.
#define Max_N2kModelSerialCode_len
Max length of SerialCode Document says for length 32 but then values has not been translated right on...
void SetN2kPGNTransmitList(tN2kMsg &N2kMsg, uint8_t Destination, const unsigned long *PGNs)
Setting up Message "PGN List - Transmit PGNs group function" - PGN 126464.
bool ParseN2kPGN126996(const tN2kMsg &N2kMsg, unsigned short &N2kVersion, unsigned short &ProductCode, int ModelIDSize, char *ModelID, int SwCodeSize, char *SwCode, int ModelVersionSize, char *ModelVersion, int ModelSerialCodeSize, char *ModelSerialCode, unsigned char &CertificationLevel, unsigned char &LoadEquivalency)
Parsing the content of message PGN 126996 "Product information".
void SetN2kPGN126993(tN2kMsg &N2kMsg, uint32_t timeInterval_ms, uint8_t sequenceCounter)
Setting up PGN 126993 Message "Heartbeat".
void SetN2kPGN126998(tN2kMsg &N2kMsg, const char *ManufacturerInformation, const char *InstallationDescription1=0, const char *InstallationDescription2=0, bool UsePgm=false)
Setting up PGN 126998 Message "Configuration information".
void SetN2kPGN60928(tN2kMsg &N2kMsg, unsigned long UniqueNumber, int ManufacturerCode, unsigned char DeviceFunction, unsigned char DeviceClass, unsigned char DeviceInstance=0, unsigned char SystemInstance=0, unsigned char IndustryGroup=4)
Setting up PGN 60928 Message "ISO Address Claim".
#define Max_N2kSwCode_len
Max length of Software Code Document says for length 40 but then values has not been translated right...
void SetN2kPGN126464(tN2kMsg &N2kMsg, uint8_t Destination, tN2kPGNList tr, const unsigned long *PGNs)
Setting up PGN 126464 Message "PGN List - Transmit PGNs group function".
void SetN2kConfigurationInformation(tN2kMsg &N2kMsg, const char *ManufacturerInformation, const char *InstallationDescription1=0, const char *InstallationDescription2=0, bool UsePgm=false)
Setting up Message "Configuration information" - PGN 126998.
bool ParseN2kPGN126998(const tN2kMsg &N2kMsg, size_t &ManufacturerInformationSize, char *ManufacturerInformation, size_t &InstallationDescription1Size, char *InstallationDescription1, size_t &InstallationDescription2Size, char *InstallationDescription2)
Parsing the content of message PGN 126998 "Configuration information".
#define N2kMessageGroups
Number of message groups.
#define Max_N2kModelVersion_len
Max length of Model Version Document says for length 24 but then values has not been translated right...
void SetN2kPGN59904(tN2kMsg &N2kMsg, uint8_t Destination, unsigned long RequestedPGN)
Setting up PGN 59904 Message "ISO request".
void SetN2kPGN59392(tN2kMsg &N2kMsg, unsigned char Control, unsigned char GroupFunction, unsigned long PGN)
Setting up PGN 59392 Message "ISO Acknowledgement".
void SetN2kISOAddressClaim(tN2kMsg &N2kMsg, unsigned long UniqueNumber, int ManufacturerCode, unsigned char DeviceFunction, unsigned char DeviceClass, unsigned char DeviceInstance=0, unsigned char SystemInstance=0, unsigned char IndustryGroup=4)
Setting up Message "ISO Address Claim" - PGN 60928.
#define Max_N2kModelID_len
Max length of ModelID Document says for length 33 but then values has not been translated right on de...
void SetHeartbeat(tN2kMsg &N2kMsg, uint32_t timeInterval_ms, uint8_t sequenceCounter)
Setting up Message "Heartbeat" - PGN 126993.
bool ParseN2kPGN59904(const tN2kMsg &N2kMsg, unsigned long &RequestedPGN)
Parsing the content of message PGN 59904 "ISO request".
void SetN2kPGN126996(tN2kMsg &N2kMsg, unsigned int N2kVersion, unsigned int ProductCode, const char *ModelID, const char *SwCode, const char *ModelVersion, const char *ModelSerialCode, unsigned char CertificationLevel=1, unsigned char LoadEquivalency=1)
Setting up PGN 126996 Message "Product information".
void SetN2kPGNISOAcknowledgement(tN2kMsg &N2kMsg, unsigned char Control, unsigned char GroupFunction, unsigned long PGN)
Setting up Message "ISO Acknowledgement" - PGN 59392.
#define N2kMaxCanBusAddress
Max CAN Bus Address given by the library.
bool ParseN2kPGNISORequest(const tN2kMsg &N2kMsg, unsigned long &RequestedPGN)
Parsing the content of a "ISO request" message - PGN 59904.
void SetN2kPGNISORequest(tN2kMsg &N2kMsg, uint8_t Destination, unsigned long RequestedPGN)
Setting up Message "ISO request" - PGN 59904.
tN2kPGNList
Enumeration of types for PGN lists according to PGN 126464.
Specific compiler definition to adapt the library to your needs.
Streaming Class to handle all Streams generated by the Library.
Class used internally on tNMEA2000 to handle incoming NMEA2000 messages.
Base handler class for Group Functions.
This class contains all the data of an NMEA2000 message.
Un synchronized Scheduler which can roll over.
void Disable()
Disable the Scheduler.
bool IsEnabled() const
Check if the scheduler is enabled.
void FromNow(uint32_t _Add)
Set Timestamp for next event relative to now.
bool IsTime() const
Is it time for the next event.
Synchronized Scheduler for timed message sending.
uint32_t GetOffset() const
Get the Offset of the Scheduler.
uint32_t GetPeriod() const
Get the Period of the Scheduler.
Structure holds all the data needed for a valid CAN-Message.
unsigned char buf[8]
Data payload for the CAN Message.
unsigned char len
Length of carried data of the CAN Message.
bool wait_sent
Has the CAN Message to wait before sending.
unsigned long id
ID of the CAN Message.
This class represents a N2k device.
unsigned long GetCreateTime() const
Returns the Time of Creation of this device.
uint8_t GetSource() const
Returns the Source Address of this device.
virtual unsigned short GetProductCode() const =0
Get the product code from the product information of this device.
unsigned char GetIndustryGroup() const
Get the Industry Group from the Device Information.
virtual const unsigned long * GetTransmitPGNs() const
Get the list of transmitted PGNs from this device.
virtual const unsigned long * GetReceivePGNs() const
Get the list of received PGNs from this device.
virtual const char * GetManufacturerInformation() const
Get the manufacturer information from the configuration information of this device.
unsigned char GetSystemInstance() const
Get the System Instance from the Device Information.
uint64_t GetName() const
Get the Name of this device.
unsigned char GetDeviceInstanceUpper() const
Get the Device Instance (upper bits) from the Device Information.
unsigned char GetDeviceInstanceLower() const
Get the Device Instance (lower bits) from the Device Information.
uint8_t Source
Source address on bus for this device.
virtual unsigned short GetCertificationLevel() const =0
Get the certification level from the product information of this device.
virtual const char * GetModelVersion() const =0
Get the model version from the product information of this device.
uint32_t GetUniqueNumber() const
Get the unique Number from the Device Information.
uint16_t GetManufacturerCode() const
Get the Manufacturer Code from the Device Information.
unsigned long CreateTime
Timestamp when this device was created.
unsigned char GetDeviceInstance() const
Get the Device Instance from the Device Information.
virtual const char * GetSwCode() const =0
Get the Software version code from the product information of this device.
virtual const char * GetModelID() const =0
Get the model ID from the product information of this device.
virtual unsigned short GetN2kVersion() const =0
Get N2k Standard version from the product information of this device.
virtual ~tDevice()
Destroy the Device object.
tDeviceInformation DevI
This object holds all necessary device informations.
virtual const char * GetModelSerialCode() const =0
Get the model serial code from the product information of this device.
virtual unsigned short GetLoadEquivalency() const =0
Get the load equivalency from the product information of this device.
unsigned char GetDeviceFunction() const
Get the Device Function from the Device Information.
virtual const char * GetInstallationDescription2() const
Get the installation description 2 from the configuration information of this device.
unsigned char GetDeviceClass() const
Get the Device Class from the Device Information.
bool IsSame(uint64_t Other)
Check if two devices are the same, by comparing the device name.
virtual const char * GetInstallationDescription1() const
Get the installation description 1 from the configuration information of this device.
tDevice(uint64_t _Name, uint8_t _Source=255)
Construct a new Device object.
This class represents an internal device.
void UpdateAddressClaimEndSource()
Updates AddressClaimEndSource.
bool QueryPendingIsoAddressClaim()
Check if enough time has passed.
bool HasPendingInformation
internal device has pending information
const unsigned long * ReceiveMessages
Pointer to a buffer that holds all supported receive PGNs for this device.
tN2kScheduler PendingIsoAddressClaim
Timestamp set while last tNMEA2000::SendIsoAddressClaim was executed.
void ClearPendingConfigurationInformation()
Resets PendingConfigurationInformation to zero.
void SetPendingProductInformation()
Set the timestamp for Pending a ProductInformation message.
void SetPendingConfigurationInformation()
Set the timestamp for Pending a ConfigurationInformation message.
uint8_t NextDTSequence
Next Sequence.
uint8_t HeartbeatSequence
Heartbeat Sequence.
tN2kScheduler NextDTSendTime
Timestamp, when next data packet can be send on TP broadcast.
uint8_t AddressClaimEndSource
Holds the highest source address for Address Claim process.
tProductInformation * LocalProductInformation
This holds all the local (???) Product Informations for this specific device.
char * ManufacturerSerialCode
This holds the Manufacturer Code for this specific device.
tN2kSyncScheduler HeartbeatScheduler
Scheduler for the heartbeat message.
uint8_t N2kSource
Source address of this device on the NMEA2000 bus.
size_t MaxPGNSequenceCounters
Fast packet PGNs sequence counters.
bool QueryPendingProductInformation()
Check if enough time has passed.
const tProductInformation * ProductInformation
This holds all the Product Informations for this specific device.
tN2kScheduler AddressClaimTimer
Timer value for AddressClaim.
void UpdateHasPendingInformation()
bool QueryPendingConfigurationInformation()
Check if enough time has passed.
tN2kMsg PendingTPMsg
Pending N2k message.
tN2kScheduler PendingConfigurationInformation
Timestamp set while last tNMEA2000::SendConfigurationInformation was executed.
tN2kScheduler PendingProductInformation
Timestamp set while last tNMEA2000::SendProductInformation was executed.
tDeviceInformation DeviceInformation
This holds all the Device Informations for this specific device.
const unsigned long * TransmitMessages
Pointer to a buffer that holds all supported transmit PGNs for this device.
void SetPendingIsoAddressClaim(unsigned long FromNow=2)
Set the timestamp for Pending an ISO Address Claim message.
void ClearPendingIsoAddressClaim()
Resets PendingIsoAddressClaim to zero.
unsigned long * PGNSequenceCounters
Fast packet PGNs sequence counters.
void ClearPendingProductInformation()
Resets PendingProductInformation to zero.
tInternalDevice()
Construct a new Internal Device object.
unsigned long GetPGN() const
Return the PGN that is handled by this message handler.
virtual ~tMsgHandler()
Destroys the Message Handler object.
tMsgHandler(unsigned long _PGN=0, tNMEA2000 *_pNMEA2000=0)
Construct a new Message Handler object.
tNMEA2000 * GetNMEA2000()
Returns the tNMEA2000 object of this handler.
virtual void HandleMsg(const tN2kMsg &N2kMsg)=0
Handles a given message *.
tNMEA2000 device class definition.
bool SendTPCM_RTS(int iDev)
Send ISO Transport Protocol message RTS.
bool IsMySource(unsigned char Source)
Checks if the source belongs to a device on Devices.
void SetFastPacketMessages(const unsigned long *_FastPacketMessages)
Set the list of known Fast Packet Messages.
bool IsReadyToSend() const
Checks if the device is ready to start address claiming.
void SendHeartbeat(int iDev)
Send heartbeat for specific device.
void SendPendingInformation()
Send ISO AddressClaim, Product Information and Config Information.
void SetProductInformation(const char *_ModelSerialCode, unsigned short _ProductCode=0xffff, const char *_ModelID=0, const char *_SwCode=0, const char *_ModelVersion=0, unsigned char _LoadEquivalency=0xff, unsigned short _N2kVersion=0xffff, unsigned char _CertificationLevel=0xff, int iDev=0)
Set the Product Information of this device.
bool(* ISORqstHandler)(unsigned long RequestedPGN, unsigned char Requester, int DeviceIndex)
Handler callbacks for 'ISORequest' messages.
static void ClearSetCharBuf(const char *str, size_t MaxLen, char *buf)
Setting up a clean Char Buffer.
bool IsTxPGN(unsigned long PGN, int iDev=0)
Check if this message is a Transmit message of this device.
size_t GetFastPacketTxPGNCount(int iDev)
Get the Fast Packet Tx PGN Count.
int DeviceCount
Number of devices.
static void ClearCharBuf(size_t MaxLen, char *buf)
Clears a char array buffer with 0s.
void InitDevices()
Initialize all devices.
tN2kCANMsg * N2kCANMsgBuf
Buffer for receiving messages.
void ExtendSingleFrameMessages(const unsigned long *_SingleFrameMessages)
Set the list of known Extended Single Frame Messages.
void EnableForward(bool v=true)
Enable message forwarding to stream.
void ParseMessages()
Parse all incoming Messages.
void SetISORqstHandler(bool(*ISORequestHandler)(unsigned long RequestedPGN, unsigned char Requester, int DeviceIndex))
Set the message handler for incoming ISO Requests.
tDebugMode dbMode
Attribute that holds the actual Debug Mode (default = md_none)
void SetDeviceInformation(unsigned long _UniqueNumber, unsigned char _DeviceFunction=0xff, unsigned char _DeviceClass=0xff, uint16_t _ManufacturerCode=0xffff, unsigned char _IndustryGroup=4, int iDev=0)
Set the Device Information. See also NAME.
bool HasAllTPDTSent(int iDev)
Check if all data bytes of the multi packet message has been send successful.
void RemoveGroupFunctionHandler(tN2kGroupFunctionHandler *pGroupFunctionHandler)
Remove a message handler for incoming Group Function messages.
void SetForwardSystemMessages(bool v=true)
Enable System Messages for forwarding.
unsigned int ForwardMode
Actual message forward operation mode (default = all messages - also system and own)
void SetSingleFrameMessages(const unsigned long *_SingleFrameMessages)
Set the list of known Single Frame Messages.
void SetInstallationDescription1(const char *InstallationDescription1)
Set the Installation Description 1 of this device.
const tDeviceInformation GetDeviceInformation(int iDev=0)
Get the Device Information.
void HandleISORequest(const tN2kMsg &N2kMsg)
Handles an ISO Request.
N2kStream * ForwardStream
Actual stream to be used for forward messaging.
void SetMsgHandler(void(*_MsgHandler)(const tN2kMsg &N2kMsg))
Set the message handler for incoming NMEA2000 messages.
static T N2kMax(T a, T b)
Delivers Max out of A an B.
tN2kGroupFunctionHandler * pGroupFunctionHandlers
Pointer to Buffer for GRoup Function Handlers.
void SetForwardStream(N2kStream *_stream)
Set the Forward Stream object.
bool SendFrame(unsigned long id, unsigned char len, const unsigned char *buf, bool wait_sent=true)
Sends a single CAN frame.
bool StartSendTPMessage(const tN2kMsg &msg, int iDev)
Start sending an ISO-TP message.
void HandleGroupFunction(const tN2kMsg &N2kMsg)
Handles a Group Function.
bool SendConfigurationInformation(unsigned char Destination, int DeviceIndex, bool UseTP)
Send a Config Information message.
bool ReadResetInstallationDescriptionChanged()
Check if this device has changed its Install Description.
void SetForwardOnlyKnownMessages(bool v=true)
Enable Only Known Messages for forwarding.
void SetForwardOwnMessages(bool v=true)
Enable Own Messages for forwarding.
bool IsInitialized()
Determines if the CAN BUS is already initialized.
void SetN2kCANMsgBufSize(const uint8_t _MaxN2kCANMsgs)
Set incoming CAN message (tNMEA2000::N2kCANMsgBuf) buffer size.
unsigned char GetCertificationLevel(int iDev=0) const
Get the Certification Level of the device.
void AttachMsgHandler(tMsgHandler *_MsgHandler)
Attach a message handler for incoming N2kMessages.
bool AddressChanged
Flag that the address has changed.
bool CheckKnownMessage(unsigned long PGN, bool &SystemMessage, bool &FastPacket)
Check if this Message is known to the system.
void SetDebugMode(tDebugMode _dbMode)
Set the Debug Mode of the system.
bool IsValidDevice(int iDev) const
Checks if the device index on Devices is valid.
void ExtendReceiveMessages(const unsigned long *_ReceiveMessages, int iDev=0)
Extend the list of Received Messages.
uint8_t MaxN2kCANMsgs
Size of N2kCANMsgBuf receiving message buffer.
virtual bool CANGetFrame(unsigned long &id, unsigned char &len, unsigned char *buf)=0
Abstract class for reading frame from driver class.
static bool IsBroadcast(unsigned char Source)
Checks if the given Address is a broadcast address.
void SendIsoAddressClaim(unsigned char Destination=0xff, int DeviceIndex=0, unsigned long FromNow=0)
Send an IsoAddressClaim message.
N2kStream * GetForwardStream() const
Read current Forward Stream object.
bool ForwardEnabled() const
Is message forwarding enabled.
static const int HandleModeBit_OnlyKnownMessages
Forward mode bit: -> Only known messages will be handled.
bool Open()
Open the CAN device.
tN2kMode
System mode defines how the device will behave on the NMEA2000 bus.
void GetManufacturerInformation(char *buf, size_t max_len)
Get the Manufacturer Information of this device.
void SetHeartbeatInterval(unsigned long interval, bool SetAsDefault=true, int iDev=-1) __attribute__((deprecated))
Deprecated. Use function SetHeartbeatIntervalAndOffset.
virtual void SetN2kCANSendFrameBufSize(const uint16_t _MaxCANSendFrames)
Set CAN send frame buffer size.
bool ForwardSystemMessages() const
Is forwarding enabled for system messages.
tForwardType
Type how to forward messages in listen mode.
void SendPendingTPMessage(int iDev)
Send pending ISO-TP Messages.
void SendTPCM_EndAck(unsigned long PGN, unsigned char Destination, int iDev, uint16_t nBytes, unsigned char nPackets)
Send ISO Transport Protocol message End Acknowledge.
tN2kScheduler OpenScheduler
bool IsFastPacketPGN(unsigned long PGN)
Check if this PNG is a fast packet message.
void AddGroupFunctionHandler(tN2kGroupFunctionHandler *pGroupFunctionHandler)
Add a message handler for incoming Group Function messages.
void Restart()
Restart the device.
bool SendMsg(const tN2kMsg &N2kMsg, int DeviceIndex=0)
Send message to the NMEA2000 bus.
void ExtendTransmitMessages(const unsigned long *_TransmitMessages, int iDev=0)
Extend the list of Transmitted Messages.
uint32_t GetHeartbeatInterval(int iDev=0)
Get the Heartbeat Interval of a device.
bool SendTPDT(int iDev)
Send ISO Transport Protocol data packet.
virtual bool CANOpen()=0
Abstract class for initializing and opening CAN interface.
static bool IsProprietaryMessage(unsigned long PGN)
Check if the given PGN is proprietary.
void HandleISOAddressClaim(const tN2kMsg &N2kMsg)
Handles an IsoAddressClaim.
tNMEA2000()
Construct a new NMEA2000 object.
uint16_t MaxCANSendFrames
Size of CANSendFrameBuf or before initialization requested total frame buffering size.
static const int FwdModeBit_OnlyKnownMessages
Forward mode bit: -> Only known messages will be forwarded. System messages will be forwarded accordi...
void GetInstallationDescription1(char *buf, size_t max_len)
Get the Install Description 1 of this device.
static const int FwdModeBit_SystemMessages
Forward mode bit: -> System messages will be forwarded.
unsigned char GetN2kSource(int DeviceIndex=0) const
Read address for current device.
tOpenState
Library open state.
@ os_OpenCAN
State Open CAN.
@ os_WaitOpen
State Wait Open.
uint16_t CANSendFrameBufferRead
Next write index for the library CAN send frame buffer.
void SetHeartbeatIntervalAndOffset(uint32_t interval, uint32_t offset=0, int iDev=-1)
Set the Heartbeat Interval and Offset for a device.
uint16_t CANSendFrameBufferWrite
Next read index for the library CAN send frame buffer.
bool SendFrames()
Sends pending all frames.
void SetOnOpen(void(*_OnOpen)())
Set OnOpen callback function.
bool IsAddressClaimStarted(int iDev)
Checks if the IsoAddressClaim is already started.
bool IsOpen() const
Test is NMEA2000 open and running.
virtual void SetN2kCANReceiveFrameBufSize(const uint16_t _MaxCANReceiveFrames)
Set CAN receive frame buffer size.
void ExtendFastPacketMessages(const unsigned long *_FastPacketMessages)
Set the list of known Extended Fast Packet Messages.
void RespondISORequest(const tN2kMsg &N2kMsg, unsigned long RequestedPGN, int iDev)
Respond to an ISO request.
void SendRxPGNList(unsigned char Destination, int DeviceIndex, bool UseTP=false)
Send a list with all supported Receive messages.
tMsgHandler * MsgHandlers
Pointer to a buffer for Message Handlers.
uint8_t SetN2kCANBufMsg(unsigned long canId, unsigned char len, unsigned char *buf)
Function handles received CAN frame and adds it to tN2kCANMsg.
void SendTxPGNList(unsigned char Destination, int DeviceIndex, bool UseTP=false)
Send a list with all supported Transmit messages.
void FindFreeCANMsgIndex(unsigned long PGN, unsigned char Source, unsigned char Destination, bool TPMsg, uint8_t &MsgIndex)
Find index for free space for a message on N2kCANMsgBuf.
static T N2kMin(T a, T b)
Delivers Min out of A an B.
void StartAddressClaim()
Starting the ISO Address Claim for all devices.
tCANSendFrame * GetNextFreeCANSendFrame()
Get the Next Free CAN Frame from CANSendFrameBuf.
tConfigurationInformation ConfigurationInformation
Configuration Information of the device.
void SetProgmemConfigurationInformation(const char *ManufacturerInformation, const char *InstallationDescription1=0, const char *InstallationDescription2=0)
Set the Configuration Information located on PROGMEM.
void GetModelVersion(char *buf, size_t max_len, int iDev=0) const
Get the Model Version of the device.
int GetSequenceCounter(unsigned long PGN, int iDev)
Get the Sequence Counter for the PGN.
const tNMEA2000::tProductInformation * GetProductInformation(int iDev, bool &IsProgMem) const
Get the Product Information of the device.
void SendTPCM_Abort(unsigned long PGN, unsigned char Destination, int iDev, unsigned char AbortCode)
Send ISO Transport Protocol message Abort.
void EndSendTPMessage(int iDev)
Ends sending of ISO-TP message.
tForwardType ForwardType
Actual message forward type (default = fwdt_Actisense)
const unsigned long * SingleFrameMessages[N2kMessageGroups]
bool HandleReceivedSystemMessage(int MsgIndex)
Handles a received system message.
tN2kMode N2kMode
Actual operation mode of this device (default = N2km_ListenOnly)
const unsigned long * FastPacketMessages[N2kMessageGroups]
void(* MsgHandler)(const tN2kMsg &N2kMsg)
Handler callbacks for normal messages.
bool HandleOnlyKnownMessages() const
Is handle only known messages enabled.
char * LocalConfigurationInformationData
Pointer to a buffer for local Configuration Information.
static void SetCharBuf(const char *str, size_t MaxLen, char *buf)
Setting up a Char Buffer.
unsigned short GetN2kVersion(int iDev=0) const
Get the N2k standard version of the device.
uint16_t MaxCANReceiveFrames
Max number received CAN messages that can go to the buffer.
int FindSourceDeviceIndex(unsigned char Source) const
Finds a device on Devices by its source address.
bool SendProductInformation(unsigned char Destination, int DeviceIndex, bool UseTP)
Send a Product Information message.
virtual void InitCANFrameBuffers()
Initialize CAN Frame buffers.
bool DeviceInformationChanged
Flag that the device information has changed.
void SendTPCM_CTS(unsigned long PGN, unsigned char Destination, int iDev, unsigned char nPackets, unsigned char NextPacketNumber)
Send ISO Transport Protocol message CTS.
bool SendTPCM_BAM(int iDev)
Send ISO Transport Protocol message BAM.
bool IsActiveNode()
Returns if this node is active on the bus.
void GetModelSerialCode(char *buf, size_t max_len, int iDev=0) const
Get the Model Serial of the device.
bool ReadResetAddressChanged()
Check if this device has changed its address.
void SetHandleOnlyKnownMessages(bool v=true)
Set the Handle Only Known Messages.
void SetMode(tN2kMode _N2kMode, uint8_t _N2kSource=15)
Set the library mode and start source address.
void ForwardMessage(const tN2kMsg &N2kMsg)
Forwards a N2k message.
uint32_t GetHeartbeatOffset(int iDev=0)
Get the Heartbeat Offset of a device.
bool ForwardOnlyKnownMessages() const
Is forwarding enabled for known messages only.
virtual bool CANSendFrame(unsigned long id, unsigned char len, const unsigned char *buf, bool wait_sent=true)=0
Abstract class for sending a CAN Frame.
void SetInstallationDescription2(const char *InstallationDescription2)
Set the Installation Description 2 of this device.
bool TestHandleTPMessage(unsigned long PGN, unsigned char Source, unsigned char Destination, unsigned char len, unsigned char *buf, uint8_t &MsgIndex)
ISO Transport Protocol handlers for multi packet support.
void SetDeviceInformationInstances(uint8_t _DeviceInstanceLower=0xff, uint8_t _DeviceInstanceUpper=0xff, uint8_t _SystemInstance=0xff, int iDev=0)
Set the Device Information Instances.
void HandleCommandedAddress(uint64_t CommandedName, unsigned char NewAddress, int iDev)
Handles if we get commanded to set a new address.
bool IsFastPacket(const tN2kMsg &N2kMsg)
Check if this PNG is a fast packet message.
static const int FwdModeBit_EnableForward
Forward mode bit: -> If set, forward is enabled.
void GetInstallationDescription2(char *buf, size_t max_len)
Get the Install Description 2 of this device.
bool ForwardOwnMessages() const
Is forwarding enabled for own messages.
unsigned short GetProductCode(int iDev=0) const
Get the Product Code of the device.
tDebugMode
For debugging we have some cases for SendMsg.
bool ReadResetDeviceInformationChanged()
Check if this device has changed its DeviceInstances or SystemInstance.
void GetSwCode(char *buf, size_t max_len, int iDev=0) const
Get the Sw Code of the device.
void SetN2kSource(unsigned char _iAddr, int _iDev=0)
Set source for the given device.
void GetModelID(char *buf, size_t max_len, int iDev=0) const
Get the ModelID of the device.
void DetachMsgHandler(tMsgHandler *_MsgHandler)
Detach a message handler for incoming N2kMessages.
bool HandleReceivedMessage(unsigned char Destination)
Should received message be handled depending on the destination of the received message.
void CopyProgmemConfigurationInformationToLocal()
Copy Configuration Information to local memory.
void(* OnOpen)()
Callback function, which will be called when library start bus communication.
unsigned char GetLoadEquivalency(int iDev=0) const
Get the Load Equivalency of this device.
void GetNextAddress(int DeviceIndex, bool RestartAtEnd=false)
Get the next free address for the device.
void RespondGroupFunction(const tN2kMsg &N2kMsg, tN2kGroupFunctionCode GroupFunctionCode, unsigned long PGNForGroupFunction, int iDev)
Respond to an Group Function.
static const int FwdModeBit_OwnMessages
Forward mode bit: -> Forward also all messages, what this device will send.
void SetForwardType(tForwardType fwdType)
Set the Forward Streaming Type.
bool InstallationDescriptionChanged
Flag the Installation description has changed.
void SetConfigurationInformation(const char *ManufacturerInformation, const char *InstallationDescription1=0, const char *InstallationDescription2=0)
Set the Configuration Information of this device.
tInternalDevice * Devices
Pointer to a buffer for all internal devices.
void SetDeviceCount(const uint8_t _DeviceCount)
Set the count of devices library shows on bus.
tCANSendFrame * CANSendFrameBuf
Buffer for library send out CAN frames.
void RunMessageHandlers(const tN2kMsg &N2kMsg)
Run all message handlers.