in reply to *extremely* simple Serial I/O

Win32::SerialPort is about as easy as it is possible to be. Try uing the tie interface. With this, you simply tie a filehandle to the serial port the device is attached to, COM1: COM2: etc., and then just print to it and read (<device>) from it using the standard perl io operators.

The example shown under the heading "Methods used with Tied FileHandles" in the pod, pretty much tells you all you need to know with regard to reading and writing. The only other part to understand is configuring the port to the appropriate baud rate, parity, start & stop bits, handshaking etc. but you would need to do this whatever language or comms library you used. Try typing help MODE for a little information on what can/needs to be configured, though the pod with the module seems pretty comprehesive.

As a simple first pass at getting things configured correctly, you can just use the comand line MODE COM1 BAUD=9600 etc to configure it, and the COPY CON COM1 to send and copy COM1 CON to retrieve responses. Once you get that to work, writing the program using WIn32::SerialPort should be pretty easy.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!

Replies are listed 'Best First'.
Re: Re: *extremely* simple Serial I/O
by wa4otj (Beadle) on Nov 03, 2003 at 17:38 UTC
    I finally found geiger.pl, a perl script to read the port for incoming data, and write it to a file. It provided the working and simple sample code to bootstrap my efforts.

    I now have working code for doing I/O, both send and receive, so it is a major victory. I had a little difficulty getting the port configured correctly as it kept giving me an obtuse error message. But I finally licked that too.

    The only thing holding me back now is figuring out how to end the read, given that I don't necessarily know what the response is going to be. But I think I am making good progress.

    Thanks for the response,

    Nathan