No MY_DEBUGDEVICE.begin ?



  • 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)

    https://github.com/mysensors/MySensors/blob/59b15f5824bf060fa153b30065d089b04fff77c7/hal/architecture/SAMD/MyHwSAMD.cpp#L70


  • 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: -

    MY_DEBUGDEVICE.begin(MY_BAUD_RATE);
    #if defined(MY_GATEWAY_SERIAL)
    while (!MY_DEBUGDEVICE) {}
    #endif

    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()
    {
    MY_DEBUGDEVICE.begin(115200);
    while(!MY_DEBUGDEVICE){};
    }

    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

13
Online

11.2k
Users

11.1k
Topics

112.5k
Posts