/[mdap]/mdap-server.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /mdap-server.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 67 by dpavlin, Sun Nov 18 01:29:04 2007 UTC revision 72 by dpavlin, Sun Nov 18 11:07:23 2007 UTC
# Line 101  sub ant2hash { Line 101  sub ant2hash {
101          return $hash;          return $hash;
102  }  }
103    
104    sub _dump_data {
105            my $data = shift;
106            $data =~ s/\s+/ /gs;
107            return substr($data,0,150);
108    }
109    
110  sub mdap_send {  sub mdap_send {
111          my $data = shift;          my $data = shift;
112    
# Line 112  sub mdap_send { Line 118  sub mdap_send {
118          if ($debug) {          if ($debug) {
119                  warn ">> ${GROUP}:${PORT} >> ", dump( $data ), $/;                  warn ">> ${GROUP}:${PORT} >> ", dump( $data ), $/;
120          } elsif( ! $quiet ) {          } elsif( ! $quiet ) {
121                  $data =~ s/\s+/ /gi;                  warn ">> ",_dump_data($data),$/;
                 warn ">> ", substr($data,0,70), $/;  
122          }          }
123  }  }
124    
# Line 194  while (1) { Line 199  while (1) {
199                  my $client_version = $h->{'MDAP-VERSION'};                  my $client_version = $h->{'MDAP-VERSION'};
200                  $mdap_ver = $client_version if ($client_version);                  $mdap_ver = $client_version if ($client_version);
201    
                 print "<< $type $proto/$mdap_ver << ", length($data), " bytes\n" unless $quiet;  
   
                 warn dump( $data, $h ),$/ if ($debug);  
   
202                  # we are getting our own messages (since our source port                  # we are getting our own messages (since our source port
203                  # is same as destination)                  # is same as destination)
204                  next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# );                  next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# );
205    
206                    print "<< $type $proto/$mdap_ver << ", length($data), " bytes: ",_dump_data($data),$/ unless $quiet;
207    
208                    warn dump( $data, $h ),$/ if ($debug);
209    
210                  my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h );                  my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h );
211                  my $seq_nr = $1 if (defined $h->{'SEQ-NR'} && $h->{'SEQ-NR'} =~ m/^-*(\d)+/);                  my $seq_nr = $1 if (defined $h->{'SEQ-NR'} && $h->{'SEQ-NR'} =~ m/^(-*\d)+/);
212                  #warn "SEQ-NR: $seq_nr ok: ",$ant_ok_password->{$ant},"\n" if ($seq_nr);                  #warn "SEQ-NR: $seq_nr ok: ",$ant_ok_password->{$ant},"\n" if ($seq_nr);
213    
214                  my ($user_id,$user_pwd) = ant_credentials( $ant );                  my ($user_id,$user_pwd) = ant_credentials( $ant );
# Line 231  while (1) { Line 236  while (1) {
236                                  my $build = $h->{'_BUILD'} || die "no _BUILD?";                                  my $build = $h->{'_BUILD'} || die "no _BUILD?";
237                                  my $new_build = fw_build( $board );                                  my $new_build = fw_build( $board );
238                                  if ( $build ne $new_build ) {                                  if ( $build ne $new_build ) {
239                                          print "+ $ant version $build -> $new_build\n";                                          print "+ $ant $board version $build -> $new_build\n";
240                                          mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:software upgrade\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");                                          mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:software upgrade\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");
241                                          $ant_flashing->{$ant}++;                                          $ant_flashing->{$ant}++;
242                                          next;                                          next;
243                                  } else {                                  } else {
244                                          once "$ant OK version $build",                                          once "$ant $board OK version $build",
245                                                  $ant_unknown_password->{$ant} ? ' with unknown password' :                                                  $ant_unknown_password->{$ant} ? ' with unknown password' :
246                                                  $ant_passwd->{$ant} ? ' password protected' :                                                  $ant_passwd->{$ant} ? ' password protected' :
247                                                  '';                                                  '';
# Line 251  while (1) { Line 256  while (1) {
256                                                  $count++;                                                  $count++;
257                                          } keys %$ant_flashing;                                          } keys %$ant_flashing;
258                                          if ($waiting == 0) {                                          if ($waiting == 0) {
259                                                  status "ALL $count ANTS FLASHED to $build\n";                                                  status "ALL $count ANTS FLASHED\n";
260                                                  $ant_flashing = undef;                                                  $ant_flashing = undef;
261                                          } else {                                          } else {
262                                                  status "$waiting of $count ants still flasing upto $build\n";                                                  status "$waiting of $count ants still flasing\n";
263                                          }                                          }
264                                  }                                  }
265    
# Line 263  while (1) { Line 268  while (1) {
268                                                  warn "## calling $plugin\n" if $debug;                                                  warn "## calling $plugin\n" if $debug;
269                                                  if ( my $command = $plugin->check( $h ) ) {                                                  if ( my $command = $plugin->check( $h ) ) {
270    
271                                                          warn ">> $plugin $ant ",                                                          warn ">> $plugin $ant $board ",
272                                                                  $h->{'ANT-NAME'}, " ",                                                                  $h->{'ANT-NAME'}, " ",
273                                                                  $h->{'_BUILD'}, " ",                                                                  $h->{'_BUILD'}, " ",
274                                                                  "\t:$command\n";                                                                  "\t:$command\n";
# Line 279  while (1) { Line 284  while (1) {
284                          }                          }
285    
286                  } elsif ( $type eq 'REPLY-EXEC-CLI' ) {                  } elsif ( $type eq 'REPLY-EXEC-CLI' ) {
287                          print "##<< $type\n$data\n" if $debug;                          print "##<< $type $seq_nr\n$data\n" if $debug;
288                          if ( $seq_nr == 1 ) {                          if ( $seq_nr == 1 ) {
289                                  mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nSEQ-NR:2\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");                                  mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nSEQ-NR:2\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");
290                                  forget_ant( $ant ) if ( $ant_flashing->{$ant} );                                  forget_ant( $ant ) if ( $ant_flashing->{$ant} );

Legend:
Removed from v.67  
changed lines
  Added in v.72

  ViewVC Help
Powered by ViewVC 1.1.26