On Thu, June 26, 2008 12:37 pm, [EMAIL PROTECTED] wrote:
>

> apologies...
>
> there was a fatal flaw... so this is the update..


David, many thanks

I'm copy'n'pasting this into ssh, perhaps I screwed up something, I'm
getting:

[EMAIL PROTECTED] tank]# ./a.pl
syntax error at ./a.pl line 31, near "<>"
syntax error at ./a.pl line 54, near "}"
Execution of ./a.pl aborted due to compilation errors.


54 is the last line '}'
31 is 'until (index($linebuffer,"\r") <> -1) {'

-----------------------
#!/usr/bin/perl

use Device::SerialPort qw( :PARAM :STAT 0.07 );

my $MAXVAR = 20;        # Maximum data variation (%)

my $port=Device::SerialPort->new("/dev/ttyS0");
my $tmpfile = "/var/tmp/aqualogger";
my $linebuffer = "";

$port->baudrate(2400);
$port->databits(8);
$port->parity("none");
$port->read_char_time(0);     # don't wait for each character
$port->read_const_time(1000); # 1 second per unfulfilled "read" call
$port->are_match("d");


# Main loop

    while (1) {
    until (index($linebuffer,"\r") <> -1) {
    $linebuffer = $linebuffer + $port->lookfor;       #
    poll until data ready
    sleep 1;                          # polling sample time
    }

    print "Full line received\nNow processing...";

# Extract what we need for the next step
    $gotit = substr $linebuffer,1,index($linebuffer,"\r");

    # We must put any stray characters after the terminator back
    # into the linebuffer as they will form the start of the next
    # line.
    $linebuffer = substr $linebuffer, index($linebuffer,"\r");

    $gotit =~ /a(\d+)b\dc(\d+)d(\d+)e\df(\d+)g/;
    $level1 = $1 / 10;
    $temp1 = $2 / 10;
    $level2 = $3 / 10;
    $temp2 = $4 / 10;
    printf "Read: %s\n", $gotit;
    print "T1 Lvl: $level1, Temp: $temp1 T2 Lvl: $level2, Temp: $temp2\n";
}



-- 
Voytek

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to