Find the answer to your Linux question:
Results 1 to 4 of 4
Hi all, I am testing sending sms through wavecom module. I tested with minicom, its responding correctly.. commands are AT OK AT+CMGS="mobilenum" (then press Enter key) >"message" (then press ctrl+z) ...
  1. #1
    Just Joined!
    Join Date
    Jul 2009
    Posts
    16

    sending AT commands to wavecom through C code

    Hi all,


    I am testing sending sms through wavecom module.

    I tested with minicom, its responding correctly..
    commands are
    AT
    OK

    AT+CMGS="mobilenum" (then press Enter key)
    >"message" (then press ctrl+z)

    its sending sms properly.

    Same thing i want to implement using a code.

    I am able to open serial port and done initialization


    now i want to send AT COMMANDS to wavecom modem using C code.

    can any one provide sample code for this.

    Thanks in advance

    John

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    1. Open the device: FILE* fp = fopen(devname,"w+");
    2. Use fprintf() or fwrite() to output the string. Ie, fprintf(fp, "AT\n");
    3. Use fscanf() or fread() to read the reply data.

    Have fun!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Jul 2009
    Posts
    16
    Quote Originally Posted by Rubberman View Post
    1. Open the device: FILE* fp = fopen(devname,"w+");
    2. Use fprintf() or fwrite() to output the string. Ie, fprintf(fp, "AT\n");
    3. Use fscanf() or fread() to read the reply data.

    Have fun!
    Thanks for your reply..

    could you please elobarate it.
    FILE* fp = fopen(devname,"w+");
    here devname is serial port id?
    i am using /dev/ttyS0/
    can i use like this : FILE*fp = fopen(/dev/ttyS0, "w+");
    any delay is needed after sending any commands to wavecom?
    if yes how much ? I am using Q24series.
    I am really new to this

    your help is appreciated

    Thanks
    in advance

    john

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by johnb4u View Post
    FILE* fp = fopen(devname,"w+");
    here devname is serial port id?
    i am using /dev/ttyS0/
    can i use like this : FILE*fp = fopen(/dev/ttyS0, "w+");
    any delay is needed after sending any commands to wavecom?
    if yes how much ? I am using Q24series.
    I am really new to this
    This is very basic stuff. You should get an intro to C programming book on how to do this.

    As for your question using /dev/ttyS0, if that is the port your wavecom device is connected to, then yes, that is correct. As for delay, you can use a blocking read which will wait until the device returns some reply. At this point, getting into timed I/O using open/select/read instead of fopen/fprintf/fread is way more complicated than you need to concern yourself with.

    Again, get an introduction to C programming (from Amazon.com or others like them) to learn the basics. There are also some tutorials on the net you should be able to find with a google search pretty easily. Here is one to get you started: Introduction to CProgramming
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...