NMEA 2000 Shield

Hopefully you have enough memory on your system. tN2kDeviceList class is for that purpose and there is example DeviceAnalyzer, where that has been used. You just create object:

pN2kDeviceList = new tN2kDeviceList(&NMEA2000);

and that automatically catches new devices and device changes on the bus. In well made system you should glue your data to NMEA NAME. You can e.g. have two devices sending "PGN 127505 Fluid Level" information from different tanks. And both may have same instance values. So the only way is to separate them by source. But due to address claiming, source may change. So here you can then use

pN2kDeviceList->FindDeviceByName(name);

and you can then get tNMEA2000::tDevice, where you have all information - also source.
You have to also periodically check ReadResetIsListUpdated and if that returs true, you check your watch devices source again.

The class does not have any enumeration function, but due to structure it is as effient to to use:

for ( size_t i=0; i<=N2kMaxCanBusAddress; i++) {
  const tNMEA2000::tDevice *pDevice=pN2kDeviceList->FindDeviceBySource(i);
  if ( pDevice!=0 ) {
    // Do something
  }
}

Note that on tNMEA2000::tDevice you can also read PGN:s they transmits and all other information available from device.

I prefer to have at least Due for using tDeviceList. I have tested it on Mega, but on bigger system memory runs out. Again with Teensy 3.2 you can do a lot more.