Added little C program to pulse Serial line DTR on Linux (can reset Arduino)
authorHarvie <tomas@mudrunka.cz>
Mon, 30 Aug 2010 12:45:41 +0000 (14:45 +0200)
committerHarvie <tomas@mudrunka.cz>
Mon, 30 Aug 2010 12:45:41 +0000 (14:45 +0200)
c/serial-pulse-dtr.c [new file with mode: 0644]

diff --git a/c/serial-pulse-dtr.c b/c/serial-pulse-dtr.c
new file mode 100644 (file)
index 0000000..0809c89
--- /dev/null
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <asm-generic/ioctls.h>
+#include <unistd.h>
+
+/* Pulse DTR (Harie 2o1o)
+ * This can be used eg.: for reseting Arduino
+ *
+ * make serial-pulse-dtr
+ * ./serial-pulse-dtr /dev/ttyUSB0
+ *
+ * (-; peace ;-)
+ */
+
+int main(int argc, char *argv[]) {
+       if(argc < 2) printf("Usage: %s [/dev/tty*]\n", argv[0]);
+
+       int fd = open(argv[1], O_WRONLY);
+       perror(argv[0]);
+
+       //DTR HIGH
+       //ioctl(fd, TIOCSDTR);
+       ioctl(fd, TIOCMBIS);
+
+       //Wait
+       //system("sleep 0.1");
+       usleep(100000);
+
+       //DTR LOW
+       //ioctl(fd, TIOCCDTR);
+       ioctl(fd, TIOCMBIC);
+
+       close(fd);
+       return 0;
+}
This page took 0.116429 seconds and 4 git commands to generate.