Add perl scripts to create graphs from logfiles Ignore logfiles.
[soft/lpc82x/exanh] / test / translate.pl
1 #!/usr/bin/perl -w
3 use strict;
4 use warnings;
6 # Author : Nathael Pajani
7 # Copyright 2016 Nathael Pajani <nathael.pajani@techno-innov.fr>
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 my $file = $ARGV[0];
24 if (! -e $file) {
25         print "Need file name as first argument\n";
26         exit 1;
27 }
29 my $count = 0;
30 my $skip = 4000;
32 open(LOGFILE, "<", $file);
33 open(TEMP, ">", "data_temp.log") or die $!;
34 open(CAP, ">", "data_cap.log") or die $!;
35 open(RES, ">", "data_res.log") or die $!;
38 foreach my $line (<LOGFILE>) {
39         if ($skip > 0) {
40                 $skip--;
41                 next;
42         }
43         chomp($line); # remove the newline from $line.
44         my $w = "(.+?)";
45         if ($line =~ m/Temp read: $w - raw/) {
46                 my $temp = $1;
47                 $temp =~ s/,/./;
48                 print TEMP "$count  $temp\n";
49                 # Increment counter
50                 $count++;
51         } elsif ($line =~ m/ADC9: $w, ADC10: (.+)/) {
52                 print CAP "$count  $1\n";
53                 print RES "$count  $2\n";
54         }
55 }
58 print "Got $count values\n";
60 close(TEMP);
61 close(CAP);
62 close(RES);