#!/usr/local/bin/perl ## ## report_sheet_voltages - Get the voltages from the eac sheet ## ## Usage: report_sheet_voltages ## Example read_eac_voltages eac1 g.txt ## ## Returned Data: ## grid_data_file = 5x7 grid of raw AD values ## ## bhimebau 9/9/04 - script creation use Socket; if (@ARGV != 2) { print "\nUSAGE: report_sheet_volatages \n"; print "EXAMPLE: report_sheet_voltages eac1 5x7_data\n\n"; exit; } $eac=shift; $grid_outfile=shift; open (GRID_OUT,">$grid_outfile") || die "Could not open grid data file -> $grid_outfile\n"; # Socket setup $iaddr = inet_aton("$eac") || die "no host: $eac"; $paddr = sockaddr_in("17000",$iaddr); $proto = getprotobyname("tcp"); socket(S,PF_INET,SOCK_STREAM,$proto) || die "socket: $!"; connect(S, $paddr) || die "connect: $!"; select(S); $|=1; select("stdout"); $count = 0; while ($count<56) { $ad_string=sprintf("A%02x000Z",$count); print S "$ad_string\n"; $result = ; $result =~ s/A.{2}//; $result =~ s/Z//; $number = hex($result); $ad_results[$count]=$number; $count++; } close (S); $col=1; $row=0; foreach(@ad_results) { $current_adval=$_; if ($row<7) { $converted_voltage = ($current_adval-470)*0.009765; $formatted_voltage = sprintf ("%4.3f ",$converted_voltage); print GRID_OUT "$formatted_voltage"; if ($col>4) { print GRID_OUT "\n"; $col=0; $row++; } $col++; } } close (GRID_OUT);