Pridana detekce keypressu
[mirrors/Programs.git] / c / serial-pulse-dtr.c
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <asm-generic/ioctls.h>
4 #include <unistd.h>
5
6 /* Pulse DTR (Harvie 2o1o)
7 * This can be used eg.: for reseting Arduino
8 *
9 * make serial-pulse-dtr
10 * ./serial-pulse-dtr /dev/ttyUSB0
11 *
12 * (-; peace ;-)
13 */
14
15 int main(int argc, char *argv[]) {
16 if(argc < 2) printf("Usage: %s [/dev/tty*]\n", argv[0]);
17
18 int fd = open(argv[1], O_WRONLY);
19 perror(argv[0]);
20
21 //DTR HIGH
22 //ioctl(fd, TIOCSDTR);
23 ioctl(fd, TIOCMBIS);
24
25 //Wait
26 //system("sleep 0.1");
27 usleep(100000);
28
29 //DTR LOW
30 //ioctl(fd, TIOCCDTR);
31 ioctl(fd, TIOCMBIC);
32
33 close(fd);
34 return 0;
35 }
This page took 0.386258 seconds and 4 git commands to generate.