Arduino never reaches setup() or loop() when rs485 connection is down



  • I am trying to add MySensors connectivity via rs485 on diy thermostats (arduino based)

    As long as I have a connection to a rs485 gateway things seems to be working fine, but if the connection is lost (or the gateway-program on my Linux box is not running) the thermostat never starts up. only the code in before() is executed

    Is that the expected behavior, and is there anyway around this ?

    I need my thermostats to work even if there is no connectivity to the MySensors infrastructure.

    Here is what I see on the serial port of the arduino when the gateway is down.

     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.3.1
    
    16 MCO:BGN:INIT NODE,CP=RSNNA---,REL=255,VER=2.3.1
    26 MCO:BGN:BFR
    ShuntCtrl
    to clear EEPROM presss c now:  321
    4142 TSM:INIT
    4143 TSF:WUR:MS=0
    4145 TSM:INIT:TSP OK
    4146 TSM:INIT:STATID=123
    4149 TSF:SID:OK,ID=123
    4151 TSM:FPAR
    4168 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6176 !TSM:FPAR:NO REPLY
    6178 TSM:FPAR
    6196 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8204 !TSM:FPAR:NO REPLY
    8206 TSM:FPAR
    8223 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    10231 !TSM:FPAR:NO REPLY
    10233 TSM:FPAR
    10252 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    12259 !TSM:FPAR:FAIL
    12260 TSM:FAIL:CNT=1
    12262 TSM:FAIL:DIS
    12264 TSF:TDI:TSL
    22267 TSM:FAIL:RE-INIT
    22269 TSM:INIT
    22270 TSM:INIT:TSP OK
    22273 TSM:INIT:STATID=123
    22275 TSF:SID:OK,ID=123
    22278 TSM:FPAR
    22295 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    24303 !TSM:FPAR:NO REPLY
    24305 TSM:FPAR
    24324 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    26331 !TSM:FPAR:NO REPLY
    26333 TSM:FPAR
    26351 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    28358 !TSM:FPAR:NO REPLY
    28360 TSM:FPAR
    28379 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    30386 !TSM:FPAR:FAIL
    30387 TSM:FAIL:CNT=2
    30389 TSM:FAIL:DIS
    30391 TSF:TDI:TSL
    40394 TSM:FAIL:RE-INIT
    40396 TSM:INIT
    40397 TSM:INIT:TSP OK
    40399 TSM:INIT:STATID=123
    
    

  • Mod

    welcome to the forum @storepeter !

    Yes this is expected default behavior, but it can be changed. Exactly how things should work varies a bit from different use cases, but see the documentation for MY_TRANSPORT_WAIT_READY_MS and search for that keyword in the forum to find some ways to do it.

    See the flowchart "node boot sequence" at https://www.mysensors.org/download/sensor_api_20#node-boot-sequence to see how changing MY_TRANSPORT_WAIT_READY_MS will affect how code is executed.

    If you have any questions, just post them here.



  • Thank you so much, just the input I needed.

    Works like a charm, I have included the output from the serial port, if any one else wonders what to expect.

    __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.3.1
    
    16 MCO:BGN:INIT NODE,CP=RSNNA---,REL=255,VER=2.3.1
    26 MCO:BGN:BFR
    before
    ShuntCtrl
    to clear EEPROM presss c now:  321
    4156 TSM:INIT
    4157 TSF:WUR:MS=1000
    4159 TSM:INIT:TSP OK
    4161 TSM:INIT:STATID=123
    4163 TSF:SID:OK,ID=123
    4165 TSM:FPAR
    4184 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    5159 MCO:BGN:STP
    setup
    5161 !TSF:SND:TNR
    6164 !TSF:SND:TNR
    6192 !TSM:FPAR:NO REPLY
    6194 TSM:FPAR
    6211 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    7165 MCO:BGN:INIT OK,TSP=0
    8288 !MCO:SND:NODE NOT REG
    8372 !MCO:SND:NODE NOT REG
    8455 !MCO:SND:NODE NOT REG
    8539 !MCO:SND:NODE NOT REG
    [ %0PH 18.8 Vejr 18.7 ] [ %16PC 18.6 ->25 18.4 ]
    8636 !TSM:FPAR:NO REPLY
    8638 TSM:FPAR
    8656 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    [ %0PH 18.8 Vejr 18.7 ] [ %16PC 18.6 ->25 18.4 ]
    11094 !TSM:FPAR:NO REPLY
    11096 TSM:FPAR
    11114 TSF:MSG:SEND,123-123-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    [ %0PH 18.8 Vejr 18.7 ] [ %16PC 18.6 ->25 18.4 ]
    13550 !TSM:FPAR:FAIL
    13552 TSM:FAIL:CNT=1
    13554 TSM:FAIL:DIS
    13556 TSF:TDI:TSL
    [ %0PH 18.8 Vejr 18.7 ] [ %16PC 18.6 ->25 18.4 ]
    [ %0PH 18.8 Vejr 18.7 ] [ %16PC 18.6 ->25 18.4 ]
    [ %0PH 18.8 Vejr 18.7 ] [ %16PC 18.6 ->25 18.4 ]
    [ %0PH 18.8 Vejr 18.7 ] [ %16PC 18.6 ->25 18.4 ]
    23558 TSM:FAIL:RE-INIT
    23560 TSM:INIT
    23561 TSM:INIT:TSP OK
    23563 TSM:INIT:STATID=123
    23565 TSF:SID:OK,ID=123
    

 

300
Online

8.9k
Users

9.7k
Topics

101.2k
Posts