summaryrefslogtreecommitdiff
path: root/tools/reset_arduino.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/reset_arduino.c')
-rw-r--r--tools/reset_arduino.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/reset_arduino.c b/tools/reset_arduino.c
index 99ace88..53dbbf5 100644
--- a/tools/reset_arduino.c
+++ b/tools/reset_arduino.c
@@ -27,6 +27,8 @@
#include <time.h>
#include <stdio.h>
#include <sys/select.h>
+#include <errno.h>
+#include <string.h>
#define STATE_OFF 0
#define STATE_ON 1
@@ -44,10 +46,12 @@ main(int argc, char* argv[])
{
char* device = argc < 2 ? "/dev/ttyUSB0" : argv[1];
int fd = open(device, O_RDWR);
- if (fd == 0) {
- fprintf(stderr, "Could not open %s\n", device);
+ if (fd < 0) {
+ fprintf(stderr, "Could not open %s (%s)\n", device, strerror(errno));
return EXIT_FAILURE;
}
+
+ printf("reseting arduino at %s\n", device);
setDTRState(fd, STATE_ON);
struct timeval sleeptime = {0, 100000}; // 100ms