User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:examples:talk_to_a_modem

Talk to a Modem

This is a Simple source how to Access a Modem.
it is very simple, just write a Modem Command to your Serial Port
in this case a serial Port ttyS0 in Linux

C Sourcecode to acces a modem

#include <stdio.h>
#include <unistd.h> // for sleep
 
/**
 * argument 1 is the number to dial
 * for this example you need a modem on Serial Port (in linux)
 */
int main(int argc,char *argv[])
{
    FILE *modem;
    char get[100];
 
    modem=fopen("/dev/ttyS0","rw");
    fprintf(modem,"ATZ\r\n");
    fscanf(modem,"%s",get);
    printf("%s\n",get);
    fprintf(modem,"ATDT%s\r\n",argv[1]);
    sleep(2);
 
    fclose(modem);
    return 0;
}

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/examples/talk_to_a_modem.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz