target.tv_sec +=usecs/1000000 + (target.tv_usec/1000000);
target.tv_usec%=1000000;
+ target.tv_usec+=1000000;
+ target.tv_sec --;
+
for (;;)
FD_ZERO(&readfds);
if (device_portfd>=0)
if (target.tv_sec < timeout.tv_sec)
return;
timeout.tv_sec =target.tv_sec - timeout.tv_sec;
- if (target.tv_usec < timeout.tv_usec) {
- target.tv_usec+=1000000;
- if (target.tv_sec <= 0)
- return;
- target.tv_sec--;
- }
timeout.tv_usec=target.tv_usec - timeout.tv_usec;
+ if (timeout.tv_usec>=1000000) {
+ timeout.tv_usec-=1000000;
+ if (!timeout.tv_sec)
+ return;
+ timeout.tv_sec--;
+ }
err=select((device_portfd<0 ? 0 : device_portfd+1),&readfds,NULL,NULL,&timeout);
if ( err > 0 ) {