[PATCH] ft245r: add sem_wait with timeout on POSIX

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] ft245r: add sem_wait with timeout on POSIX

Andrey Skvortsov
Hi,

sometimes, if not enough bytes are received from ftdi device, avrdude
hangs in ft245r_recv, to avoid this sem_wait is replaced with
sem_timedwait. I tested this patch on linux.


--
Best regards,
Andrey Skvortsov

Secure eMail with gnupg: See http://www.gnupg.org/
PGP Key ID: 0x57A3AEAD

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

0001-ft245r-fix-hang-if-there-are-no-enough-data-in-receive-buffer.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ft245r: add sem_wait with timeout on POSIX

René Liebscher
Am 26.01.2015 um 16:38 schrieb Andrey Skvortsov:
> Hi,
>
> sometimes, if not enough bytes are received from ftdi device, avrdude
> hangs in ft245r_recv, to avoid this sem_wait is replaced with
> sem_timedwait. I tested this patch on linux.
>
>
Hi,

I guess for MacOS we should implement an own function.

Probably something like this (I do not own a Mac so I cannot check if
this really correct.)

int sem_wait_with_timeout(sem_t * psem, long to_ns)
{
    dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, to_ns);
    long result = dispatch_semaphore_wait(*psem, timeout);
    if (result != 0)
    {
        errno = ETIMEDOUT;
        return -1;
    }
    return 0;
}

Could anyone check this?


Best regards

René



_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ft245r: add sem_wait with timeout on POSIX

Andrey Skvortsov
In reply to this post by Andrey Skvortsov
In-Reply-To=[hidden email]
Reply-To:
X-PGP-Key: fp="21AF 2E6F 04EC 7E11 21C6  E399 2236 2F26 57A3 AEAD";
 id="0x57A3AEAD";
 get=<hkp://pgp.mit.edu/pks/lookup?search=0x22362F2657A3AEAD&op=get>;

Hi René,

I thought about that too, according to the documentation your code looks good.
But I have no access to any of Apple computers too. Therefore can't
test it.

--
Best regards,
Andrey Skvortsov

Secure eMail with gnupg: See http://www.gnupg.org/
PGP Key ID: 0x57A3AEAD

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

signature.asc (853 bytes) Download Attachment