Hi Uwe,
> can anybody comment on the appended patchset.
I'll try my very best ;)
> After adding an empty transfer in the async example, only the first
> run succeeds. After adding a case for empty transfers with the second
> patch, consecutive runs of the sync example succeed.
it's a bit odd that empty async transfers are not handled
at the libusb level.
Did you try tracing into libusb? Debug printing?
I'm willing to apply this fix:
>From 89d9684fd4dfde0fdc6d11f7ee957383b39aa954 Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Jul 2018 21:35:40 +0200
Subject: ftdi_write_data_submit: Handle empty transfers.
---
src/ftdi.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/ftdi.c b/src/ftdi.c
index 52266d0..e2efc3a 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -1660,6 +1660,12 @@ struct ftdi_transfer_control
*ftdi_write_data_submit(struct ftdi_context *ftdi,>
if (!tc)
return NULL;
+ if (!size) {
+ tc->completed = 1;
+ tc->offset = 0;
+ tc->transfer = 0;
+ return tc;
+ }
transfer = libusb_alloc_transfer(0);
if (!transfer)
{
> From 4da9e37309058ace7c354b7ac109c69df7678afa Mon Sep 17 00:00:00 2001
> From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
> Date: Wed, 18 Jul 2018 21:35:19 +0200
> Subject: examples/async.c: Test empty write transfer.
>
> Running "async -b" will fail after the first run.
> ---
>
> examples/async.c | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/examples/async.c b/examples/async.c
> index 0589479..9143155 100644
> --- a/examples/async.c
> +++ b/examples/async.c
> @@ -132,7 +132,7 @@ int main(int argc, char **argv)
>
> struct ftdi_transfer_control *tc_write;
> uint8_t data[3];
> if (do_read) {
>
> - tc_read = ftdi_read_data_submit(ftdi, data, DATA_TO_READ);
> + tc_read = ftdi_read_data_submit(ftdi, data, DATA_TO_READ - 1);
>
> }
> if (do_write) {
>
> tc_write = ftdi_write_data_submit(ftdi, ftdi_init,
> sizeof(ftdi_init));
yuk, the ftdi_init variable really caught me in the example.
I think we should choose a different variable name since
ftdi_init() is also a function name in libftdi.
Any explanation why "DATA_READ" was changed to "DATA_READ -1"?
Cheers,
Thomas
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|