wa4otj has asked for the wisdom of the Perl Monks concerning the following question:
BUT...
I am finding an extremely steep learning curve in figuring out how to do serial I/O under perl. I have the modules Win32-Serialport, Win32API-Commport, and have played with perl-GPS and Device-Davis (interfaces to Garmin GPS receivers, and Davis weather stations respectively). These seem *WAY* more complex than I need. Plus, I'm having a real dog of a time wrapping my brain around how they work, or more importantly, how to use them.
I have a Lexicon DC2 preamp in my media center. It is controllable via RS232, and I want to interface it to my home automation system using perl. It's communications protocol is very simple. Send it a few bytes representing a command, (say, select DVD player) look for an ack and exit. No protocol engine, no state machine, etc. It's essentially the same thing as communicating to it via IR (which is how my home automation system does it today) except it's two-way and you can inquire status, etc, as well as receive confirmation that commands worked. Plus you can control things that IR can't.
What I want to do is write a simple script that will take a literal command on the commandline (e.g. SelectDVD), translate it to the correct HEX string, output it to com1, wait for an ack, and then exit with a return code.
I can write it all quite easily except for the bit about sending the string out the serial port and looking for a response.
That learning curb again.
After several hours studying the topic, I decided to appeal to the monks for a leg up. Can anyone point me to some simple perl code that will accept a string of bytes, output it to a serial port, and return the answer, exiting with an error code if no answer is forthcoming within a second or so?
If so, you would be accomplishing two things. Helping a perl novice complete a useful program, and helping that same novice progress slowly toward enlightenment.
And I would be most appreciative.
Nathan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: *extremely* simple Serial I/O
by BrowserUk (Patriarch) on Nov 02, 2003 at 19:46 UTC | |
by wa4otj (Beadle) on Nov 03, 2003 at 17:38 UTC | |
|
Re: *extremely* simple Serial I/O
by chanslor (Acolyte) on Feb 02, 2004 at 03:24 UTC |