diff options
Diffstat (limited to 'src/clear_rts.c')
-rw-r--r-- | src/clear_rts.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/clear_rts.c b/src/clear_rts.c new file mode 100644 index 0000000..52da3f5 --- /dev/null +++ b/src/clear_rts.c @@ -0,0 +1,42 @@ +/* Compile with: + gcc -o toggle_rts toggle_rts.c + + Change PORT if necessary. + */ +#define PORT "/dev/ttyS0" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include <stdio.h> +#include <stdlib.h> +#include <termios.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <linux/serial.h> + +int main() { + int fd, status; + + fd = open(PORT, O_RDWR); + if(fd < 0) { + perror(PORT); + return 1; + } + + // fprintf(stderr, "ioctl(fd, TIOCMGET, &status);\n"); + ioctl(fd, TIOCMGET, &status); + /* + if(status & TIOCM_RTS) { + fprintf(stderr, "RTS set\n"); + } else { + fprintf(stderr, "RTS clear\n"); + } + */ + status &= ~TIOCM_RTS; + ioctl(fd, TIOCMSET, &status); + // fprintf(stderr, "ioctl(fd, TIOCMSET, &status);\n"); + fprintf(stderr, "RTS forced off (Tucker SIO2PC)\n"); + return 0; +} |