Zkus tohle, me to kdysi fungovalo .....
#include <termios.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#define BAUDRATE B9600
#define SERIAL "/dev/ttyS0"
int main(void)
{
int fdcom;
struct termios oldtio, newtio, akttio;
int flags;
int flst, flold;
int bit_ST = TIOCM_ST;
int bit_SR = TIOCM_SR;
int bit_LE = TIOCM_LE;
int bit_RTS = TIOCM_RTS;
int bit_CTS = TIOCM_CTS;
int bit_DTR = TIOCM_DTR;
int bit_DSR = TIOCM_DSR;
int bit_CD = TIOCM_CD;
int bit_RI = TIOCM_RI;
/*config for serial device */
fdcom = open(SERIAL, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fdcom < 0) {
perror(SERIAL);
return(-1);
}
tcgetattr(fdcom, &oldtio); /* save current port settings */
/* new port settings */
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD | HUPCL;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag = TOSTOP;
newtio.c_cc[VMIN] = 1;
newtio.c_cc[VTIME] = 0;
tcflush(fdcom, TCIFLUSH);
tcsetattr(fdcom, TCSANOW, &newtio);
printf("port: %s\n", SERIAL);
for (;;) {
(void) ioctl(fdcom, TIOCMGET, &flags);
flst = (flags & bit_RTS);
printf("RTS: %03x ", flst);
flst = (flags & bit_CTS);
printf("CTS: %03x ", flst);
flst = (flags & bit_DTR);
printf("DTR: %03x ", flst);
flst = (flags & bit_DSR);
printf("DSR: %03x ", flst);
flst = (flags & bit_CD);
printf("CD: %03x ", flst);
flst = (flags & bit_RI);
printf("RI: %03x \n", flst);
// printf("flags: 0x%03x\n", flags);
usleep(500000);
}
/* restore old port settings */
tcsetattr(fdcom, TCSANOW, &oldtio);
}