diff --git a/conf/airframes/twinjet1.xml b/conf/airframes/twinjet1.xml index 0c4d1f4d78..ae9585a74a 100644 --- a/conf/airframes/twinjet1.xml +++ b/conf/airframes/twinjet1.xml @@ -84,6 +84,8 @@ ap.CFLAGS += -DACTUATORS=\"servos_direct_hw.h\" ap.EXTRA_SRCS += $(SRC_ARCH)/servos_direct_hw.c ap.CFLAGS += -DCONTROL -DAUTOPILOT ap.EXTRA_SRCS += $(ACINCLUDE)/ap/control.c autopilot_fbw.c +ap.CFLAGS += -DADC +ap.EXTRA_SRCS += $(SRC_ARCH)/adc_hw.c ap.CFLAGS += -DTRACES -DWAVECARD_ON_GPS ap.EXTRA_SRCS += $(SRC_ARCH)/traces.c $(SRC_ARCH)/uart_ap.c #ap.CFLAGS += -DDATALINK diff --git a/conf/boa.conf b/conf/boa.conf index fae310ef77..df0193b29e 100644 --- a/conf/boa.conf +++ b/conf/boa.conf @@ -217,7 +217,7 @@ CGIPath /bin:/usr/bin:/usr/local/bin # Example: AddType type extension [extension ...] # Uncomment the next line if you want .cgi files to execute from anywhere -#AddType application/x-httpd-cgi cgi +AddType application/x-httpd-cgi cgi # Redirect, Alias, and ScriptAlias all have the same semantics -- they # match the beginning of a request and take appropriate action. Use diff --git a/sw/airborne/main_ap_2.c b/sw/airborne/main_ap_2.c index 694ada2b75..f2ee0b1979 100644 --- a/sw/airborne/main_ap_2.c +++ b/sw/airborne/main_ap_2.c @@ -23,6 +23,9 @@ void init_ap( void ) { gps_init(); gps_configure(); #endif +#ifdef ADC + +#endif ADC /* if AP is running in a separate MCU */ #ifndef FBW int_enable(); diff --git a/sw/lib/perl/Paparazzi/Environment.pm b/sw/lib/perl/Paparazzi/Environment.pm index 067af4dff0..d7fe149444 100644 --- a/sw/lib/perl/Paparazzi/Environment.pm +++ b/sw/lib/perl/Paparazzi/Environment.pm @@ -14,14 +14,14 @@ if (defined $ENV{PAPARAZZI_SRC}) { $paparazzi_home = $ENV{PAPARAZZI_SRC}; } $paparazzi_home = $ENV{PAPARAZZI_HOME} if (defined $ENV{PAPARAZZI_HOME}); -print "\nEnvironment : "; -if (defined $paparazzi_src) { - print "source directory mode\n paparazzi_src $paparazzi_src\n"; -} -else { - print "system mode\n inst_prefix INST_PREFIX"; -} -print " paparazzi_home $paparazzi_home\n\n"; +#print "\nEnvironment : "; +#if (defined $paparazzi_src) { +# print "source directory mode\n paparazzi_src $paparazzi_src\n"; +#} +#else { +# print "system mode\n inst_prefix INST_PREFIX"; +#} +#print " paparazzi_home $paparazzi_home\n\n"; sub parse_command_line { my ($options) = @_; @@ -66,7 +66,7 @@ sub read_config { my $aircrafts = $conf->getElementsByTagName("aircraft");; foreach my $aircraft (@{$aircrafts}){ my $name = $aircraft->getAttribute('name'); - print ("name $name\n"); +# print ("name $name\n"); } } @@ -95,7 +95,7 @@ sub get_default_map { my $map_conf = $doc->getElementsByTagName("map")->[0]; my $calib_file = $map_conf->getAttribute('location'); $calib_file = get_data($calib_file); - print "in Paparazzi::Environment::get_default_map $calib_file\n"; +# print "in Paparazzi::Environment::get_default_map $calib_file\n"; return $calib_file; } diff --git a/sw/lib/perl/Paparazzi/Log.pm b/sw/lib/perl/Paparazzi/Log.pm new file mode 100644 index 0000000000..1806dea36d --- /dev/null +++ b/sw/lib/perl/Paparazzi/Log.pm @@ -0,0 +1,69 @@ +package Paparazzi::Log; + +use strict; + +use XML::Parser; +use XML::DOM; + +my $PAPARAZZI_HOME = "/home/poine/work/paparazzi_savannah/paparazzi3"; + +sub get_available { + my $log_dir = $PAPARAZZI_HOME."/var/logs"; + opendir(DIR, $log_dir) || print "can't opendir $log_dir: $!\n"; + my @logs = grep { /^.*\.log/ && -f "$log_dir/$_" } readdir(DIR); + closedir DIR; + return @logs; +} + +sub read_infos { + my ($filename) = @_; + $filename = $PAPARAZZI_HOME."/var/logs"."/".$filename; + my $parser = XML::DOM::Parser->new(); + my $doc = $parser->parsefile($filename); + + my $configuration = $doc->getElementsByTagName('configuration')->[0]; + my $timeofday = $configuration->getAttribute('time_of_day'); + my $data_file = $configuration->getAttribute('data_file'); + + my $conf = $doc->getElementsByTagName('conf'); + my $aircrafts = parse_configuration($conf->[0]); + my $protocol = $doc->getElementsByTagName('protocol'); + return { date => $timeofday, data_file => $data_file , aircrafts => $aircrafts }; +} + +sub read_data { + my ($filename) = @_; + $filename = $PAPARAZZI_HOME."/var/logs"."/".$filename; + my @data = (); + open(INFILE, $filename) or print STDOUT "Cant open $filename: $!"; + while (my $line = ) { + if ($line =~ /(^\d+\.\d+) (\d+) (\w+) (.+)/) { + push @data, {time => $1, sender => $2, msg_id => $3, args => $4}; + } + } + close INFILE; + my $duration = @data[$#data]->{time}; + return {nb_messages => $#data, duration => $duration, raw_data => \@data}; +} + + +sub parse_configuration { + my ($conf) = @_; + my @ret = (); + my @aircrafts = $conf->getElementsByTagName('aircraft'); + foreach my $aircraft (@aircrafts) { + push @ret, parse_aircraft($aircraft); + } + return \@ret; + +} + +sub parse_aircraft { + my ($aircraft) = @_; + my $ac_name = $aircraft->getAttribute('name'); +# print "aircraft : $ac_name
\n"; + return $ac_name; +} + + +1; diff --git a/sw/logalizer/plot.cgi b/sw/logalizer/plot.cgi new file mode 100755 index 0000000000..7837648966 --- /dev/null +++ b/sw/logalizer/plot.cgi @@ -0,0 +1,189 @@ +#!/usr/bin/perl +use CGI::Form; +use Expect; + +my $paparazzi_lib; +BEGIN { +# $paparazzi_lib = (defined $ENV{PAPARAZZI_SRC}) ? +# $ENV{PAPARAZZI_SRC}."/sw/lib/perl" : "/usr/lib/paparazzi/"; + $paparazzi_lib = "/home/poine/work/paparazzi_savannah/paparazzi3/sw/lib/perl"; +} +use lib ($paparazzi_lib); + +use strict; +use warnings; +#use diagnostics; +#use Paparazzi::Environment; +use Paparazzi::Log; + +my $PAPARAZZI_HOME = "/home/poine/work/paparazzi_savannah/paparazzi3"; + +my $query = new CGI::Form; +print $query->header; +print $query->start_html("Paparazzi plotter"); +process_query($query); +print_prompt($query); +print_log_info(); +print_tail(); +print $query->end_html; + + +my @logs = (); +my @aircrafts = (); +my @messages = (); +my @fields = (); +my $log_info = undef; +my $log_data = undef; + + + +sub print_prompt { + my($query) = @_; + print "

Paparazzi plotter

\n"; + print $query->startform; + print "\n"; + print " \n"; + print " "; + print " "; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print "
FileAircraftMessageField
\n"; + print $query->popup_menu('file', \@logs, $logs[0]); + print " \n"; + print $query->popup_menu('aircraft', \@aircrafts, $aircrafts[0]); + print " \n"; + print $query->popup_menu('message', \@messages, $messages[0]); + print " \n"; + print $query->popup_menu('field', \@messages, $messages[0]); + print " \n"; + print $query->submit('Action','Update'); + print "
\n"; + print $query->endform; + print "
\n"; +} + +use POSIX qw(strftime); + +sub print_log_info { + if (defined $log_info) { + my $now_string = POSIX::strftime "%a %b %e %H:%M:%S %Y", localtime($log_info->{date}); + print "date :".$now_string."\n
"; + my $url = gen_activity_plot($log_info->{data_file}); + my $nb_messages = $log_data->{nb_messages}; + print "nb message :".$nb_messages."\n
"; + my $duration = $log_data->{duration}; + print "duration :".$duration."s\n
"; + print"\n"; +# print "data_file ".$log_info->{data_file}."\n
"; + } + + +} + +sub gen_activity_plot { + my ($data_file) = @_; + $log_data = Paparazzi::Log::read_data($data_file); + my $raw_data = $log_data->{raw_data}; + my @res = (); + my $data_filename = "/tmp/foo.dat"; + open(OUTFILE, ">".$data_filename) or die "Can t open $data_filename: $!"; + my ($idx, $time, $step) = (0, 0, 2); + my $active_aircrafts; + while ( $time < $log_data->{duration}) { + ($idx, $active_aircrafts) = get_active_aircrafts($raw_data, $idx, $step); + print OUTFILE "$time \t"; + foreach my $a_ac (@{$active_aircrafts}) { + print OUTFILE $a_ac." "; + } + print OUTFILE "\n"; + $time+=$step; + } + close OUTFILE; + + my $plot_cmd = "plot \"$data_filename\" using 1:11 w p t \"alalalala\""; +# for (my $i=2; $i < $#{@$active_aircrafts}+1; $i++) { + for (my $i=2; $i < 3; $i++) { + $plot_cmd = $plot_cmd."; replot \"$data_filename\" using 1:$i w p t \"ouou\""; + } + print "$plot_cmd\n
"; + my $url = gen_plot("png size 640,480", "bar.png", $plot_cmd); + return $url; +} + +sub get_active_aircrafts { + my ($raw_data, $idx, $step) = @_; + my @a_ac = (); + my $aircrafts = $log_info->{aircrafts}; + for (my $i=0; $i <= $#{@$aircrafts}; $i++) { + $a_ac[$i] = 0; + } + my $start_time = $raw_data->[$idx]->{time}; + my $curtime; + do { + $curtime = $raw_data->[$idx]->{time}; + $a_ac[$raw_data->[$idx]->{sender}] = $raw_data->[$idx]->{sender}; + $idx++; + } while ( $curtime < $start_time + $step and $idx < $#{@$raw_data}); + return ($idx, \@a_ac); +} + + +sub gen_plot { + my ($terminal, $filename, $plot_cmd ) = @_; + + my $set_terminal_cmd = "set terminal $terminal"; + my $set_output_cmd = "set output \"$PAPARAZZI_HOME/var/plot/$filename\""; + my $print_cmd = "$set_terminal_cmd; $set_output_cmd; $plot_cmd"; + my $exp = new Expect(); + $exp->raw_pty(1); + $Expect::Debug = 10; + my $pid = $exp->spawn("/usr/bin/gnuplot", ("-geometry", "1x1+0+0")) or printf "Don't find gnuplot"; + $pid->log_stdout(0); + print("Printing $print_cmd
\n"); + $exp->send($print_cmd."\n"); + my $timeout = 5; + my $foo = $exp->expect($timeout); + print "foo $foo
\n"; + $exp->hard_close(); + + return "http://ornette:8889/var/plot/".$filename; +} + + + +sub process_query { +# print "in process_query
\n"; + my($query) = @_; + @logs = Paparazzi::Log::get_available(); + my @files = $query->param('file'); + if ($#files >=0 ) { + my $file = $files[0]; + $log_info = Paparazzi::Log::read_infos($file); + + @aircrafts = @{$log_info->{aircrafts}}; + } +# my(@values,$key); +# foreach $key ($query->param) { +# print "$key -> "; +# @values = $query->param($key); +# print join(", ",@values),"
\n"; +# } +# print "leaving process_query\n"; +} + + + + + +sub print_tail { + print "
\n"; + print "
Poine.

\n"; +}