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

I am running into a problem with differences between Device::SerialPort under Linux and Win32::SerialPort under Windows. Specifically, the read() method seems to differ under both.

For example, using Device::SerialPort under Linux, the call:

# $port is a Device::SerialPort object $port->read(1);
returns immediately, while under Win32::SerialPort, the call blocks forever.

Does anyone know of a way around this? I prefer the Device::SerialPort semantics. Can Device::SerialPort be used successfully under Windows? Are there other differences between the two modules?

Thank you for your time.

Replies are listed 'Best First'.
Re: Difference Between Device::SerialPort and Win32::SerialPort
by PodMaster (Abbot) on Apr 16, 2004 at 02:32 UTC
    Does anyone know of a way around this?
    From what I've read, anyone who RTFMs (see timeouts in the manual).
    I prefer the Device::SerialPort semantics.
    According to the docs, Device::SerialPort doesn't have semantics and Any discrepancies or omissions should be considered bugs and reported to the maintainer. The read differences are documented, so I guess they're not "bugs" anymore.
    Can Device::SerialPort be used successfully under Windows?
    Have you tried it? Did you look at the source? Did you check cpan-testers? Having done all 3 my guess would be no, esp. since there is no point (since Device::SerialPort is supposed to be Win32::SerialPort for unices).
    Are there other differences between the two modules?
    Yes. They're documented in Device::SerialPort. Here's a little quote The read method, and tied methods which call it, currently can use a fixed timeout which approximates behavior of the Win32::SerialPort...

    PS - I haven't actually used either of these modules to develop apps, but I sure can RTFM :)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Indeed, thank you for the pointer to the timeout section of the manual. I did not need the timeouts when using Device::SerialPort so I completely overlooked them. I changed my code and my "blocking" forever problem in Windows has been solved.

      For some reason my program does not appear to be writing when running under Windows. It writes correctly under Linux, but my embedded controller does not see any activity when run under Windows. I'm not sure of the problem; however, I will read the Win32::SerialPort documentation more carefully.

      Thank you for your suggestions and response.