Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

C/C++ Serial Comms AT Command help

  • 21-04-2004 02:50PM
    #1
    Registered Users, Registered Users 2, Paid Member Posts: 8,000 ✭✭✭
    Something about sandwiches


    i have a problem with communicating with COM3.
    i am writing a program that will, hopefully, receive an SMS message off a GSM modem or a phone, read it, handle the data, ie if it says "LOTTO" then retrieve lotto results and send a new SMS back to the user with the lotto results in it.

    The only problem i have is communicating with the device. im testing with my internal modem using AT commands. When i send the command "AT", or "ATE1" or "ATI1" etc, i get back the string "ERROR". Actually, the string is "carriage return, line feed,E,R,R,O,R,carriage return, line feed. when i leave the command blank, i get back nothing, so obviously its sending, but sending the commands wrong.

    for my command i have:
    char *command = "ATE1" ;

    in my program, i create the handle, using createfile, set the DCB structure, do sum error checkin to make sure the port is setup corrrectly, then i write and if the write is successful, i read.

    any1 know why my commands are getting sent incorrectly?
    Do i need to send "carriage return, line feed, ATE1, carriage return, line feed" or something? also, i've tried sending "ATZ" first because thats the initialize modem comand but no difference.

    im compiling in MS VC++ 6 in windows.

    thanks for any help.


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 8,000 ✭✭✭The_B_Man
    Something about sandwiches


    solved the problem.

    it was to do with the number of bytes i was sending and receiving and also, i sent the command as "ATI1\r\n" with carriage return and line feed.

    all i need now is the at command to retrieve an SMS from the phone, anyone know where i can find it?


  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    AT+CMGR
    according to

    http://www.cellular.co.za/sms_at_commands.htm

    google for "AT+CSMS" for more along the same lines.


  • Registered Users, Registered Users 2, Paid Member Posts: 8,000 ✭✭✭The_B_Man
    Something about sandwiches


    thanx, thats excellent.
    I dont suppose u have the same for Nokia FBUS Commands?


  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    :dunno:
    beyond me

    first google link was
    http://www.embedtronics.com/nokia/fbus.html
    which looks as well explained as these 'hidden' protocols get.

    and they recommend gnokii
    http://freesoftware.fsf.org/download/gnokii/
    protocol docs embedded in the tarball.


  • Registered Users, Registered Users 2, Paid Member Posts: 8,000 ✭✭✭The_B_Man
    Something about sandwiches


    FBUS is out the window coz u cant use WriteFile() to send them, which is wat i was using. instead u have to do a big complicated handshaking process.
    im just gonna stick to the easy AT commands.
    thank 4 the help.

    by the way, would i need something connected to a phone line or a mobile phone to test these AT-SMS commands, or could i do it on my internal modem that isnt connected, any ideas? i hope me g/f's mobile uses AT Commands or im fudged!!


  • Advertisement
  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    could i do it on my internal modem that isnt connected, any ideas?

    You require a GSM modem. This can be something like an M20 or TC35 external modem or a link to the right type of phone. (I use a broken down Nokia 6150 + DAU9P cable, supposedly should work over IRDA serial connection but on this phone implementation was flawed).

    Sell it for a reasonable price :-) if you can't afford that SMSC internet link just yet.


Advertisement