PDA

View Full Version : accessing the GSM modem using serialport in windows OS



jjbabu
28th December 2007, 06:12
Hello,

I want to develop an application where i have to interact with a GSM Modem to send or receive messages and require to write AT Commands on the modem via the com port from the qt programming.

Can anyone provide guidance in this regard ..
Highly URGENT ...



Thanks in advance ... :)

jpn
28th December 2007, 06:47
I want to develop an application where i have to interact with a GSM Modem to send or receive messages and require to write AT Commands on the modem via the com port from the qt programming.
See QextSerialPort (http://qextserialport.sourceforge.net/).


Highly URGENT ...
Don't flag your question as “Urgent”, even if it is for you (http://catb.org/~esr/faqs/smart-questions.html#urgent)

jjbabu
28th December 2007, 08:51
first thanx for ur response jpn,

I feel very sorry to mentioning the urgent word in my thread.

about my problem,i already used that "qextserialport" class.i want to send some commands(at commands)to the GSM modem for the purpose of sending and receiving the messages.

Is there any library in the Qt to develop these type of applications,if any plz provide that documents to me.

thanx for ur help.

katrina
28th December 2007, 11:13
As far as I know, you would use QextSerialPort to read and write to the GSM modem, and you would just write the AT commands and then read the returned data. I have not ever seen a class specifically for dealing with GSM modem AT commands, but I do know there are several apps for KDE that work with GSM modems, it's possible one of them has some code which could be useful to you.

calhal
29th December 2007, 15:14
I want to develop an application where i have to interact with a GSM Modem to send or receive messages
What do you mean saying "messages" - SMS?
I really don't think you can find anything ready to use with Qt and gsm. If you find something, I think it will work only with some specific gsm modem.
I've been working with some industrial gsm modems (Motorola, Sony Ericcson, SIM, Siemens). They all support standard AT commands, but they have also nonstandard commands specific to their vendor.
Datasheet of your modem should have list of all commands. As you already know, qextserialport will let you use UARTs. Then you must just analyze strings you get from GSM and correctly respond to them. I think QHash and maybe QMap will be helpful to do that.

jjbabu
31st December 2007, 05:50
Hi,
Thanx for ur reply,

Here i am mentioning clearly what is the problem,

I am using Qt4.1 on Windows.

I developed one application using the "Qextserialport" class.The functionality of my application is,it has to receive the data from the Micro controller(which will send the data according to user request) and display the data on my GUI,at the same time according to user requirement my application will send the data to the Micro controller using the RS-232.
Upto this i have successfully finished.In this application the connectivity between my GUI(which is on PC) and Micro controller board is direct(i.e using RS-232 direct connection is there).

Now we have one more version which is called wireless version,In this case the connectivity between GUI and Micro controller is wireless.

at the Pc side we r having one GSM modem and at the board side we r having another,the same functionality will (i.e sending and receiving of data will occur between the two modems).

here i know the At commands of modem to send and read the sms messages of modem.
my idea is the data will be transfered in the sms messages between the modems.

My problem is HOW TO WRITE SOURCE CODE FOR CONNECTING TO AND SENDING AT COMMANDS TO THE GSM MODEM.

Is any one having the idea abt this issue,plz suggest me,are there any useful documents and libraries for this?

THE MODEM I AM USING IS WAVE COM,

How to start with this type of functionality,whether can i send the At commands(At,AT+CMGF=1,AT+CMGW="-----",AT+CMSS)through serially as like in the direct version or can i use any library to send this commands to the modem ?


Thanx in Advance.

katrina
31st December 2007, 07:57
_Most_ GSM modems are capable of acting like standard serial devices; in that case you treat them just like you would any other serial port, just write your AT commands to the serial port they are attached to and get the response.

_Some_ GSM modems use proprietary drivers and do not act like a standard serial device... in this case you would need to work with the manufacturer of that device to get the libraries you need.

The easiest way I have found to test it on Windows is to go into the hardware manager and see if the GSM device has a modem device listed as a COM port, then if so open up Hyperterminal with a direct link to that serial port and try to type some AT commands to it. If that works, then chances are you can just write the AT commands directly to it in your software. If either of the these is not true, then chances are your device uses a proprietary driver.

calhal
31st December 2007, 08:55
Connect wavecom to your pc's RS-232 and talk with it using qextserial just like you did to talk with your microcontroller.
The difference is that you must use the AT commands. I'm sure they are ale listed in some manual you got with the modem.
As katrina wrote, try to send sms manualy first, using hyperterminal or some other serial terminal software. Usually those modems are default at 115200, 8bit and no parity.
After power-on just send to RS something like that


AT //your command
OK //modem response
ATE0 //this is very usefull - turning off local echo
OK //modem response
AT+CPIN="1234" //enter pin number
OK //modem response
AT+CREG=1
OK

In your software you should end commands you send by "\r\n". Most modems will send anything to you starting and finishing the message using "\r\n". So in fact you'll receive "\r\nOK\r\n".
So again, try do what you need manually, then write Qt software doing this for you. It's not really difficult ;)

jjbabu
31st December 2007, 10:42
Thanx for ur help calhal & katrina,

yah,what u told ,i completed already,

i checked my Gsm modem by connecting with com port and passed At commands using MS Hyperterminal,the modem works fine at that time,i sended sms message from PC to another mobile using that AT commands.
we set the port and modem for 9600,8bit,no parity.

My doubt was,how can i send "ENTER","CNTR+Z" signals of keyboard from my source code.can i give "\n" for "ENTER" signal?

one more doubt is, after sending command to the modem,i will verify that"OK" response in the PC side,it will take some delay for this,how can i avoid the delay problem in this issue.

u are really helpful to me,
thanx alot..........:)

calhal
31st December 2007, 11:09
My doubt was,how can i send "ENTER","CNTR+Z" signals of keyboard from my source code.can i give "\n" for "ENTER" signal?

I think enter is rather "\r\n" in this case. ctrl+z is a SUB character. IIRC it has 0x1a hex code.


one more doubt is, after sending command to the modem,i will verify that"OK" response in the PC side,it will take some delay for this,how can i avoid the delay problem in this issue.
I don't know if I understand correctly your question. I'd use a QTimer to receive data from RS232, then emit some signal when got "OK" and connect it to right slot. Same for other commands received from modem.

jjbabu
31st December 2007, 11:23
Hi calhal


I think enter is rather "\r\n" in this case. ctrl+z is a SUB character. IIRC it has 0x1a hex code.


If u dont mind can u give me some more clarity regarding "CNTR+Z" signal,i understood about that "enter" signal,but i didnt abt "CNTR+Z".

In the source code what i have to mention for "CNTR+Z"?
can u give me any example abt this,

thanks,

calhal
31st December 2007, 11:38
In the source code what i have to mention for "CNTR+Z"?
can u give me any example abt this
When you press cntr+z in some serial terminal software, it will simply send ascii char representing this cntr+z.
Here is some link http://www.cisco.com/en/US/docs/ios/11_0/protocol/command/reference/papascii.html

So in fact you must send this char to gsm modem. It would be string with something like "\x1a".