Good morning, The code listed below is part of a link level serial protocol that doesn't port to Win32. A framed message with a checksum is sent and then a single character response (ACK or NAK) is expected in return. On the Win32 platform, this form of select is only implemented for sockets, and alarm() is not implemented at all. How can I set up a sysread() with an adjustable timeout on a device in MS-Windows?
$port = 'COM4' unless $port; sysopen( PORT, "$port", O_RDWR ) or die "Can't sysopen $port: $!"; binmode(PORT); # loop on NAK or timeout with two retries $done = 0; $tries = 0; do { syswrite PORT, $_, length; $rin = $win = $ein = ''; vec($rin, fileno(PORT), 1) = 1; vec($win, fileno(PORT), 1) = 1; $ein = $rin | $win; $timeout = 3.0; ($nfound,$timeleft) = select($rout=$rin, $wout=$win, $eout=$ein, $timeout); if ($nfound > 0) { $inchar = sysread PORT, $line, 1, 0; if (ord ($line) == 21) { print STDOUT " NAK"; } if (ord ($line) == 6) { print STDOUT " ACK"; $done = 1; } } else { print STDOUT " t/o"; } } while ($done == 0 && ++$tries < 3); print STDOUT "\n"; if ($done == 0) { next LINE; } I have ActiveState Perl 5.8.0.806 or Cygwin with Perl 5.6.1 available. Both versions are parts of SDK's which prevent me from upgrading. I tried to install Linux in a VM session, but I don't have a recent enough version of VMWare to do so, and my manager has refused to allow me to update that one either. (He said something about being too near the end of the fiscal year.) NOTA BENE: I don't do objects. After 30 years of procedural code, they don't make any sense to me, on several levels. I have looked at Win32-SerialPort-0.19 but can't make heads nor tails of it. Thank you, Bob McConnell Principal Communications Programmer The CBORD Group, Inc. 61 Brown Road Ithaca NY, 14850 Phone 607 257-2410 FAX 607 257-1902 Email [EMAIL PROTECTED] Web www.cbord.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/