Using AT commands with C

sasha85
sasha85 used Ask the Experts™
on
there is a AT commands here
http://www.developershome.com/sms/readSmsByAtCommands.asp


suppose i want to work with C visual or ++, how can i use this AT commands in a what that it will be sent to the mobile phone that will be connected to the computer
?

for example this is the at command to read unread sms
AT+CMGL="REC UNREAD"
how i can write it inside the c code, in a way that it will send this command to the mobile phone?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
how to open socket or port?
how to send the at commends to this port?
Commented:
You can use a COM port.
A good article on windows serial communication:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp

Author

Commented:
i tried every part of the code in the link but it somehow not work...when i look inside the settings 'phone and modems' i see the nokia and the motorola that i tried to connect on com 4
i set it on com 4 inside the string but i realy got no idea in what order this code need to be...msdn give only part and not the all code example:(
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Author

Commented:
i want to do this in C#

Author

Commented:
what is the diffrences in coding  between serial rs232 cable and USB cable?
Commented:
There is no difference. Applications manage a modem as a serial device using a COM port; the phisical layer differences are managed at driver level.

Author

Commented:
there is no even speed deiffrences??
Commented:
I don't know... i think performance may be different

Author

Commented:
and how i transfer the at commands to the phone?
Commented:
System.IO.Ports.SerialPort port = new System.IO.Ports.SerialPort( "COM4", 115200, Parity.None, 8, StopBits.One);
port.ReadTimeout = 500;
try
{
  port.Open();
  port.WriteLine("AT");
  string str = port.ReadLine();
}
catch...
offcourse there is a speed difference between COM port and USB communication. anyhow, you can use the createfile to open comport and write function to send output. you can get the code of win32 example in this link(download link is there).

http://msdn2.microsoft.com/en-us/library/ms810467.aspx

Author

Commented:
for example i got 10,000 sms at a time...my income limit is 200 sms
the program will need to read each sms than to procces it and delete it and read the new one...

speed is highly important...may be i will need a special GSM modem and not a regular mobile phone?
10,000 SMS happens frequently then its a design flaw, why GSM modem is choosen instead of going for GPRS/data connection?

Author

Commented:
i ment to write 1000 sms and not 10000...
i manage to get
Sierra Wireless AirCard 875U USB

i got it here it looking at me and i don't know how to communicate with this...cause i don't know what at command i have to use...i am sure it want to say something to me:)

*for gsm/data connection, as i understand i need to pay the service provider company...because it for study project and my budget limitted i cannot do this...
u can use the 3G AT commands as your card is 3G card.
u can check both of the following link.

http://the.taoofmac.com/space/AT%20Commands
ftp://ftp.biometrics.co.za/Miscellaneous/3G_AT_Commands.zip

Author

Commented:
i realy tried to understand what i am reading on this link but i realy do not understand how 3G and my
Sierra Wireless AirCard 875U USB  connected?

Author

Commented:
its gsm card...
did u try to use the commands listed in the link? it will serve your purpose..
Author of the Year 2009
Commented:
I suggest first trying to establish comminications manually.  Use the Windows program named "Hyperterminal"  to see if the device accepts simple AT commands.  Start > All Programs > Accessories > Communications

Once you know that you can "converse" with the device manually, you've taken the first "baby step"  towards writing code to do the same thing programamtically.

Author

Commented:
ok...i just lost 2 weeks:(
this system have to run on linux...that means that c# or visual not good for this...

i will have to start all over again with c++
someone can please help me only with the part of communicating with the phone modem?
i mean opening the port and talking to the device...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial