libftdi Archives

Subject: Re: Re: [ANNOUNCE] libftdi 1.0 third release candidate

From: Xiaofan Chen <xiaofanc@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 25 Jan 2013 21:37:18 +0800
On Fri, Jan 25, 2013 at 9:10 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> On Fri, Jan 25, 2013 at 9:03 PM, Thomas Jarosch
> <thomas.jarosch@xxxxxxxxxxxxx> wrote:
>> On Friday, 25. January 2013 20:50:17 Xiaofan Chen wrote:
>>> > Hopefully this is the final release candidate and we can
>>> > push out libftdi 1.0 next week for good.
>>>
>>> There are some problems with Sleep definition in the examples.
>>>
>>> Here is the build log with MinGW.org's MinGW/MSys.
>>>
>>> It would be good to be able to manually specify the libconfuse
>>> include and lib just like libusb-1.0. It seems to use pkg-config
>>> where native MinGW does not provide.
>>>
>>> I am also not build Boost bindings and Unit test example here
>>> due to the lack of Boost in my current MinGW.org toolchain.
>>
>> This affects the Windows build only. So IMHO this is not a show stopper for
>> the 1.0 final. Let's get it out of the door and fix minor stuff like this 
>> later
>> on. Otherwise we end up polishing it until 2015 ;)
>
> 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>

-- 
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread