I have a small program, that sends sms messages over SerialPort. It works nice for 7-8 days in a row, sending hundreds of messages per day. But sometimes it hangs on sending the message, and only a hardware reset can solve it.
The problem occurs when the modem is waiting for the message (showing the "> " string), and I sent my message. When a modem receives the CTRL+Z (ASCII#26) character, it should send back an "OK". But I never recevice this response, and from that time, every write attempt ends with a System.TimeoutException: The write timed out. exception.
I can catch the exception, but I can’t do anything to resolve the problem (except for the hardware reset). From the 1st timeout exception, the serial port won’t work – not even for hyperterminal. I had the chance to try 2 different modems, but both of them produces the same simptoms. (Different modems, but same computer.) I don’t have the means to test it for 10 days on a production like environment, on a different machine.
I used a serial monitor software, and it also showed, that the serial port (or the modem) sends back a write timeout error. When I initialize my serial port I set the WriteTimeout property to 100 (ms). I have to use hardware handshaking according to the modem’s manufacturer.
I send only simple text messages (no PDU, no more than 160 char).
I already found this thread, talking about write timeouts and hardware handshaking. I could raise the write timeout value, but I would like to know why this problems occurs only occasionaly. And I would like to know if this is my problem at all…
I’m using C# 4.0, the program runs on a Windows 2008 64 bit server.
Any ideas?
UPDATE
Following the hint from Dennis, we have found a solution. The watchdog part is my own software, detecting the timeout exception. When this happens, the program will send a command to a specialized hardware to toggle the power of the modem. At first, this specialized hardware would have been a relaycard, but we found a special extension cord, that can be controlled over RS-232 or USB or ETHERNET. (Switching on and off it’s plugs.)
This is a well-known problem for people, who often works with GSM-modems. In general, you can do noting here at software level, and the hardware reset is the only effective way.
If you will look into any ATM, which works through the GSM newtork, you will find there a small watch-dog device, which is intended for the single thing – to make a hardware reset (it turns the power off, than on).