views:

30

answers:

1

I have a USB Modem connected to my PC with a SIM card inserted. I want to write a C# application to send SMS through the modem can any one help me with this??? another question..I have heard about serial port communication...Is there some thing called as USB port communication???

+2  A: 

So at first, there exists nothing like a USB port communication. But all those usb modems implement a virtual serial connection.

You can make a connection through this virtual serial port to your modem and use it as you like. To find out the used serial port you can take a look into the device manager after you connected the modem or you can just call System.IO.Ports.SerialPort.GetPortNames() to find out the available ports. Perfect would be a ComboBox that would be filled up, so the user can choose the port, cause it will differ which com port a usb device gets from pc to pc.

To communicate with the port you can take a look into the SerialPort class. But what you have to send to enter the pin code and to send (or receive) an SMS completely depends on the command of your modem. So for these commands you should take a look into the handbook of your modem. Normally you'll find a list of all possible AT-commands and their parameters.

And this brings us back to the start where you first have to check if you have selected the right COM port and if it is correct configured. To find this out you just have to send the command AT\r\n and your answer should be OK\r\n (don't forget to add the Environment.NewLine or "\r\n" to your entered command!). For these just take a look into the Read() and Write() functions of the class.

Maybe for a first test of your modem configuration and the AT commands you should use a Terminal program like HyperTerminal. With this you can configure and open a connection to a serial port, enter your commands manually and see directly the answer from the other side. If you got this to work it should quite easy to create a small application that performs the commands automatically and shows the answer in a more readable way.

Update

Cause you just said it is a Huwai modem i just found this documentation. Here they mentioned an existing software to send and receive an SMS. If you just have such an existing application, no documentation about the AT-command and you'd like to write your own application. You should install the Free Serial Port Monitor and sniff into the communcation between the modem and the application. So it should be quite easy to find out the needed commands if you don't get any documentation for it.

Oliver
Thank you very much for the help. I'll work on your information.....
chamara