I'm trying to communicate synchronously with a GSM-modem (really
doesn't matter what's on the other side of the Serial Port!) using
My real problem is to do a synchronous serial communication with
whatever be connected to the serial port.
And I have opened the port this way:
struct termios options,xivato; /* doesn't use xivato ... ;-) */
fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY); /* opens the
fcntl(fd, F_SETFL, 0);
/* which uses this flags with the termos structure:
termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
termios_p->c_oflag &= ~OPOST;
termios_p->c_cflag &= ~(CSIZE|PARENB);
termios_p->c_cflag |= CS8;
tcsetattr(fd, TCSAFLUSH, &options);
But I still have problems:
Doing it this way, I can do this communication, so I can send AT
commands to the modem and I can read his answers but I've got already
-I can't do a blocking read: I mean that what I need is to call a
function to read which doesn't return until there's anything in the
buffer to be read, or which could wait for a little time (I could read
untill the data read is not null, but I prefer do it right!). (I've
tried to un-use the "O_NDELAY" flag, but this doesn't seem to work at
-The program I've wrote runs right once, but I want to run it a second
time, the program blocks trying to read the answer to the firs "AT\r"
command which I send to initialize the modem. When this happens, I've to
run "minicom" and re-initialize the modem, this evidently is not valid
to my program and also means that my program is not good!!!!
Some resources of information
The links in which I have found some interesting information are:
That's what I need ;-)
?Does anybody has already done something like this? ?Can I take a look
to this code?
?Does someone know how can I do this "blocking read" or what's the
matter that I cannot read anymore once I've executed the program once?
?Does anybody know any other resource of information, any link, any
I have no problem to give the C's source of what I've done to anybody
who also has to do something like this and doesn't want to start from
I'm waiting for some holy answer ... Thanks in advance!!!
Angel Galindo Mu?oz