> I'm doing some data-collection using some dedicated devices outputing via 
> their serial port, and I've run into a few roadblocks. My specific example 
> is a BASIC Stamp that's outputting temp every 60 seconds. I know that the 
> data is coming into the Linux serial port, as I can view the data using cu. 
> I've cheated the process by setting up one terminal window to do 'cu -l 
> /dev/ttyS0 > temp.dat', and in another terminal window I've got a perl 
> script that does a 'tail -f' every 60 seconds, appends the time, and writes 
> out to another file. Now I now the temp and time (the BASIC Stamp can't 
> send out time), which I could (for example) read in another perl script and 
> output to html.
> 
> My issue is that I want to do this all with perl, in one script. Call it my 
> nature to make it as 'simple' as possible. I've tried working with the 
> serial port in perl, but I can't find any simple examples that show how to 
> read the serial port (BTW, I don't give a darn about writing to the serial 
> port, as this is data collection). My goal is to be able to set up a simple 
> routine that monitors the serial port for one data line terminating in 
> CR/LF. That's it. I'd prefer not to have to read character by character (as 
> I know every line will end in CR/LF), but will if I have to.
> 
> I know this is a 20-line perl script, to read the serial port for one line 
> of data, append some formatted date info, and append to a disk file. But 
> I'm in need of some breadcrumbs. Just one simple loop that reads for a 
> line, so I can continue with my script.

One of the nice things about perl is its willingness to cooperate with 
other programs. Since cu can read the port just fine, I'd open a pipe:
open SERIAL, "</usr/bin/cd ... " or die "Drat that cu| $!";

and go on with something else. I'm happy to use someone else's wheel.

-- 
Cheers
John Summerfield
http://os2.ami.com.au/os2/ for OS/2 support.
Configuration, networking, combined IBM ftpsites index.


-- 
To unsubscribe:
mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to