-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'lib/NMEA2000/' changes from 6835188..38d46ed
38d46ed Compiler warning fixes 0d805a1 Fixes 3be0ec7 Arduino DUE CAN library update 605b6c3 Fix PGN 128259 send length to 8 a332640 Fixes and new features c66e927 Merge pull request #62 from sarfata/do-not-override-esp8266-pgm-definitions bd372f3 Merge pull request #63 from sarfata/bugfix/respond-to-query-sent-to-broadcast 61daf41 Fix a bug where we do not respond to info request sent to broadcast 2b31958 The Arduino framework for ESP8266 defines pgm_* git-subtree-dir: lib/NMEA2000 git-subtree-split: 38d46ed67bbd72ddb2a58c2e83dbfb28fa0a979c
- Loading branch information
Showing
17 changed files
with
1,189 additions
and
245 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#include <Arduino.h> | ||
#define N2k_CAN_INT_PIN 21 | ||
#include <NMEA2000_CAN.h> // This will automatically choose right CAN library and create suitable NMEA2000 object | ||
#include "N2kDeviceList.h" | ||
|
||
tN2kDeviceList *pN2kDeviceList; | ||
Stream *OutputStream; | ||
|
||
//***************************************************************************** | ||
template<typename T> void PrintLabelValWithConversionCheckUnDef(const char* label, T val, double (*ConvFunc)(double val)=0, bool AddLf=false ) { | ||
OutputStream->print(label); | ||
if (!N2kIsNA(val)) { | ||
if (ConvFunc) { OutputStream->print(ConvFunc(val)); } else { OutputStream->print(val); } | ||
} else OutputStream->print("not available"); | ||
if (AddLf) OutputStream->println(); | ||
} | ||
|
||
//***************************************************************************** | ||
void setup() { | ||
Serial.begin(115200); | ||
OutputStream=&Serial; | ||
Serial.println("Device analyzer is starting up..."); | ||
delay(3000); | ||
NMEA2000.SetN2kCANReceiveFrameBufSize(150); | ||
NMEA2000.SetN2kCANMsgBufSize(8); | ||
// Set Product information | ||
NMEA2000.SetProductInformation("00000003", // Manufacturer's Model serial code | ||
100, // Manufacturer's product code | ||
"N2k bus device analyzer", // Manufacturer's Model ID | ||
"1.0.0.10 (2017-07-29)", // Manufacturer's Software version code | ||
"1.0.0.0 (2017-07-12)" // Manufacturer's Model version | ||
); | ||
|
||
// Set device information | ||
NMEA2000.SetDeviceInformation(2, // Unique number. Use e.g. Serial number. | ||
130, // Device function=Display. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf | ||
120, // Device class=Display. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf | ||
2046 // Just choosen free from code list on http://www.nmea.org/Assets/20121020%20nmea%202000%20registration%20list.pdf | ||
); | ||
// Uncomment 3 rows below to see, what device will send to bus | ||
|
||
NMEA2000.SetForwardStream(0); //&Serial); | ||
NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text. Leave uncommented for default Actisense format. | ||
// NMEA2000.SetForwardOwnMessages(); | ||
|
||
NMEA2000.EnableForward(false); | ||
NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode, 50); | ||
pN2kDeviceList = new tN2kDeviceList(&NMEA2000); | ||
NMEA2000.Open(); | ||
Serial.println("Device analyzer started"); | ||
} | ||
|
||
//***************************************************************************** | ||
void PrintUlongList(const char *prefix, const unsigned long * List) { | ||
uint8_t i; | ||
if ( List!=0 ) { | ||
Serial.print(prefix); | ||
for (i=0; List[i]!=0; i++) { | ||
if (i>0) Serial.print(", "); | ||
Serial.print(List[i]); | ||
} | ||
Serial.println(); | ||
} | ||
} | ||
|
||
//***************************************************************************** | ||
void PrintDevice(const tNMEA2000::tDevice *pDevice) { | ||
if ( pDevice == 0 ) return; | ||
|
||
Serial.println(pDevice->GetModelID()); | ||
Serial.print(" Source: "); Serial.println(pDevice->GetSource()); | ||
Serial.print(" Manufacturer code: "); Serial.println(pDevice->GetManufacturerCode()); | ||
Serial.print(" Unique number: "); Serial.println(pDevice->GetUniqueNumber()); | ||
Serial.print(" Software version: "); Serial.println(pDevice->GetSwCode()); | ||
Serial.print(" Model version: "); Serial.println(pDevice->GetModelVersion()); | ||
Serial.print(" Manufacturer Information: "); Serial.println(pDevice->GetManufacturerInformation()); | ||
PrintUlongList(" Transmit PGNs :",pDevice->GetTransmitPGNs()); | ||
PrintUlongList(" Receive PGNs :",pDevice->GetReceivePGNs()); | ||
Serial.println(); | ||
} | ||
|
||
//***************************************************************************** | ||
void ListDevices(bool force = false) { | ||
if ( !force && !pN2kDeviceList->ReadResetIsListUpdated() ) return; | ||
|
||
Serial.println(); | ||
Serial.println("**********************************************************************"); | ||
for (uint8_t i = 0; i < N2kMaxBusDevices; i++) PrintDevice(pN2kDeviceList->FindDeviceBySource(i)); | ||
} | ||
|
||
//***************************************************************************** | ||
void CheckCommand() { | ||
if (Serial.available()) { | ||
char chr = Serial.read(); | ||
switch ( chr ) { | ||
case 'u': ListDevices(true); break; | ||
} | ||
} | ||
} | ||
|
||
//***************************************************************************** | ||
void loop() { | ||
NMEA2000.ParseMessages(); | ||
ListDevices(); | ||
CheckCommand(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.