Corner Cases

  • Experience has taught me that if the lte modem is going to connect it will do so in under a second, so I give it 3 just to be sure

    10  for i in range(3):
    11    print(i, ' ', end=''); time.sleep(1)
    12    if lte.isconnected(): break
    13  else: lte.send_at_cmd('AT^RESET')

    then reset it if it doesn't make it. This works in 99% of cases where the modem doesn't connect, which in turn is 1% of all connection attempts. But in 1% of the 1% (1 in 10,000!) I get an OSError (modem in data state, AT cmd not allowed) from line 13. Surely the damn thing doesn't connect in the millisecond between line 12 & line 13?

  • @kjm The time is a little bit longer, since it is the span between i being 3 and the moment, the command string "AT^RESET" is finally parsed & executed by the modem firmware. Since that event is relatively rare, it may happen in that time.

Log in to reply

Pycom on Twitter