![]() ![]() |
![]() |
File: [Development] / JSOC / proj / datacapture / scripts / tlmview
(download)
Revision: 1.1, Tue Oct 16 21:48:16 2007 UTC (15 years, 11 months ago) by arta Branch: MAIN CVS Tags: Ver_LATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, Ver_8-0, Ver_7-1, Ver_7-0, Ver_6-4, Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, Ver_5-9, Ver_5-8, Ver_5-7, Ver_5-6, Ver_5-5, Ver_5-3, Ver_5-2, Ver_5-14, Ver_5-13, Ver_5-12, Ver_5-11, Ver_5-10, Ver_5-1, Ver_5-0, Ver_4-7, Ver_4-6, Ver_4-5, Ver_4-4, Ver_4-3, Ver_4-2, Ver_4-1, Ver_4-0, NewTree01_cp09_JSOC, NewTree01_cp08_JSOC, NewTree01_cp07_JSOC, NewTree01_cp06_JSOC, NewTree01_cp05_JSOC, HEAD Move JSOC/src/base to JSOC/base and JSOC/src/proj to JSOC/proj. 86 JSOC/src. |
eval 'exec /home/jsoc/bin/$JSOC_MACHINE/perl -S $0 "$@"' if 0; # #/home/jim/STAGING/src/perl_tk/tlmview/tlmview #Perl/Tk gui. # #setenv TLMVIEWIMAGEDIR to the directory that contains the gif arrow #pictures for navigation. Will still work ok w/o the arrows if not set. # #Usage: tlmview.pl tlm_file_name # use Tk; #use Tk::FileDialog; $CADULEN = 1788; #length of CADU frame less the RS symbols $SYNC = "1acffc1d"; #each VCDU must start with this sync code $| = 1; #flush output as we go $user = $ENV{'USER'}; $PID = getppid; $datapktfile = "/tmp/pktfile_"."$user"."_"."$PID.od"; if($#ARGV == 0) { $tfile = $ARGV[0]; open(TF, $tfile) || die "Can't open $tfile: $!\n"; &Read_Tfile; } else { $tfile = "<none>"; } $IMGDIR = $ENV{'TLMVIEWIMAGEDIR'}; if(!$IMGDIR) { $afile = "./arrow04.gif"; if(!-e $afile) { print "No env vrbl TLMVIEWIMAGEDIR found.\n"; print "Cannot display arrows for VCDU navigation. Will proceed without them.\n"; } else { $IMGDIR = "."; } } $mw = MainWindow->new; $mw->geometry("500x200+500+470"); $mw->title("tlmview"); #my($LoadDialog) = $mw->FileDialog(-Title =>'tlmview file', # -Create => 0); #$LoadDialog->configure(-FPat => '*.*', # -ShowAll => 'NO'); my(@pl) = qw/-side top anchor nw/; my(@pl1) = qw/-side left/; my(@pl2) = qw/-side top/; @toplevel2destroy = (); #list of windows to destroy when new file my $f = $mw->Frame(-borderwidth => 8)->pack(-fill => 'both'); $txt = "Telemetry File: "; # my $e = $f->Entry(qw/-relief sunken -width 50/); # $e->insert(0, $tfile); # $e->configure(-font => 'arial 12 bold'); my $l = $f->Label(-text => $txt, -anchor => 'e', -justify => 'right'); my $e = $f->Label(-text => $tfile, -relief => 'sunken', -anchor => 'w', -justify => 'right'); $row = 0; Tk::grid( $l, -row => $row, -column => 0, -sticky => 'e', -pady => 5); Tk::grid( $e, -row => $row, -column => 1,-sticky => 'ew', -pady => 5); $f->gridRowconfigure(1,-weight => 1); #$mw->Button(-text => "Select New File", # -command => \&Select_File, # ) # ->pack(-side=> 'top'); $b = $mw->Button( -text => 'Exit', -width => 4, -background => 'red', -command => sub {exit;}, ); $b->pack(-side=> 'top', -pady => 10, -padx => 12); $mw->Label(-text => "VCDU:", -anchor => 'e', -justify => 'right')->pack(-side=> 'left', -padx => 5); if($IMGDIR) { #dir with arrow photos my $yf = $mw->Frame(-borderwidth => 0)->pack(-fill => 'both', -side => 'top'); $yf->Label(-text => "Previous")->pack(@pl1); $yf->Label(-text => " Next ")->pack(@pl1); $yf->Label(-text => " First ")->pack(@pl1); $yf->Label(-text => " Last")->pack(@pl1); $xyf = $mw->Frame(-borderwidth => 0)->pack(-fill => 'both', -side => 'top'); $image = $xyf->Photo(-file => "$IMGDIR/arrow04.gif"); $xyf->Button(-command => \&Previous, -image => $image) ->pack(-side=> 'left', -padx => 10); $image = $xyf->Photo(-file => "$IMGDIR/arrow05.gif"); $xyf->Button(-command => \&Next, -image => $image) ->pack(-side=> 'left', -padx => 10); $image = $xyf->Photo(-file => "$IMGDIR/arrow06.gif"); $xyf->Button(-command => \&First, -image => $image) ->pack(-side=> 'left', -padx => 10); $image = $xyf->Photo(-file => "$IMGDIR/arrow03.gif"); $xyf->Button(-command => \&Last, -image => $image) ->pack(-side=> 'left', -padx => 10); $xyf->Button(-text => "Find a VCDU", -command => \&Find_Vcdu,) ->pack(-side=> 'left', -padx => 10); } else { $mw->Button(-text => "Previous", -command => \&Previous,) ->pack(-side=> 'left', -padx => 10); $mw->Button(-text => "Next", -command => \&Next,) ->pack(-side=> 'left', -padx => 10); $mw->Button(-text => "First", -command => \&First,) ->pack(-side=> 'left', -padx => 10); $mw->Button(-text => "Last", -command => \&Last,) ->pack(-side=> 'left', -padx => 10); $mw->Button(-text => "Find a VCDU", -command => \&Find_Vcdu,) ->pack(-side=> 'left', -padx => 10); } $mw->bind('all', '<Control-c>' => \&exit); #$mw->bind('all', '<Destroy>' => \&exit);#No, will exit incorrectly if($tfile ne "<none>") { &CADU_view; &VCDU_data; &M_PDU_pkt; &Pkt_data_front; &Appl_data; } MainLoop; ########################################################################### #sub Select_File { # $nfile = $LoadDialog->Show(); # if (!defined($nfile)) { # return; # } # $tfile = $nfile; # #print "\ntfile = $tfile\n"; #!!TEMP # if(Exists($msgwin)) { # $msgwin->destroy(); # } # #$e->delete(0, 'end'); # #$e->insert(0, $tfile); # $e = $f->Label(-text => $tfile, -relief => 'sunken', -anchor => 'w', # -justify => 'right'); # Tk::grid( $e, -row => $row, -column => 1,-sticky => 'ew', -pady => 5); # $f->gridRowconfigure(1,-weight => 1); # while($tlx = shift(@toplevel2destroy)) { #destroy old views # if(Exists($tlx)) { # $tlx->destroy(); # } # } # @toplevel2destroy = (); # close(TF); # open(TF, $tfile) || die "Can't open $tfile: $!\n"; # &Read_Tfile; # &CADU_view; # &VCDU_data; # &M_PDU_pkt; # &Pkt_data_front; # &Appl_data; #} sub CADU_view { $tl2 = $mw->Toplevel(); push(@toplevel2destroy, $tl2); $tl2->geometry("950x68+8+86"); $tl2->title("CADU 1788 Octets"); my $f1 = $tl2->Frame(-borderwidth => 0)->pack(-fill => 'both', -side => 'top'); $f1->Label(-text => "Sync", -font => 'arial 10', -relief => 'groove', -width => 12)->pack(@pl1); $f1->Label(-text => "CVCDU Primary Header", -font => 'arial 10', -relief => 'groove', -width => 61)->pack(@pl1); $f1->Label(-text => "VCDU Data", -font => 'arial 10', -relief => 'groove', -width => 68)->pack(@pl1); $f1->Label(-text => "VCDU Trailer", -font => 'arial 10', -relief => 'groove', -width => 10)->pack(@pl1); $c = $tl2->Button( -text => "SyncMark\n0x$sync_code\n(32)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl2->Button( -text => "Version\n$version\n(2)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl2->Button( -text => "S/C Id\n$scid\n(8)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl2->Button( -text => "VC Id\n$vcid\n(6)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl2->Button( -text => "VCDU Cntr\n$vcdu_cntr\n(24)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl2->Button( -text => "Replay Flg\n$replay\n(1)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl2->Button( -text => "Spare\n$spare\n(7)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl2->Button( -text => "Data\n\n1776 Octets", -font => 'arial 10', -background => 'grey', -width => 65, -command => \&VCDU_data, ); $c->pack(-side=> 'left'); $c = $tl2->Button( -text => "CRC\n$crc_value\n(16)", -font => 'arial 10', -background => 'grey', -width => 6, ); $c->pack(-side=> 'left'); # $c = $tl2->Button( # -text => 'Exit', # -width => 2, # -background => 'red', # -command => sub {exit;}, # ); # $c->pack(-side=> 'bottom', -pady => 10); } sub VCDU_data { $tl3 = $mw->Toplevel(); push(@toplevel2destroy, $tl3); $tl3->geometry("950x68+8+182"); $tl3->title("VCDU Data"); my $f1 = $tl3->Frame(-borderwidth => 0)->pack(-fill => 'both', -side => 'top'); $f1->Label(-text => "VCDU Insert Zone", -font => 'arial 10', -relief => 'groove', -width => 40)->pack(@pl1); $f1->Label(-text => "M_PDU Hdr", -font => 'arial 10', -relief => 'groove', -width => 22)->pack(@pl1); $f1->Label(-text => "M_PDU Pkt Zone", -font => 'arial 10', -relief => 'groove', -width => 84)->pack(@pl1); $c = $tl3->Button( -text => "IM_PDU Id\n$vcid_insert_zone\n(6)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl3->Button( -text => "IM_PDU Counter\n (10) = $high10x (32) = $low32x\n(42)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl3->Button( -text => "Spare\n$spareM\n(5)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl3->Button( -text => "First Hdr Ptr\n$first_hdr_ptr\n(11)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl3->Button( -text => "Source Pkt Data\n\n1768 Octets", -font => 'arial 10', -background => 'grey', -width => 81, -command => \&M_PDU_pkt, ); $c->pack(-side=> 'left'); $c = $tl3->Button( -text => "CRC\n\n(16)", -font => 'arial 10', -background => 'lightyellow', -width => 6, ); $c->pack(-side=> 'left'); } sub M_PDU_pkt { $tl4 = $mw->Toplevel(); push(@toplevel2destroy, $tl4); #$tl4->geometry("1120x68+8+278"); $tl4->geometry("1230x68+8+278"); $tl4->title("M_PDU Pkt Zone"); my $f1 = $tl4->Frame(-borderwidth => 0)->pack(-fill => 'both', -side => 'top'); $f1->Label(-text => "Pkt Identification", -font => 'arial 10', -relief => 'groove', -width => 41)->pack(@pl1); $f1->Label(-text => "Pkt Seq Control", -font => 'arial 10', -relief => 'groove', -width => 23)->pack(@pl1); $f1->Label(-text => "Pkt Len", -font => 'arial 10', -relief => 'groove', -width => 9)->pack(@pl1); $f1->Label(-text => "Secondary Hdr", -font => 'arial 10', -relief => 'groove', -width => 27)->pack(@pl1); $f1->Label(-text => "Packet Data", -font => 'arial 10', -relief => 'groove', -width => 64)->pack(@pl1); $c = $tl4->Button( -text => "Version\n$version_pkt\n(3)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "Type\n$type\n(1)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "Sec Hdr Flg\n$sec_hdr_flg\n(1)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "App ID\n$app_id\n(11)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "Seg Flg\n$seg_flg\n(2)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "Src Seq Cnt\n$src_seq_cnt\n(14)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "Pkt Len\n$pkt_len\n(16)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "Secs\n$secs\n(32)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "Sub Secs\n$sub_secs\n(32)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "Application Data\n\n1754 Octets", -font => 'arial 10', -background => 'grey', -width => 61, -command => \&Appl_data, ); $c->pack(-side=> 'left'); $c = $tl4->Button( -text => "CRC\n\n(16)", -font => 'arial 10', -background => 'lightyellow', -width => 6, ); $c->pack(-side=> 'left'); # $c = $tl4->Button( # -text => 'Exit', # -width => 2, # -background => 'red', # -command => sub {exit;}, # ); # $c->pack(-side=> 'bottom', -pady => 10); } sub Pkt_data_front { $tl5 = $mw->Toplevel(); push(@toplevel2destroy, $tl5); $tl5->geometry("1220x68+8+374"); $tl5->title("Packet Data First 9 Words (16bits)"); my $f1 = $tl5->Frame(-borderwidth => 0)->pack(-fill => 'both', -side => 'top'); $f1->Label(-text => "CCD Camera Hdr Words", -font => 'arial 10', -relief => 'groove', -width => 45)->pack(@pl1); $f1->Label(-text => "Crop ID", -font => 'arial 10', -relief => 'groove', -width => 9)->pack(@pl1); $f1->Label(-text => "Rdout Mode", -font => 'arial 10', -relief => 'groove', -width => 13)->pack(@pl1); $f1->Label(-text => "Hdr Err Flg", -font => 'arial 10', -relief => 'groove', -width => 12)->pack(@pl1); $f1->Label(-text => "Ovrflow Flg", -font => 'arial 10', -relief => 'groove', -width => 11)->pack(@pl1); #!!TBD fix below: $c = $tl5->Button( -text => "CamHdr1\n$ccd_hdr_1\n(16)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "CamHdr2\n$ccd_hdr_2\n(16)", -font => 'arial 10', -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "CamHdr3\n$ccd_hdr_3\n(16)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "CamHdr4\n$ccd_hdr_4\n(16)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "Crop ID\n$crop_id\n(12)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "Rdout Mode\n$rdout_mode\n(2)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "Hdr Err Flg\n$hdr_err_flg\n(1)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "OvrflowFlg\n$ovrflo_flg\n(1)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "TAP Code\n$tapcode\n(4)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "BitSelID\n$bitselect\n(4)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "CompressID\n$compressid\n(8)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "LookT ID\n$ltid\n(8)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "Offset Cnt\n(8)=$offcnt8 (16)=$offcnt16\n(24)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); $c = $tl5->Button( -text => "Init Value\n$initval\n(16)", -font => 'arial 10', -background => 'grey', ); $c->pack(-side=> 'left'); } sub Appl_data { $tl6 = $mw->Toplevel(); push(@toplevel2destroy, $tl6); $tl6->geometry("450x200+8+470"); $tl6->title("Packet Data"); my $f1 = $tl6->Frame(-borderwidth => 0)->pack(-fill => 'both', -side => 'top'); $f1->Label(-text => "od -Ad -tx1 of Application Data:",-font => 'arial 18')->pack(); $textf1 = $f1->Scrolled("Text")->pack(); ##@od_appl_data = `od -Ad -tx1 -j32 -N1756 $tfile`; @od_appl_data = `od -Ad -tx1 -N1756 $datapktfile`; $textf1->insert('end', " @od_appl_data"); } sub Read_Tfile { read(TF, $buf, 4); $sync_code = sprintf("%x", unpack("N", $buf)); if($sync_code ne $SYNC) { &Seek_Msg("VCDU does not start with a sync code.\nThis is a corrupted tlm file.\nYour navigation through this file may not work.\n"); } #print("Sync code = $sync_code\n"); read(TF, $buf, 2); #Version = 2bits, s/c id = 8bits, VC id = 6 bits $x = sprintf("%x", unpack("n", $buf)); $y = hex($x); #print "\$y = $y\n"; $version = $y >> 14; #printf("Version = %b\n", $version); $scid = ($y >> 6) & 0xff; #printf("S/C id = %d\n", $scid); $vcid = $y & 0x3f; #printf("VC id = %d\n", $vcid); #VCDU cntr = 24 bits, replay flg = 1, spare = 7 bits read(TF, $buf, 4); $x = sprintf("%x", unpack("N", $buf)); $y = hex($x); $vcdu_cntr = sprintf("0x%x", ($y >> 8)); #print("VCDU counter = $vcdu_cntr\n"); $replay = $y & 0xff; $replay = $replay >> 7; #printf("Replay flag = %d\n", $replay); $spare = $y & 0x7f; #printf("Spare = %x\n", $spare); #next 48bits vcid(6), vcdu cntr (42) read(TF, $buf, 2); $x = sprintf("%x", unpack("n", $buf)); $y = hex($x); $vcid_insert_zone = $y >> 10; #printf("VC id insert zone = %x\n", $vcid_insert_zone); $high10 = $y & 0x3ff; #high 10 bits of 42 bit cntr read(TF, $buf, 4); $x = sprintf("%x", unpack("N", $buf)); $low32 = hex($x); #get decimal value of the hex $high10x = sprintf("0x%03x", $high10); $low32x = sprintf("0x%08x", $low32); #printf("VCDU counter high 10bits = $high10x\n"); #printf("VCDU counter low 32bits = $low32x\n"); #M_PDU Hdr spare 5 bits, first hdr pointer 11 bits read(TF, $buf, 2); $x = sprintf("%x", unpack("n", $buf)); $y = hex($x); $spareM = $y >> 11; #printf("spare = %d\n", $spareM); $first_hdr_ptr = sprintf("0x%x", ($y & 0x7ff)); #printf("first hdr pointer = $first_hdr_ptr\n"); #Pkt Identification Version (3), Type (1), Sec Hdr Flg (1), App ID (11) read(TF, $buf, 2); $x = sprintf("%x", unpack("n", $buf)); $y = hex($x); $version_pkt = $y >> 13; #print("Version = $version_pkt\n"); $type = $y >> 12; $type = $type & 0x1; #print("Type = $type\n"); $sec_hdr_flg = $y >> 11; $sec_hdr_flg = $sec_hdr_flg & 0x1; #print("Sec Hdr Flg = $sec_hdr_flg\n"); $app_id = sprintf("0x%x", ($y & 0x7ff)); #print("App ID = $app_id\n"); #Pkt Seq Control: Seg Flg (2), Src Seq Cnt (14) read(TF, $buf, 2); $x = sprintf("%x", unpack("n", $buf)); $y = hex($x); $seg_flg = $y >> 14; #print("Seg Flg = $seg_flg\n"); $src_seq_cnt = sprintf("0x%x", ($y & 0x3fff)); #print("Src Seq Cnt = $src_seq_cnt\n"); #Pkt Len (16) read(TF, $buf, 2); $pkt_len = sprintf("0x%x", unpack("n", $buf)); #print("Pkt Len = $pkt_len\n"); #Secondary Hdr: Secs (32), Sub Secs (32) read(TF, $buf, 4); $secs = sprintf("0x%08x", unpack("N", $buf)); #print("Secs = $secs\n"); read(TF, $buf, 4); $sub_secs = sprintf("0x%08x", unpack("N", $buf)); #print("Sub Secs = $sub_secs\n"); ##!!NEW 15Apr04 below ## seek(TF, 1754, 1); #go to the CRC 16bits read(TF, $buf, 1754); open(XF, "> $datapktfile"); print XF $buf; close(XF); ## #CCD camera header words. 4 words 16bits ea. $sbuf = substr($buf, 0, 2); $ccd_hdr_1 = sprintf("0x%x", unpack("n", $sbuf)); $sbuf = substr($buf, 2, 2); $ccd_hdr_2 = sprintf("0x%x", unpack("n", $sbuf)); $sbuf = substr($buf, 4, 2); $ccd_hdr_3 = sprintf("0x%x", unpack("n", $sbuf)); $sbuf = substr($buf, 6, 2); $ccd_hdr_4 = sprintf("0x%x", unpack("n", $sbuf)); $sbuf = substr($buf, 8, 2); $x = sprintf("%x", unpack("n", $sbuf)); $y = hex($x); $crop_id = sprintf("0x%x", ($y >> 4)); $z = $y >> 2; $rdout_mode = sprintf("0x%x", ($z & 0x3)); $hdr_err_flg = $y >> 1; $hdr_err_flg = $hdr_err_flg & 0x1; $ovrflo_flg = $y & 0x1; $sbuf = substr($buf, 10, 2); $x = sprintf("%x", unpack("n", $sbuf)); $y = hex($x); $tapcode = sprintf("0x%x", ($y >> 12)); $z = $y >> 8; $bitselect = sprintf("0x%x", ($z & 0xf)); $compressid = sprintf("0x%x", ($y & 0xff)); $sbuf = substr($buf, 12, 2); $x = sprintf("%x", unpack("n", $sbuf)); $y = hex($x); $ltid = sprintf("0x%x", ($y >> 8)); $offcnt8 = sprintf("0x%x", ($y & 0xff)); $sbuf = substr($buf, 14, 2); $x = sprintf("%x", unpack("n", $sbuf)); $y = hex($x); $offcnt16 = sprintf("0x%x", $y); $sbuf = substr($buf, 16, 2); $x = sprintf("%x", unpack("n", $sbuf)); $y = hex($x); $initval = sprintf("0x%x", $y); read(TF, $buf, 2); $crc_value = sprintf("0x%04x", unpack("n", $buf)); #print("CRC = $crc_value\n"); seek(TF, -$CADULEN, 1); #backup to start of vcdu } sub Previous { if(Exists($msgwin)) { $msgwin->destroy(); } if(!tell(TF)) { print "Already of Beginning-of-File on $tfile\n"; &Seek_Msg("Already at Beginning-of-File"); return; } seek(TF, -($CADULEN), 1); #seek to start of previous vcdu &ReDisplay; } sub Next { if(Exists($msgwin)) { $msgwin->destroy(); } seek(TF, $CADULEN, 1); #seek to end of vcdu from current pos if(eof(TF)) { print "End-of-File on $tfile\n"; &Seek_Msg("End-of-File"); seek(TF, -($CADULEN), 1); #go back to where we were return; } &ReDisplay; } sub First { if(Exists($msgwin)) { $msgwin->destroy(); } seek(TF, 0, 0); #seek to start of file &ReDisplay; } sub Last { if(Exists($msgwin)) { $msgwin->destroy(); } seek(TF, -($CADULEN), 2); #go to last vcdu &ReDisplay; } sub Seek_Msg { my($a) = @_; if(Exists($msgwin)) { $msgwin->destroy(); } $msgwin = $mw->Toplevel(); $msgwin->geometry("300x90+600+600"); $msgwin->title("msg window"); $msgwin->Label(-text => $a, -font => 'arial 14')->pack(@pl2); $msgwinb = $msgwin->Button( -text => 'Close', -width => 2, -command => sub {$msgwin->destroy();}, ); $msgwinb->pack(-side=> 'bottom'); } sub ReDisplay { while($tlx = shift(@toplevel2destroy)) { #destroy old views if(Exists($tlx)) { $tlx->destroy(); } } @toplevel2destroy = (); &Read_Tfile; &CADU_view; &VCDU_data; &M_PDU_pkt; &Pkt_data_front; &Appl_data; } sub Find_Vcdu { if(Exists($findwin)) { $findwin->destroy(); } my $row = 0; $findwin = $mw->Toplevel(); $findwin->geometry("400x200+700+600"); $findwin->title("Find window"); $findwin->Label(-text => "NOTE: Searches from BOF until found", -font => 'arial 14')->pack(@pl2); my $fv = $findwin->Frame(-borderwidth => 8)->pack(-fill => 'both'); $txt = "Find 24bit VCDU Cntr in Primary\nHeader (6 hex digits):"; $e24 = $fv->Entry(qw/-relief sunken -width 11/); $e24->configure(-font => 'arial 14 bold'); my $l = $fv->Label(-text => $txt, -anchor => 'e', -justify => 'right'); $fvbut = $fv->Button( -text => 'Go', -width => 2, -command => \&V24Go, ); Tk::grid( $l, -row => $row, -column => 0, -sticky => 'e', -pady => 5); Tk::grid( $e24, -row => $row, -column => 1,-sticky => 'ew', -pady => 5); Tk::grid( $fvbut, -row => $row++, -column => 2,-sticky => 'ew', -pady => 5); #$fv->gridRowconfigure(1,-weight => 1); $txt = "Find 42bit VCDU Cntr in VCDU\nInsert Zone (11 hex digits):"; $e42 = $fv->Entry(qw/-relief sunken -width 11/); $e42->configure(-font => 'arial 14 bold'); $l = $fv->Label(-text => $txt, -anchor => 'e', -justify => 'right'); $fvbut = $fv->Button( -text => 'Go', -width => 2, -command => \&V42Go, ); Tk::grid( $l, -row => $row, -column => 0, -sticky => 'e', -pady => 5); Tk::grid( $e42, -row => $row, -column => 1,-sticky => 'ew', -pady => 5); Tk::grid( $fvbut, -row => $row++, -column => 2,-sticky => 'ew', -pady => 5); $txt = "Find Secs in Secondary\nHdr (8 hex digits):"; $esec = $fv->Entry(qw/-relief sunken -width 11/); $esec->configure(-font => 'arial 14 bold'); $l = $fv->Label(-text => $txt, -anchor => 'e', -justify => 'right'); $fvbut = $fv->Button( -text => 'Go', -width => 2, -command => \&VSecGo, ); Tk::grid( $l, -row => $row, -column => 0, -sticky => 'e', -pady => 5); Tk::grid( $esec, -row => $row, -column => 1,-sticky => 'ew', -pady => 5); Tk::grid( $fvbut, -row => $row++, -column => 2,-sticky => 'ew', -pady => 5); $findwinb = $findwin->Button( -text => 'Close', -width => 2, -command => sub {$findwin->destroy();}, ); $findwinb->pack(-side=> 'bottom'); } #Search the tlm file from BOF to find the 24bit VCDU counter in the #primary hdr. sub V24Go { my $val = $e24->get(); my $valx = hex($val); $val = sprintf("%06x", $valx); print "This is V24Go. \$val = $val\n"; open(FIND, $tfile) || die "Can't open $tfile: $!\n"; while(!eof(FIND)) { seek(FIND, 6, 1); #skip to VCDU cntr 24 #VCDU cntr = 24 bits, replay flg = 1, spare = 7 bits read(FIND, $buf, 4); $x = sprintf("%x", unpack("N", $buf)); $y = hex($x); $vcdu_cntr = sprintf("%06x", ($y >> 8)); print "Next vcdu_cntr = $vcdu_cntr\n"; if($vcdu_cntr eq $val) { print "Found vcdu_cntr = $vcdu_cntr\n"; seek(FIND, -10, 1); #go to start of current vcdu $FINDpos = tell(FIND); seek(TF, $FINDpos, 0); #position the TF which Read_Tfile uses if(Exists($msgwin)) { $msgwin->destroy(); } &ReDisplay; close(FIND); return; } seek(FIND, ($CADULEN-10), 1); #go to end of current vcdu } print "Value not found before eof(FIND)\n"; &Seek_Msg("Value not found before eof"); close(FIND); } #Search the tlm file from BOF to find the 42bit IM_PDU counter in the #VCDU Insert Zone. sub V42Go { my $val = $e42->get(); my $len = length($val); if($len > 8) { $high3 = substr($val, 0, $len-8); $low8 = substr($val, $len-8, 8); print "high3 = $high3\n"; #!!TEMP print "low8 = $low8\n"; } else { $high3 = 0; $low8 = $val; } my $high3x = hex($high3); my $low8x = hex($low8); my $val3 = sprintf("%03x", $high3x); my $val8 = sprintf("%08x", $low8x); print "This is V42Go. \$val8 = $val8 \$val3 = $val3\n"; open(FIND, $tfile) || die "Can't open $tfile: $!\n"; while(!eof(FIND)) { seek(FIND, 10, 1); #skip to VCDU cntr 42 #next 48bits vcid(6), vcdu cntr (42) read(FIND, $buf, 2); $x = sprintf("%x", unpack("n", $buf)); $y = hex($x); $high10 = $y & 0x3ff; #high 10 bits of 42 bit cntr read(FIND, $buf, 4); $x = sprintf("%x", unpack("N", $buf)); $low32 = hex($x); #get decimal value of the hex $high10x = sprintf("%03x", $high10); $low32x = sprintf("%08x", $low32); print "High 10bits = $high10x\n"; print "Low 32bits = $low32x\n"; if(($low32x eq $val8) && ($high10x eq $val3)) { print "Found vcdu_cntr = $high10x $low32x\n"; seek(FIND, -16, 1); #go to start of current vcdu $FINDpos = tell(FIND); seek(TF, $FINDpos, 0); #position the TF which Read_Tfile uses if(Exists($msgwin)) { $msgwin->destroy(); } &ReDisplay; close(FIND); return; } seek(FIND, ($CADULEN-16), 1); #go to end of current vcdu } print "Value not found before eof(FIND)\n"; &Seek_Msg("Value not found before eof"); close(FIND); } #Search the tlm file from BOF to find the Secs value in the Seconday Hdr. sub VSecGo { my $val = $esec->get(); my $valx = hex($val); $val = sprintf("%08x", $valx); print "This is VSecGo. \$val = $val\n"; open(FIND, $tfile) || die "Can't open $tfile: $!\n"; while(!eof(FIND)) { seek(FIND, 24, 1); #skip to Secs in secondary hdr read(FIND, $buf, 4); $x = sprintf("%x", unpack("N", $buf)); $y = hex($x); $secs = sprintf("%08x", $y); print "Next secs = $secs\n"; if($secs eq $val) { print "Found secs = $secs\n"; seek(FIND, -28, 1); #go to start of current vcdu $FINDpos = tell(FIND); seek(TF, $FINDpos, 0); #position the TF which Read_Tfile uses if(Exists($msgwin)) { $msgwin->destroy(); } &ReDisplay; close(FIND); return; } seek(FIND, ($CADULEN-28), 1); #go to end of current vcdu } print "Value not found before eof(FIND)\n"; &Seek_Msg("Value not found before eof"); close(FIND); }
Karen Tian |
Powered by ViewCVS 0.9.4 |