Arduinon startup complete request strange behaviour (python)


  • Mod

    Hi,

    When the gateway is started up it sends a message 'Arduino startup complete' (at least that is what I see).

    But instead of using the 'normal' 5 field format I receive the below with 8 fields.
    Obviously this is wrong and it looks like one or two request are mixed up (possibly a request for a radioId together with the startup message)...
    Any idea how this can happen (using python and serial connection)...

    2014-04-29 01:16:36 MySensors Debug Receiving command 255;255;4;0;0;4;11;Arduino startup complete.


  • Admin

    @marceltrapman

    Strange.

    serial(PSTR("0;0;%d;%d;Arduino startup complete.\n"),  M_INTERNAL, I_LOG_MESSAGE);
    

    This is the only thing i can find being printed during Gateway begin.


  • Mod

    @hek is it in any way possible that messages get scrambled on the gateway when they cross each other?


  • Admin

    @marceltrapman

    No, i don't really see how this could happen. Do you have any idea what other message it could have gotten mixed up with?

    What happens if you turn of debug-printing does it disappear?


  • Mod

    This happened with and without debug printing.

    The funny thing is that it appeared 'out of the blue', showed up a couple of restarts and it looks like it disappeared again with the last restart.

    I will keep an eye on it since I will need a lot of restarts before I am ready with the plugin ")


  • Mod

    OK, this time it is completely clear to me but I don't know why yet.

    Receiving command 1;2;2;2;0;0;4;11;Arduino startup complete.

    Two sensor/gateway messages were concatenated.

    The first a relay device 'reporting for duty', asking for the registered state of itself 1;2;2;2;
    And following the gateway reporting for duty: 0;0;4;11;Adruino startup complete

    Strange though that the gateway presentation comes after the sensor presentation...


  • Admin

    @marceltrapman

    Are you really "breaking" the commands on newline character on the phyton side? Please post your code 😉


  • Mod

    See below, the answer is yes. I do a readline() and it breaks on '\n' by default and MySensors does the same.

    BTW I added the flush() after sending my previous post as well as removing all sleeping code from the sensor.
    I will start playing with this because I suspect one of these two (or both) solved the issue.
    I now see Receiving command 0;0;4;11;Arduino startup complete. before anything else 🙂

    EDIT: false alarm. A new upload of the sketch and a restart made the issue appear again 😞

        try:
            request = self.connection.readline()
        except:
            self.debugLog("Unexpected error:", sys.exc_info()[0])
            request = None
        finally:
            self.connection.flush()
    
            if request:
                request = request.strip("\n\r")
    
                self.debugLog("Receiving command %s" % request)

  • Admin

    @marceltrapman

    Should you really flush after calling readline()?


  • Mod

    Nope, this was a 'if it does not help it will not hurt'.

    I am going to remove it.


  • Admin

    Hard to say,

    It surely looks like readline() gives back more that one line to me.

    I'm no phyton expert. But where is request-variable declared? Is it cleared between runs?


  • Mod

    Yes, all variables are cleared before I re-use them which is completely obsolete even because they are defined in the method and the method is called from within a/the loop.

    I will ask the Indigo gurus about this...


Log in to reply
 

341
Online

6.9k
Users

7.8k
Topics

82.9k
Posts

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.