• I've been testing a Genuino Zero as a serial gateway. Everything works fine except for the redirection of debug output to the Programming port.

    I saw a thread and a pull request which added MY_DEBUGDEVICE to the architecture files, but if I #define MY_DEBUGDEVICE SERIAL my gateway crashes, silently.

    I believe this is because there is no 'begin' for MY_DEBUGDEVICE.

    When I add one to to relevant architecture file it works fine, with debug output sent as expected to the Programming port.

    I'm a bit puzzled how anybody has got this to work without that mod, have I missed something?

    Note that adding MY_DEBUGDEVICE.begin into Setup in the sketch is too late - the node crashes before it gets to that point.

  • Admin

    I think that it's probably because you are the first that use a separate port for debugging..

    in hwInit for SAMD architecture, we only initialize the standard serial port (MY_SERIALDEVICE)

  • Mod

    @fac13 as a workaround, could you try placing MY_DEBUGDEVICE.begin in a function called before() or preHwInit() in your sketch? MySensors will execute them before setup().

  • @mfalkvidd I tried both and neither worked - the node still failed to start.

    My workaround is to add MY_DEBUGDEVICE initialization in hwInit() in MyHwSAMD.cpp , immediately after the initialization of MY_SERIALDEVICE,

    i.e. insert these lines after line #76: -

    #if defined(MY_GATEWAY_SERIAL)
    while (!MY_DEBUGDEVICE) {}

    Of course if the two devices are the same then MY_SERIALDEVICE gets initialized twice, but doesn't seem to cause a problem.

  • fac13 about 2 hours ago

    I realized I should have added a wait after the initialization, like this: -

    void preHwInit()

    With that included, my sketch works without needing the architecture code mod.

    Putting the same code in before() doesn't work.

    Thanks for your help.

Log in to reply

Suggested Topics