
mrhedin
Novice
Dec 17, 2009, 9:02 AM
Views: 1166
|
|
Re: [mrhedin] Serial data linebreaks in string causing problems
|
|
|
Your suggestion got me started and solved it. Thanks!
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:
[ 7.73941 ; 8.27391 ; 241.502 ; 3.58776 ; 95.6792 ; 1012 ; 13.4134 ; 23.7773 ] into nice serial data:
[ 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)
|