diff miscutil/fc-pulse-dtr.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/miscutil/fc-pulse-dtr.c	Tue Sep 15 04:29:43 2020 +0000
@@ -0,0 +1,32 @@
+/*
+ * This utility opens a serial port, asserts DTR for 50 ms, then negates it
+ * and exits.  It is intended for use with FreeCalypso DUART28C adapters.
+ */
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+main(argc, argv)
+	char **argv;
+{
+	int target_fd;
+	int mctl_arg = TIOCM_DTR;
+
+	if (argc != 2) {
+		fprintf(stderr, "usage: %s ttyname\n", argv[0]);
+		exit(1);
+	}
+	target_fd = open(argv[1], O_RDWR|O_NONBLOCK);
+	if (target_fd < 0) {
+		perror(argv[1]);
+		exit(1);
+	}
+	ioctl(target_fd, TIOCMBIS, &mctl_arg);
+	usleep(50000);
+	ioctl(target_fd, TIOCMBIC, &mctl_arg);
+	exit(0);
+}