Wednesday, March 28, 2012

Modem fails to respond at long intervals

The Option Icon 322 USB modem fails to respond to at commands at long intervals, and causes timeouts when waiting for a response to an at command, which are detected using the 'catch' command and causing my program to exit. When this happens, stopping and restarting the program does no good. The second restart always fails at the open() call, and by using 'fuser' ('fuser /dev/ttyHS0) it appears that the program has opened the modem, but gets stuck at a tcsetattr() call, according to the stack trace when I attach 'gdb' to the process. But, running minicom seems to restore correct operation. What does minicom do that the program does not do? If I can find out I can at least restart the program successfully. I would of course like to be able to reset the modem to restore it, but I can't figure out what does that, other than somehow (modprobe -r) deactivating the usbserial module and reactivating it.

To find out I ran both ('tclsh beaglegsm.tcl' and minicom) using 'strace' to trace system calls. Except for the open call, both do the same things regarding protocol in sending 'at' commands. The open call for minicom uses the switches:

 open("/dev/ttyHS0", O_RDWR|O_NOCTTY|O_NONBLOCK) = 3


while beaglegsm.tcl uses:

 open /dev/ttyHS0 RDWR

I programmed the open in tcl to use these same flags as minicom, and I'm now testing this arrangement:

open /dev/ttyHS0 {RDWR NOCTTY NONBLOCK}

3 comments:

  1. What was the result of the code change?

    ReplyDelete
  2. This appears to be the first mention of your 3G modem. Why did you choose this modem? Have you tried and others? Are you using it /just/ for SMS or are you also using the data/Internet service? Thanks.

    ReplyDelete
    Replies
    1. Sorry for the long delay. I chose the Option modem due to its low cost, not having tried any others. Since it worked fine (excepting the intermittent timeout, which I 'fixed' by using a disconnect/reconnect USB hardware method outlined at http://beaglebonegsmmonitor.blogspot.com/2012/05/bullet-proofing-monitor-software.html, I kept it. I'm now getting it to at least restart when it times out.

      Delete