From 8e15784c28f45b9944af57e044bf2c612c1c65e1 Mon Sep 17 00:00:00 2001 From: Diego Roversi Date: Sun, 21 Aug 2016 21:08:26 +0100 Subject: Correct bug: firstInt not reinitialized --- rotor/rotor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rotor/rotor.c b/rotor/rotor.c index f6121f4..d231b21 100644 --- a/rotor/rotor.c +++ b/rotor/rotor.c @@ -39,7 +39,7 @@ int main( int argc, char** argv ) gpio_fd = open( "/sys/class/gpio/gpio15_pb2/value", O_RDONLY | O_NONBLOCK ); - timeout = 500; + timeout = 500; //ms clock_gettime(CLOCK_MONOTONIC, &then_ts); @@ -71,6 +71,7 @@ int main( int argc, char** argv ) printf("%d\n\n", number % 10); number=0; } + firstInt=true; } if (fdset[1].revents & POLLPRI) { @@ -87,7 +88,7 @@ int main( int argc, char** argv ) float msec=diff_ts.tv_nsec/1000000.0; - printf("value [%s] sec %d msec %f\n",buf,sec,msec); +// printf("value [%s] sec %d msec %f number pre %d\n",buf,sec,msec, number); if (firstInt || msec > 90) number++; firstInt=false; -- cgit v1.2.3