chiark / gitweb /
Send HELLO as a result of all slaves being online. Do not crash if slave is slow...
[trains.git] / cebpic / make-idlocs
1 #!/usr/bin/perl
2
3 @ARGV==2 or die;
4 ($wiring,$_) = @ARGV;
5
6 m/^\d+$/ or die;
7 $_<32 or die;
8 $picno= $_;
9
10 # @a is the ID locations, one byte per array entry,
11 # with $a[0] being the first ID location (ie 0x200000).
12 # Values must be in hex (or otherwise suitable for the assembler).
13
14 $a[0]= $picno;
15 $a[1]= 0;
16
17 $a[1] |= 0x80 if !$picno;
18
19 open W, "< $wiring" or die "$wiring: $!";
20 while (<W>) {
21     next if m/^\s*\#/;
22     next unless m/^boards\s+$/...(!m/\S/ || m/^\S/);
23     next if !m/\S/ || m/^\S/;
24     die unless m/^\s+(\d+)\s+(\w+)\s*$/;
25     next unless $1 == $picno;
26     $board= $2;
27 }
28 close W;
29 die $picno unless defined $board;
30 die $board unless $board =~ m/^(?:reversers|detectors)$/;
31
32 $a[1] |= 0x40 if $board eq 'detectors';
33
34 @a= map { sprintf "0x%02x", $_; } @a;
35
36 printf "; automatically generated - do not edit\n" or die $!;
37 for ($i= 0x200000;
38      @a;
39      $i++) {
40     $_= shift @a;
41     printf "\t __idlocs \t 0x%06x, %s\n", $i, $_ or die $!;
42 }
43 print "\t end\n" or die $!;