Hi,
I wrote a simple code in C that intends to write data on the serial port (/dev/ttyGS0) and verify if that data is being written (using windows - COM4). The code intends to write the word "DATA " on the serial port once every second, but on the console terminal on windows (command prompt) I see the word data being printed 7x every seven seconds. Below is the code:
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
int main(int argc, char *argv[])
{
int fd;
struct termios options;
fd = open ("/dev/ttyGS0", O_RDWR | O_NOCTTY | O_NDELAY);
memset(&options, 0x00, sizeof(options));
options.c_cflag = (B115200 | CS8 | CLOCAL | CREAD);
options.c_lflag = 0;
options.c_iflag = 0;
options.c_oflag = 0;
options.c_cc[VTIME] = 0;
options.c_cc[VMIN] = 1;
tcsetattr(fd, TCSANOW, &options);
for (;
{
tcflush(fd, TCIOFLUSH);
sleep(1);
write (fd, "data ", 5);
}
close(fd);
return 0;
}
Do you have any ideas why this happens? thanks.
-uchiha