WiringPi: Remove files that seem won't be used or already have not been used
Signed-off-by: Deokgyu Yang <secugyu@gmail.com>
Change-Id: I1189f950d0e51cbc4c569b1e7a1182dc5f8fe762
diff --git a/examples/delayTest.c b/examples/delayTest.c
index 4c8b6ca..d772cf9 100644
--- a/examples/delayTest.c
+++ b/examples/delayTest.c
@@ -25,7 +25,6 @@
#include <stdio.h>
#include <unistd.h>
-#include <wiringPi.h>
#include <sys/time.h>
@@ -34,17 +33,13 @@
int main()
{
int x ;
- struct timeval t1, t2 ;
+ struct timeval t1, t2, t3 ;
int t ;
int max, min ;
int del ;
- int underRuns, overRuns, exactRuns, total ;
+ int underRuns, overRuns, exactRuns, bogusRuns, total ;
int descheds ;
- if (wiringPiSetup () == -1)
- return 1 ;
-
- piHiPri (10) ; sleep (1) ;
// Baseline test
@@ -58,21 +53,22 @@
{
underRuns = overRuns = exactRuns = total = 0 ;
descheds = 0 ;
- max = del ;
- min = del ;
+ max = 0 ;
+ min = 999 ;
for (x = 0 ; x < CYCLES ; ++x)
{
for (;;) // Repeat this if we get a delay over 999uS
{ // -> High probability Linux has deschedulled us
gettimeofday (&t1, NULL) ;
- delayMicroseconds (del) ;
+ usleep (del) ;
+// delayMicroseconds (del) ;
gettimeofday (&t2, NULL) ;
- if (t2.tv_usec < t1.tv_usec) // Counter wrapped
- t = (1000000 + t2.tv_usec) - t1.tv_usec;
- else
- t = t2.tv_usec - t1.tv_usec ;
+ timersub (&t2, &t1, &t3) ;
+
+ t = t3.tv_usec ;
+
if (t > 999)
{
++descheds ;
@@ -82,25 +78,24 @@
break ;
}
- if (t > max)
- {
- max = t ;
- ++overRuns ;
- }
- else if (t < min)
- {
- min = t ;
- ++underRuns ;
- }
- else
+ if (t == del)
++exactRuns ;
+ else if (t < del)
+ ++underRuns ;
+ else if (t > del)
+ ++overRuns ;
+
+ if (t > max)
+ max = t ;
+ else if (t < min)
+ min = t ;
total += t ;
}
printf ("Delay: %3d. Min: %3d, Max: %3d, Unders: %3d, Overs: %3d, Exacts: %3d, Average: %3d, Descheds: %2d\n",
del, min, max, underRuns, overRuns, exactRuns, total / CYCLES, descheds) ;
fflush (stdout) ;
- delay (1) ;
+ usleep (1000) ;
}
return 0 ;