On Fri, Jan 25, 2013 at 9:37 PM, Xiaofan Chen <[email protected]> wrote: >> The examples build used to be okay though, not so >> sure it is because of the change in MinGW or because of the >> change in ftdi.h and examples (now no libusb-1.0.h include >> which might take care of the Win32 situation). >> Ref: >> http://developer.intra2net.com/mailarchive/html/libftdi/2012/msg00099.html >> >> But I agree with you this is very minor. But if some >> Windows expert can come out a quick fix to the >> sleep problem, then it would not hurt to work. > > Okay, it seems to me the following simple patch works fine > for Windows, tested with MinGW. > > Ref: > http://mingw-users.1079350.n2.nabble.com/usleep-not-available-td5239654.html > usleep exists in MinGW's <unistd.h>. > > diff --git a/examples/bitbang.c b/examples/bitbang.c > index 1d69e2e..75bc4eb 100644 > --- a/examples/bitbang.c > +++ b/examples/bitbang.c > @@ -4,7 +4,7 @@ > #include <stdlib.h> > #include <unistd.h> > #ifdef __WIN32__ > -#define sleep(x) Sleep(x) > +#define sleep(x) usleep(x * 1000) > #endif > #include <ftdi.h> > > diff --git a/examples/bitbang2.c b/examples/bitbang2.c > index 26f3338..f10a496 100644 > --- a/examples/bitbang2.c > +++ b/examples/bitbang2.c > @@ -32,9 +32,6 @@ > #include <stdio.h> > #include <stdlib.h> > #include <unistd.h> > -#ifdef __WIN32__ > -#define usleep(x) Sleep((x+999)/1000) > -#endif > #include <ftdi.h> > > void ftdi_fatal (struct ftdi_context *ftdi, char *str) > diff --git a/examples/bitbang_ft2232.c b/examples/bitbang_ft2232.c > index 253555a..8444681 100644 > --- a/examples/bitbang_ft2232.c > +++ b/examples/bitbang_ft2232.c > @@ -12,7 +12,7 @@ > #include <stdlib.h> > #include <unistd.h> > #ifdef __WIN32__ > -#define sleep(x) Sleep(x) > +#define sleep(x) usleep(x * 1000) > #endif > #include <ftdi.h> > > diff --git a/examples/serial_test.c b/examples/serial_test.c > index 6a9d8ff..91b1a2c 100644 > --- a/examples/serial_test.c > +++ b/examples/serial_test.c > @@ -9,7 +9,7 @@ > #include <stdlib.h> > #include <unistd.h> > #ifdef __WIN32__ > -#define sleep(x) Sleep(x) > +#define sleep(x) usleep(x * 1000) > #endif > #include <getopt.h> > #include <signal.h>
I think the better fix is to use usleep and get rid of the ugly __WIN32__ defines. -- Xiaofan -- libftdi - see http://www.intra2net.com/en/developer/libftdi for details. To unsubscribe send a mail to [email protected]
