comparison libserial-orig/openport.c @ 248:cb1ba53a1106

beginning of factored-out libserial
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 21 Sep 2017 21:43:34 +0000
parents
children
comparison
equal deleted inserted replaced
247:b5b148ef63da 248:cb1ba53a1106
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 }