0

I have a GSM ModeM connected to a serial port, and I use it so send SMS upon certain events.

Since it is not Plug-and-Play, I am confused as to how I'll detect its connection status. Win APIs like GetCommState will obviously not work.

I could periodically send packets of data and check whether the data is being consumed or not, but I'm wary about the risks of polling over performance and clogging up the buffers which might be in use.

So, is there any other method, or some interrupt based thing, which I could use to check whether is still connected, via a serial port, to my system?

I'd be grateful for any help on this.

Thanks.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
user1173240
  • 1,455
  • 2
  • 23
  • 50

2 Answers2

0

From Windows 7 onwards, use Windows Mobile Broadband API to get information about a GSM modem.

user1725145
  • 3,993
  • 2
  • 37
  • 58
0

Serial ports are very primitive communication devices, they date from the very early days of computing. It is what you plugged your ASR-33 teletype into to start banging in your Fortran program. The only reason they are still around is because they are simple, hardware vendors like them because they don't have to spend money developing and supporting a custom api to use their device.

Still, even back in the sixties did a computer have a need to find out if a teletype was attached. Which is done through the hardware handshake signals. The DSR signal, Data Set Ready, is turned on by the device when it is powered up. If you use the .NET SerialPort class then you can check that signal with the SerialPort.DsrHolding property. If you use the winapi then use GetCommModemStatus(), MS_DSR_ON flag.

That still only tells you that some device is attached. If you want to find out that it is the modem that you wrote your program for then you can interrogate it with AT commands, a protocol that's specific to modems. No vendor implements this exactly the same way but you can usually count on an identification from the modem with the ATI command. Check the programming manual for the modem for details.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I tried with `GetCommModemSatus()`, but can't seem to get it to work..could you give me an example of how to use it, please. And the checking condition. It always returns odd variables in my case. – user1173240 Apr 05 '13 at 06:29