barnaclebill - I'm having an odd problem. Here'...
I'm having an odd problem. Here's the short(ish) version:
I have two ESP32s connected via UART. ESP32-A reads PGN 130306 (wind) from N2K bus-A, corrects it for mast rotation, and forwards to ESP32-B in Actisense format. ESP32-B simply forwards the message to N2K bus-B. My Garmin displays happily report the (corrected) wind direction.
It would be more efficient/elegant to use a second CAN bus on ESP32-A, which I only recently got working (with a MCP2515 HAT). So now ESP32-A reads PGN 130306, corrects, and transmits directly onto bus B. The issue is that the Garmin displays do not acknowledge/display this wind data. However, SignalK sees wind data in both configurations. Aside from the obvious fact that SignalK is a more robust marine communication mechanism than Garmin, what am I doing wrong?
In the first configuration, ESP-A does this:
SetN2kPGN130306(correctN2kMsg, 1, windSpeedMeters, rotateout*(M_PI/180), N2kWind_Apparent);
correctN2kMsg.SendInActisenseFormat((Stream )&ESPlink);
and ESP-B is doing:
actisense_reader.ParseMessages();
(which, since there are no special handlers, simply forwards the message to bus B)
In the second configuration, the sole ESP is doing this:
SetN2kPGN130306(correctN2kMsg, 1, windSpeedMeters, rotateout(M_PI/180), N2kWind_Apparent);
n2kMain->SendMsg(correctN2kMsg);
In both configurations, the only source for PGN 130306 on the N2K bus that all of the displays are connected to, is an ESP32 registered on the network, using N2km_ListenAndSend mode. I'm struggling to figure out what's missing from the direct/single ESP config.
3 Replies
So you're saying, if you have two ESP32s connected via UART, the Garmin display receives PGN 130306 properly, but if you have an ESP32 with two CAN buses but otherwise seemingly identical setup, it doesn't?
The devil might be in the details here. In the latter case, does ESP32-A register itself on bus B? Like, does the SK server or the Garmin display show ESP32-A on their list of devices?
If not, then ESP32-A might not do proper address reservation on bus B, or might not respond to the device query PGNs. Assuming that the SK server doesn't care if those are missing but the Garmin would expect good N2K bus citizenship.
Related to this - what did you do to get the MCP2515 module working with ESP32? I remember I tried that when I was building a test jig for some device but couldn't get it working in 15 min or so and decided to take another route...
I was thinking it had something to do with registration as well. Next time I'm at the boat I will swap the functions of the CAN interfaces and see if anything changes. The wind bus (bus-A) does not register (it's in Listenonly mode), but the main bus (bus-B) does registration just like the original code. In fact, it still registers as "SH-ESP32 NMEA 2000 USB GW" because I haven't bothered to change it. Regardless, that registration is the same in both cases (single ESP vs dual ESP).
I was never able to get a MCP2515 module working with any ESP32...freeRTOS crashed as soon as it loaded, and I'm not capable of debugging kernel driver problems. It's possible I was doing something wrong with the 3.3-5V conversions (up to power the module, down for logic out). For whatever reason, the MCP2515 chip and mcp driver library work fine on the PICAN-M HAT. That version is running on an ESP32 that has a 40-pin GPIO header that corresponds to RPI pinouts (not that it matters...it's still just SPI). But it allows me to swap between my working device (SH-ESP32) and the single-ESP device easily.
Thanks, that's interesting. Probably should try again at some point...