From: Harvie Date: Mon, 30 Aug 2010 12:45:41 +0000 (+0200) Subject: Added little C program to pulse Serial line DTR on Linux (can reset Arduino) X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=5cf8708d01329e09a411d323dcf07435d63493e1;p=mirrors%2FPrograms.git Added little C program to pulse Serial line DTR on Linux (can reset Arduino) --- diff --git a/c/serial-pulse-dtr.c b/c/serial-pulse-dtr.c new file mode 100644 index 0000000..0809c89 --- /dev/null +++ b/c/serial-pulse-dtr.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +/* 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; +}