comparison sw/libserial/openport.c @ 21:c4346cdc9641

sw/libserial: based on FC host tools version
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 22 Aug 2023 02:44:23 +0000
parents
children
comparison
equal deleted inserted replaced
20:f6579cef76e1 21:c4346cdc9641
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 }