Skip to content

Commit

Permalink
Added to API -- Optional message lists
Browse files Browse the repository at this point in the history
Added two APIs to allow setting of SingleFrameMessages and
FastPacketMessages arrays.  Allows for extension (and editing) of
supported messages.
  • Loading branch information
thomasonw committed Jul 12, 2016
1 parent 23bc3c6 commit d80b511
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 12 additions & 8 deletions NMEA2000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,24 @@ void ClearSetCharBuf(const char *str, int MaxLen, char *buf) {
if (str) SetCharBuf(str,MaxLen,buf);
}


//*****************************************************************************
void SetMsgBuf(const unsigned long *msgs, int MaxLen, unsigned long* buf) {
for (int i=0; i<MaxLen-1 && msgs[i]!=0; i++) buf[i]=msgs[i];
buf[MaxLen]=0;
void tNMEA2000::SetSingleFrameMessages(const unsigned long *_SingleFrameMessages) {
SingleFrameMessages=_SingleFrameMessages;
if (SingleFrameMessages==0) SingleFrameMessages=DefSingleFrameMessages;
}


//*****************************************************************************
void tNMEA2000::SetFastPacketMessages(const unsigned long *_FastPacketMessages) {
FastPacketMessages=_FastPacketMessages;
if (FastPacketMessages==0) FastPacketMessages=DefFastPacketMessages;
}

//*****************************************************************************
tNMEA2000::tNMEA2000() {
// Point for message code buffers was that developer can dynamically change them.
// Currentrly there has not been any need for that, so due to ram optmization do it later.

SingleFrameMessages=DefSingleFrameMessages;
FastPacketMessages=DefFastPacketMessages;
//SetMsgBuf(DefSingleFrameMessages,Max_N2kSingleFrameMessages_len,SingleFrameMessages);
//SetMsgBuf(DefFastPacketMessages,Max_N2kFastPacketMessages_len,FastPacketMessages);

N2kCANMsgBuf=0;
MaxN2kCANMsgs=0;
Expand Down
6 changes: 5 additions & 1 deletion NMEA2000.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ class tNMEA2000
// Note that I have not yet found a way to test is pointer in PROGMEM or not, so this does not work, if you define
// tProductInformation to RAM.
void SetProductInformation(const tProductInformation *_ProductInformation);


// Call these if you wish to modify the default message packets supported. Pointers must be in PROGMEM
void SetSingleFrameMessages(const unsigned long *_SingleFrameMessages);
void SetFastPacketMessages (const unsigned long *_FastPacketMessages);

// Set default device information.
// For keeping defaults use 0xffff/0xff for int/char values and nul ptr for pointers.
// Note that ManufacturerCode and UniqueNumber should give unic result on any network.
Expand Down

0 comments on commit d80b511

Please sign in to comment.