Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
I encountered a strange phenomenon when reading / writing to RS232 serial device (on my Linux machine /dev/ttyS0)
I have simple 2 processes:
1) process which WRITE characters to serial device /dev/ttyS0
For example write the characters "aa102222233333444445555566666777778888899999aaaaa bbbbbcccccddddd"
2) process which READ characters from serial device /dev/ttyS0 ( the process is blocked when nothing to be read)
I short the TX and the RX pins in my RS232 PC port (the 9 pins serial connector) so I 'll be able to read what I write.
The problem is:
when WRITE process write something like "aa102222233333444445555566666777778888899999aaaaa bbbbbcccccddddd"
The READ process reads some time read ONLY part of the above characters like: "8888899999aaaaabbbbbcccccdddddaa102222233333"
In my test I run WRITE process few times and check what READ process get
I want to emphasize that this problem happens some time (most case when I run process READ first time, but some time after few time that I write to the serial device)
Can you please help me to understand what is wrong?
code:
Process write:
----------------
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
int main()
{
int fd; /* File descriptor for the port */
Open Source Security Myths Dispelled Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization subscribe
InformationWeek InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology. subscribe