in reply to win32::serial port

What moritz has said is correct.

In my experience the best way to deal with serial communications is to formulate a protocol that both sides of the line will follow. Usually this involves having a fixed message size or ending the message with a terminating character (such as a CR). Also, it is common to have a checksum of the bytes embedded in the message. As long as both parties agree and there isn't too much noise on the line, it should work.

As for the Win32::SerialPort module, it looks to be very outdated, the interface isn't very good, and the examples are somewhat complicated. I also didn't see anything having to do with flushing.

Replies are listed 'Best First'.
Re^2: win32::serial port
by ikegami (Patriarch) on Oct 30, 2008 at 04:22 UTC

    the interface isn't very good

    How so? It uses the standard Perl IO interface (print $comm $data;) and some setters/getters to set/query communication settings.

    I also didn't see anything having to do with flushing.

    Why would expect it to be buffered?

      How so?
      I guess I would want something a little more akin to IO::Socket::Inet. Otherwise, it's fine.
      Why would expect it to be buffered?
      I did not expect it to be buffered, but it was asked in the question how one could flush the serial port. Usually what I've seen is that people want to flush the rx buffer to get rid of any remaining bytes after reading the current message.