minicom
that can read and
write to the serial port, and also set port parameters.
Using this (or the more common stty
),
connect two PCs using the null modem cables, and set both
to 9600baud, 8 data bits, 1 stop bit and exchange data
char *fgets(char *string, int str_length, FILE *fp)
where the string
is an array of char
,
and fp
is stdin
.
End of file is signalled by the function returning
NULL
:
char str[128];
while (fgets(str, 128, stdin) != NULL) ...
int write(int file_descriptor, char *string, int str_len)
where the file_descriptor
is the file descriptor
from opening the serial port,
0
and the string is an array of char
.
The value returned is the number of characters read
char str[128];
write(0, str, 128);