From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Francisco M. Marzoa Alonso" Subject: (unknown) Date: Tue, 24 Aug 2004 08:05:08 +0200 Sender: linux-serial-owner@vger.kernel.org Message-ID: <200408240805.08811.fmmarzoa@softronica.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from 55.Red-213-4-20.pooles.rima-tde.net ([213.4.20.55]:50395 "EHLO softronica.org") by vger.kernel.org with ESMTP id S266507AbUHXF4h convert rfc822-to-8bit (ORCPT ); Tue, 24 Aug 2004 01:56:37 -0400 Received: from 10.10.0.21 (unknown [10.10.0.21]) by softronica.org (Postfix) with ESMTP id 5C90F7E8B for ; Tue, 24 Aug 2004 07:49:01 +0200 (CEST) Content-Disposition: inline List-Id: linux-serial@vger.kernel.org To: linux-serial@vger.kernel.org >> TOut.tv_sec =3D Wait / 1000; >> TOut.tv_usec =3D Wait % 1000; > >So "Wait" is in milli-seconds? That doesn't look correct, then:) > > TOut.tv_sec =3D Wait / 1000; > TOut.tv_usec =3D (Wait % 1000) * 1000; Sure you're right, but this is a thing that I do not understand. I made= a=20 function GetTickCount to emulate Window's one based on gettimeofday and= see=20 that milliseconds on timeval structure can have values up to 999999 whe= n I=20 expect to found a maximum value of 999 as there are only 1000 milliseco= nds in=20 a second. >> if ( select ( FD_SETSIZE, &readfs, NULL, NULL, &TOut ) ) { >That's most probably wrong. "FD_SETSIZE" should be "HND + 1". ...and t= he >"if" should fire like "if (select (...) > 0)" Ok, I've tried some different values, I'll use only HND+1 from now. >This could hand because you didn't select() on HND *before* writing to >it. You're right. I've fixed this.=20 >> if ( ! select ( FD_SETSIZE, NULL, &writefs, NULL, &TOut ) ) { >> perror ( "Timeout waiting on CommWriteChar"); >> return 0; >> } >select() checks if the next access won't hand (but may return >successfull or with an error instead). It doesn't make much sense to d= o >that *after* having something written down there:) >> return ( bcount ); >> } >Btw: return isn't a function. It's return value doesn't need an own pa= ir >of parentheses. I usually forget this, but I think this makes no efective difference an= d the=20 code generated by the compiler is the same and I feel more comfortable = using=20 them. I've done this changes, that I've no doubt that are needed, but I conti= nue=20 having the same problems as described in my previous e-mail. Thanks a lot. --=20 =46rancisco M. Marzoa Alonso Responsable de Software - Softr=F3nica S.A. http://www.softronica.org/ C/Herrer=EDas, 14 - 28760 Tres Cantos (Madrid) tfno. +34 918 038 600 fax. +34 918 032 297 - To unsubscribe from this list: send the line "unsubscribe linux-serial"= in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html