FreeCalypso > hg > freecalypso-tools
comparison miscutil/fc-pulse-rts.c @ 735:5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 15 Sep 2020 04:29:43 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 734:23f41a61ff7a | 735:5b8287c655cf |
|---|---|
| 1 /* | |
| 2 * This utility opens a serial port, asserts RTS for 50 ms, then negates it | |
| 3 * and exits. It is intended for use with FreeCalypso DUART28C adapters. | |
| 4 */ | |
| 5 | |
| 6 #include <sys/types.h> | |
| 7 #include <sys/file.h> | |
| 8 #include <sys/ioctl.h> | |
| 9 #include <stdio.h> | |
| 10 #include <stdlib.h> | |
| 11 #include <unistd.h> | |
| 12 | |
| 13 main(argc, argv) | |
| 14 char **argv; | |
| 15 { | |
| 16 int target_fd; | |
| 17 int mctl_arg = TIOCM_RTS; | |
| 18 | |
| 19 if (argc != 2) { | |
| 20 fprintf(stderr, "usage: %s ttyname\n", argv[0]); | |
| 21 exit(1); | |
| 22 } | |
| 23 target_fd = open(argv[1], O_RDWR|O_NONBLOCK); | |
| 24 if (target_fd < 0) { | |
| 25 perror(argv[1]); | |
| 26 exit(1); | |
| 27 } | |
| 28 ioctl(target_fd, TIOCMBIS, &mctl_arg); | |
| 29 usleep(50000); | |
| 30 ioctl(target_fd, TIOCMBIC, &mctl_arg); | |
| 31 exit(0); | |
| 32 } |
