[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avrdude-dev] [PATCH] ft245r: add sem_wait with timeout on POSIX
From: |
René Liebscher |
Subject: |
Re: [avrdude-dev] [PATCH] ft245r: add sem_wait with timeout on POSIX |
Date: |
Mon, 26 Jan 2015 22:42:01 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
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é