CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [mrhedin] Serial data linebreaks in string causing problems: Edit Log



mrhedin
Novice

Dec 17, 2009, 9:02 AM


Views: 1405
Re: [mrhedin] Serial data linebreaks in string causing problems

Your suggestion got me started and solved it. Thanks!


Code
system ("stty -F /dev/ttyS0 raw cs8 ispeed 9600"); 
open(SERIAL, "/dev/ttyS0");

while(1)
{
$i = 0;
until($i > 3)
{
$read[$i] = <SERIAL>;
$read[$i] =~ s/\n//g;
$i = $i + 1;
}


open(OUTFILE, ">>$bcppath/test/current.dat") or die "Hedin error: [$!]";
print OUTFILE "$read[0] $read[1] $read[2] $read[3]\n";
close(OUTFILE);
}


turned this serial data:


Code
[ 7.73941 ; 8.27391 ; 

241.502 ; 3.58776 ; 95.6792

; 1012 ; 13.4134 ;

23.7773 ]


into nice serial data:


Code
[ 8.27401 ; 8.27391 ; 238.768 ; 3.5084 ; 95.667 ; 1012 ; 13.4218 ; 23.5682 ]



(This post was edited by mrhedin on Dec 17, 2009, 9:03 AM)


Edit Log:
Post edited by mrhedin (Novice) on Dec 17, 2009, 9:03 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives