Thursday, May 24, 2012

Bullet-proofing the Monitor Software

There have been a number of issues regarding the Icon GSM/GPRS USB modem in the home monitor. The main two are (1) that it does not get recognized and switched to serial-port mode on power-up boot (but does on subsequent command line reboots) and (2) that it sometimes (but rarely) stops responding to sending AT commands, and must be unplugged and plugged in again (or the system must be rebooted.)

I believe I can solve both problems without having to physically unplug and replug in the modem, which is impossible when I'm away. A software way to do this eludes me at this time, and I'm running out of time, so I will try a partly hardware way to do this: by disconnecting the USB 5V power line to the modem and reconnecting it. I will use an output bit (GPIO) on the Beaglebone to switch the 5V under program control.

The idea is to set the bit set by default so as not to supply power to the modem on reboot, or initial boot up. Then, later, when I run the  monitor program I will set the bit to supply power to the modem and wait for the five devices /dev/ttyHS0-4 to appear in the file system. If this is like plugging in the modem, I should see the /dev/ttyHS0-4 devices in the file system, after the usb-modeswitch software recognizes the modem and >switches it to the serial port USB device, creating the five devices.

To recover from timeouts when the modem refuses to respond to commands while running, I will recover by turning off, then on the modem power, and proceed as on boot up to wait for the devices and open the /dev/ttyHS1 port.

Here is an outline of the program at startup:
  1. Switch power to the GSM USB modem off, then on with a 30 second delay using the GPIO bit that controls modem USB power.
  2. Wait until the five /dev/ttyHS* devices appear in the file system.
  3. Open the modem as usual and test it by issuing a plain 'AT' command.
  4. If either of these steps do not work, go back to step 1.
When we get a timeout, simply restart the program, which should go thru the steps above.

For reference, here is the pin-out for the USB cable:

Pin Name Cable color Description
1 VCC Red +5 VDC
2 D- White Data -
3 D+ Green Data +
4 GND Black Ground

No comments:

Post a Comment