]>
git.defcon.no Git - hm-trp-tool/blob - serial.c
3 int open_port ( char* device
, int rate
)
8 f
= open ( device
, O_RDWR
| O_NOCTTY
); // Not using O_NDELAY, that caused ERR11: temp unavail.
14 tio
.c_cflag
= rate
| CS8
| CLOCAL
| CREAD
;
16 // 8 bits, local mode, read enabled
17 tio
.c_cflag
|= CS8
| CLOCAL
| CREAD
;
20 tio
.c_cflag
&= ~CRTSCTS
;
26 tio
.c_lflag
= 0; // Non-canonical read, no other options.
27 tio
.c_cc
[VMIN
] = 0; // Disable minimum characters for read
28 tio
.c_cc
[VTIME
] = 5; // Wait for a max of 0.5 second
30 tcsetattr(f
,TCSANOW
,&tio
); // Apply this now.
32 tcflush(f
, TCIFLUSH
); // the serial input buffer.