ttlappalainen / NMEA2000

NMEA2000 library for Arduino
532 stars 221 forks source link

PGN 126464 causing exception #277

Closed dmarc1234 closed 2 years ago

dmarc1234 commented 2 years ago

Hello and thank you for a great library.

I am running the library on an ESP32 dev module and setting up multiple devices (battery, motor and GNSS) to talk to a Raymarine Axiom 7 plotter on my boat. Measurements are collected by the ESP32 and sent to the plotter for display.

The problem I am having is that PGN 126464 is causing a stack smashing exception when I first power-up the plotter which is caused by the length of the 126464 frame. I have enabled the debug and attached and as you can see the 126464 PGN frame length is 1390 which is way above what I believe is the maximum length.

Can anyone throw any light on this problem ? PGN126464 exception error.txt

ttlappalainen commented 2 years ago

Can you say, which source is 22? Also 23-25? I expect 0 is your GPS.

dmarc1234 commented 2 years ago

I believe if you look at the address claims earlier on in the log that 22~25 are the individual devices setup on the ESP32 i.e. battery, motor etc. so the 126464 is in response to the 59904 from the plotter at address 0.

The back-trace from the exception looks like this: Decoding stack results 0x4008c630: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 155 0x4008c861: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 170 0x400e75bc: __stack_chk_fail at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/stack_check.c line 36 0x400d6a62: tNMEA2000::SendTxPGNList(unsigned char, int, bool) at ../../driver/src/NMEA2000.cpp line 1783 0x400d6ea1: tNMEA2000::RespondISORequest(tN2kMsg const&, unsigned long, int) at ../../driver/src/NMEA2000.cpp line 1930 0x400d6f65: tNMEA2000::HandleISORequest(tN2kMsg const&) at ../../driver/src/NMEA2000.c

ttlappalainen commented 2 years ago

Building Tx/Rx list does not have checking for buffer limitation. This works normally, if there are too many Tx/Rx messages defined.

dmarc1234 commented 2 years ago

This is what I setup for the messages:

// NMEA2K messages we will transmit const unsigned long BatteryMonitorTransmitMessages[] PROGMEM={127504L,127506L,127507L,127508L}; const unsigned long EngineTransmitMessages[] PROGMEM={127496L,127497L,127488L,127489L,127493L}; const unsigned long MotionTransmitMessages[] PROGMEM={127257L,0,0,0}; const unsigned long NavTransmitMessages[] PROGMEM={129026L,129025L,126985L,0};

and here is the initialisation:

// Initialise transmit message and open
NMEA2000.ExtendTransmitMessages(BatteryMonitorTransmitMessages,DEV_BAT);
NMEA2000.ExtendTransmitMessages(EngineTransmitMessages,DEV_MOTOR);
NMEA2000.ExtendTransmitMessages(MotionTransmitMessages,DEV_MOTION);
NMEA2000.ExtendTransmitMessages(NavTransmitMessages,DEV_NAV);
NMEA2000.Open();

I need this many PGNs to transfer all the messages I am using, are there too many?

ttlappalainen commented 2 years ago

You should have e.g., const unsigned long BatteryMonitorTransmitMessages[] PROGMEM={127504L,127506L,127507L,127508L,0};

ttlappalainen commented 2 years ago

on const unsigned long MotionTransmitMessages[] PROGMEM={127257L,0}; there are unnecessary 0:s

dmarc1234 commented 2 years ago

Looks like we have got this working now by making sure that there are 0 values at the end of each const allocation.

Thank you for your help.