spurperl has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

After a couple of days of dire difficulties, I finally managed to marry Win32::SerialPort, Tk and threads into a jolly threesome. It was an interesting experience and I plan to write a largish article about it, but for now I'd like to ask about two problems I still have with Win32::SerialPort:

  1. When I try to read and open a port which already receives a stream of data, sometimes I get errors opening and sometimes the data is weird. All is fine when the port is idle when I open it.
  2. I wrap calls to SerialPort's functions with eval{}, but yet some errors "slip through". In a GUI environment this is intolerable. Any ideas ?

By the way, I use SerialPort to monitor several ports simultaneously. My "paradigm" for doing it is:

my ($done, $rb, $byte) = $port->read_done(0); $port->read_bg(1) if ($done); if ($rb > 0) { print $fh "$byte\n"; }
This is because I need to record any character individually (I actually log the time of its arrival).