[SLUG] perl comm port data reading/parsing

2008-06-25 Thread Voytek Eymont
On Wed, June 25, 2008 12:14 am, Gonzalo Servat wrote: > On Tue, Jun 24, 2008 at 10:56 AM, Voytek Eymont <[EMAIL PROTECTED]> wrote: > Works for me: > my $str = 'a1566b0c203d1477e0f205g'; > > if( $str =~ /a(\d+)b\dc(\d+)d(\d+)e\df(\d+)g/ ) { printf( "DEPTH: %.1f\n", > $1/10 ); > printf( "AIR TEMP:

Re: [SLUG] perl comm port data reading/parsing

2008-06-25 Thread david . lyon
Quoting Voytek Eymont <[EMAIL PROTECTED]>: on first read, I get only 'half' of output, followed my 'wrong offset', see below: Right, You must wait till the end of line character is received, and not when data is available. Set up a variable called 'linebuffer' or something... keep addin

Re: [SLUG] perl comm port data reading/parsing

2008-06-25 Thread Voytek Eymont
On Thu, June 26, 2008 11:18 am, [EMAIL PROTECTED] wrote: > Quoting Voytek Eymont <[EMAIL PROTECTED]>: > Right, > You must wait till the end of line character is received, and not when > data is available. > Set up a variable called 'linebuffer' or something... > keep adding characters in your lo

Re: [SLUG] perl comm port data reading/parsing

2008-06-25 Thread david . lyon
Quoting Voytek Eymont <[EMAIL PROTECTED]>: yes, I thought it was something like that, I recall some REXX script we had for SMSsing, it had stuff like that to process comm port; there must be some ready made perl code like that, any thoughts where to look for such ? (I'm just a water tank gauge

Re: [SLUG] perl comm port data reading/parsing

2008-06-25 Thread david . lyon
apologies... there was a fatal flaw... so this is the update.. 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-

Re: [SLUG] perl comm port data reading/parsing

2008-06-25 Thread Daniel Pittman
[EMAIL PROTECTED] writes: > there was a fatal flaw... so this is the update.. There still is: [...] > while (1) { > until (index($linebuffer,"\r") <> -1) { > $linebuffer = $linebuffer + $port->lookfor; Unless you mean to convert $linebuffer into a number, add another nu

Re: [SLUG] perl comm port data reading/parsing

2008-06-26 Thread Voytek Eymont
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, nea

Re: [SLUG] perl comm port data reading/parsing

2008-06-26 Thread david . lyon
Quoting Voytek Eymont <[EMAIL PROTECTED]>: you need to fix this line, so it does the read. $linebuffer =. $port->read; # poll until data ready I don't have any of the earlier emails but your first version must have been correct. --- #!/usr/bin/perl

Re: [SLUG] perl comm port data reading/parsing

2008-06-27 Thread Voytek Eymont
On Thu, June 26, 2008 11:48 pm, [EMAIL PROTECTED] wrote: > Quoting Voytek Eymont <[EMAIL PROTECTED]>: > > > you need to fix this line, so it does the read. $linebuffer =. > $port->read; # poll until data ready thanks > I don't have any of the earlier emails but your first version must