]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
modified startup.pl to allow for programming multiple jtag chains connected to differ...
authorwww@jspc55 <www@jspc55>
Tue, 24 Jun 2014 15:47:36 +0000 (17:47 +0200)
committerwww@jspc55 <www@jspc55>
Tue, 24 Jun 2014 15:47:36 +0000 (17:47 +0200)
tools/startup.pl

index 30da2ad0d8b250eea1fbd7234f728336073f7122..91694c42d5022092e0055a5dff7f6625c816b917 100755 (executable)
@@ -59,7 +59,11 @@ mkdir($defaultIniPath) unless (-e $defaultIniPath);
 ## Read setup xml file
 ###############################  
 my @commands;
-my $boardsini;
+my $JtagCommands = {};
+my @CbCommands;
+
+my $boardsini = {};
+my $chainsini = {};
 my $setupFile = $ARGV[0];
 my $systemFile = $ARGV[1];
 my $parser = XML::LibXML->new(line_numbers => 1);
@@ -67,14 +71,19 @@ my $db = $parser->parse_file($setupFile);
 my $name = $db->getDocumentElement->getAttribute('name');
 print STDERR "Loading setup $name from file $setupFile\n" if $verbose;
 
-my @CbCommands;
 
 foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
   my $ctrlname = $curctrl->getAttribute('name');
   my $ctrlid   = $curctrl->getAttribute('id');
   my $ctrladdr = $curctrl->getAttribute('address');
   print STDERR "Found controller $ctrlname id $ctrlid\n" if $verbose;
-  $boardsini .= proto_boardsini($ctrlname,$ctrlid, $ctrladdr);
+  
+  unless( defined( $JtagCommands->{$ctrladdr} ) ){
+    $JtagCommands->{$ctrladdr} = [];
+  }
+  
+  $boardsini->{$ctrladdr}.= proto_boardsini($ctrlname,$ctrlid, $ctrladdr);
+  
 
   foreach my $curchain ($curctrl->findnodes('chain')) {
     my $chainid   = $curchain->getAttribute('id');
@@ -82,7 +91,7 @@ foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
     print STDERR "  Found chain $chainname id $chainid \n" if $verbose;
     my (@sname, @sfile, @senable);
     
-    push(@commands,"./ui_writeram.pl -c $chainname");
+    push(@{$JtagCommands->{$ctrladdr}},"./ui_writeram.pl -c $chainname");
     
     foreach my $cursensor ($curchain->findnodes('sensor')) {
       my $sensid = $cursensor->getAttribute('id');
@@ -111,7 +120,7 @@ foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
 
       foreach my $cfg ($cursensor->findnodes('config')) {
         print STDERR "      Found config\n" if $verbose;
-        push(@commands,"./ui.pl -b $ctrlname -o ".$cfg->textContent());
+        push(@{$JtagCommands->{$ctrladdr}},"./ui.pl -b $ctrlname -o ".$cfg->textContent());
         }
       }
       
@@ -132,35 +141,21 @@ foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
       
     foreach my $cfg ($curchain->findnodes('config')) {
       print STDERR "    Found config\n" if $verbose;
-      push(@commands,"./ui.pl -b $ctrlname -c $chainname -o ".$cfg->textContent());
+      push(@{$JtagCommands->{$ctrladdr}},"./ui.pl -b $ctrlname -c $chainname -o ".$cfg->textContent());
       }
     
-    $chainsini .= proto_chainsini($chainname,$chainid,$ctrladdr,\@sname,\@sfile,\@senable);
+    $chainsini->{$ctrladdr} .= proto_chainsini($chainname,$chainid,$ctrladdr,\@sname,\@sfile,\@senable);
     sensorini(\@sfile);
     }
   foreach my $cfg ($curctrl->findnodes('config')) {
     print STDERR "  Found config\n" if $verbose;
-    push(@commands,"./ui.pl -b $ctrlname -o ".$cfg->textContent());
+    push(@{$JtagCommands->{$ctrladdr}},"./ui.pl -b $ctrlname -o ".$cfg->textContent());
     }
-  }
+  } # end of curctl loop
 
 
-###############################
-## Write ini files
-###############################  
-my $boardsinifile = FileHandle->new($defaultIniPath."/boards.ini", 'w');
-print $boardsinifile $boardsini;
-$boardsinifile->close();
-  
-my $chainsinifile = FileHandle->new($defaultIniPath."/chains.ini", 'w');
-print $chainsinifile $chainsini;
-$chainsinifile->close();
   
   
-###############################
-## Do whatever has to be done
-###############################
-
 # configure Converter Boards
 local $CWD = XMLDBPATH;
 delete $ENV{'QUERY_STRING'}; # make sure put.pl is used in a command line and not in a web context
@@ -171,12 +166,31 @@ foreach my $cmd (@CbCommands){
   my $fieldname = $cmd->{name};
   execute("./put.pl $entity $addr $fieldname $value");
 }
+  
 
+foreach my $ctrladdr (keys %$JtagCommands) {
 
-local $CWD = $ENV{'JTAGPATH'};
-foreach my $cmd (@commands) {
-  execute($cmd);
-  }
+  ###############################
+  ## Write ini files
+  ###############################  
+  my $boardsinifile = FileHandle->new($defaultIniPath."/boards.ini", 'w');
+  print $boardsinifile $boardsini->{$ctrladdr};
+  $boardsinifile->close();
+    
+  my $chainsinifile = FileHandle->new($defaultIniPath."/chains.ini", 'w');
+  print $chainsinifile $chainsini->{$ctrladdr};
+  $chainsinifile->close();
+    
+    
+  ###############################
+  ## execute programming commands
+  ###############################
+
+  local $CWD = $ENV{'JTAGPATH'};
+  foreach my $cmd (@{$JtagCommands->{$ctrladdr}}) {
+    execute($cmd);
+    }
+}