Procedure to issue AT commands from a C program.

Home Forums MultiConnect OCG Procedure to issue AT commands from a C program.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2603
    JM K
    Participant

    Hi,

    I am working with an EV2 CDP Unit. I am trying to write a small application that accepts a message in the form of a text file (gedit) and sends an sms to a custom phone number also entered by the user. I am confused as how to access the minicom interface via a C program. Is there any other way AT commands can be issued at the terminal after logging in to the device at run time through a C program? Any suggestions would be very much appreciated. Thank you very much and have a great day.

    Best Regards,

    JM

    #3289
    Jesse Gilles
    Blocked

    JM,

    You don’t need to use minicom to talk to the modem. Linux treats the serial port for the modem (/dev/ttyUSB0) as a file, so you can do reads and writes as if it were a regular file in your C application. There are also C calls you can make to configure the serial port (baud rate, etc).

    Here is a page that has some examples, take a look at the section labeled “termios”.

    http://en.wikibooks.org/wiki/Serial_Programming/Serial_Linux

    You are also free to look at and use the source code for the sms-utils application, which is written in C.

    http://git.multitech.net/

    Jesse

    #3290
    JM K
    Participant

    Hi Jesse,

    thank you very much for the reply. I wrote a small C program that would just open the ‘file’, ttyUSB0 and send out an SMS to a phone number using the AT commands. I am however getting a Segmentation fault when I try to open the file ttyUSB0 and write an AT command to it. Here is my program:

    void main()

    {

    FILE *fileptr;

    fileptr = fopen(” /dev/ttyUSB0 :,”a”);

    puts(“AT!SSMS=0,xxxxxxxx,0,yyyyyyyyyy”); /* xxxxxxxxx is the phone number and yyyyyyyyy is the message */

    fclose(fileptr);

    }

    I would appreciate it if you could let me know where my program went wrong. Thank you very much and have a great day.

    Best Regards,

    JM

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.