From 9a101943b8c5f202c19d6f4bd8aca40ec8ead17c Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 8 Apr 2011 19:50:09 +0000 Subject: [PATCH] tamashell: now pause in milliseconds --- examples/pn53x-tamashell.1 | 2 +- examples/pn53x-tamashell.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/examples/pn53x-tamashell.1 b/examples/pn53x-tamashell.1 index 3607e05..598528c 100644 --- a/examples/pn53x-tamashell.1 +++ b/examples/pn53x-tamashell.1 @@ -22,7 +22,7 @@ Shebang is supported, simply start your script with: .SH COMMANDS -\fIp N\fP to introduce a pause of N seconds. +\fIp N\fP to introduce a pause of N milliseconds. \fIq\fP or \fICtrl-d\fP to quit. diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index 9c79a28..e874905 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -47,7 +47,20 @@ #include #include #include -#include +#include + +#ifndef _WIN32 +// Needed by sleep() under Unix +# include +# define sleep usleep +# define SUSP_TIME 1000 // usecs. +#else +// Needed by Sleep() under Windows +# include +# define sleep Sleep +# define SUSP_TIME 1 // msecs. +#endif + #include @@ -132,9 +145,9 @@ int main(int argc, const char* argv[]) offset++; } sscanf(cmd+offset, "%d", &s); - printf("Pause for %i secs\n", s); + printf("Pause for %i msecs\n", s); if (s>0) { - sleep(s); + sleep(s * SUSP_TIME); } free(cmd); continue;