I tried to write data from RS232 to a file with cat:
cat /dev/ttyS0 > rs232.log
As a result, I had everything in my file except the last line.
By printing to stdout, I was able to find that the cat only writes the output if it receives a newline ('\ n'). I found the same thing:
dd bs=1 if=/dev/ttyS0 of=rs232.log
After reading, How can I print text right away without waiting for a new line in Perl? I was starting to think if this could be a buffering problem with either the Linux Kernel or the coreutils package.
According to TJD's comment, I wrote my own C program, but still had the same problems:
#include <stdio.h> #include <stdlib.h> int main(int argc, char* args[]) { char buffer; FILE* serial; serial = fopen(args[1],"r"); while(1) { buffer = fgetc(serial); printf("%c",buffer); } }
Based on the results of my own C code, this seems like a problem with Linux-Kernel.
source share