comparison libserial-newlnx/openport.c @ 254:6984b76f3def

beginning of libserial-newlnx: copy of libserial-orig
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 22 Sep 2017 00:09:37 +0000
parents
children 9d9c241f2c84
comparison
equal deleted inserted replaced
253:6f078c4a5506 254:6984b76f3def
1 /*
2 * This module implements the basic serial port opening operation.
3 */
4
5 #include <sys/types.h>
6 #include <sys/file.h>
7 #include <sys/ioctl.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11
12 int target_fd;
13
14 open_serial_port(ttyport)
15 char *ttyport;
16 {
17 target_fd = open(ttyport, O_RDWR|O_NONBLOCK);
18 if (target_fd < 0) {
19 perror(ttyport);
20 exit(1);
21 }
22 ioctl(target_fd, TIOCEXCL);
23 return 0;
24 }