Rev 1877 | Rev 1890 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1877 | Rev 1885 | ||
|---|---|---|---|
| 1 | #!/usr/bin/perl |
1 | #!/usr/bin/perl |
| 2 | 2 | ||
| 3 | # Written by Mattias Runge 2008-2010 |
3 | # Written by Mattias Runge 2008-2010 |
| 4 | 4 | ||
| 5 | use Cwd 'abs_path'; |
5 | use Cwd 'abs_path'; |
| - | 6 | use File::Basename; |
|
| 6 | 7 | ||
| 7 | $| = 1; |
8 | $| = 1; |
| 8 | 9 | ||
| 9 | $numArgs = $#ARGV + 1; |
10 | $numArgs = $#ARGV + 1; |
| 10 | 11 | ||
| 11 | my $hostname = "localhost"; |
12 | my $hostname = "localhost"; |
| 12 | my $port = 1201; |
13 | my $port = 1201; |
| 13 | my $filename = ""; |
14 | my $filename = ""; |
| 14 | my $hwid = ""; |
15 | my $hwid = ""; |
| 15 | my $bios = 0; |
16 | my $bios = 0; |
| 16 | my $reset = "false"; |
17 | my $reset = "false"; |
| 17 | 18 | ||
| 18 | foreach $argnum (0 .. $#ARGV) |
19 | foreach $argnum (0 .. $#ARGV) |
| 19 | { |
20 | { |
| 20 | if ($ARGV[$argnum] eq "-h") |
21 | if ($ARGV[$argnum] eq "-h") |
| 21 | { |
22 | { |
| 22 | $hostname = $ARGV[$argnum+1]; |
23 | $hostname = $ARGV[$argnum+1]; |
| 23 | next; |
24 | next; |
| 24 | 25 | ||
| 25 | } |
26 | } |
| 26 | elsif ($ARGV[$argnum] eq "-p") |
27 | elsif ($ARGV[$argnum] eq "-p") |
| 27 | { |
28 | { |
| 28 | $port = $ARGV[$argnum+1]; |
29 | $port = $ARGV[$argnum+1]; |
| 29 | next; |
30 | next; |
| 30 | 31 | ||
| 31 | } |
32 | } |
| 32 | elsif ($ARGV[$argnum] eq "-i") |
33 | elsif ($ARGV[$argnum] eq "-i") |
| 33 | { |
34 | { |
| 34 | $hwid = $ARGV[$argnum+1]; |
35 | $hwid = $ARGV[$argnum+1]; |
| 35 | next; |
36 | next; |
| 36 | 37 | ||
| 37 | } |
38 | } |
| 38 | elsif ($ARGV[$argnum] eq "-f") |
39 | elsif ($ARGV[$argnum] eq "-f") |
| 39 | { |
40 | { |
| 40 | $filename = abs_path($ARGV[$argnum+1]); |
41 | $filename = abs_path($ARGV[$argnum+1]); |
| 41 | next; |
42 | next; |
| 42 | 43 | ||
| 43 | } |
44 | } |
| 44 | elsif ($ARGV[$argnum] eq "-b") |
45 | elsif ($ARGV[$argnum] eq "-b") |
| 45 | { |
46 | { |
| 46 | $bios = 1; |
47 | $bios = 1; |
| 47 | } |
48 | } |
| 48 | elsif ($ARGV[$argnum] eq "-r") |
49 | elsif ($ARGV[$argnum] eq "-r") |
| 49 | { |
50 | { |
| 50 | $reset = "true"; |
51 | $reset = "true"; |
| 51 | } |
52 | } |
| 52 | } |
53 | } |
| 53 | 54 | ||
| 54 | if ($hwid eq "") |
55 | if ($hwid eq "") |
| 55 | { |
56 | { |
| 56 | die "You must specify a hardware id!\n"; |
57 | die "You must specify a hardware id!\n"; |
| 57 | exit 1; |
58 | exit 1; |
| 58 | } |
59 | } |
| - | 60 | ||
| - | 61 | my $path = dirname(abs_path($0)); |
|
| - | 62 | ||
| - | 63 | # Read atom functions from separate file |
|
| - | 64 | if (-e $path."/setConfig/AtomLib.pl") { |
|
| - | 65 | require $path."/setConfig/AtomLib.pl"; |
|
| - | 66 | } else { |
|
| - | 67 | print "Error: No AtomLib.pl was found in ".$path.". \n\n"; |
|
| - | 68 | exit 1; |
|
| - | 69 | } |
|
| - | 70 | ||
| 59 | 71 | ||
| 60 | #0x14f90d1f to 0x1f0df914 |
72 | #0x14f90d1f to 0x1f0df914 |
| 61 | @hwidChars = split(//, $hwid); |
73 | @hwidChars = split(//, $hwid); |
| 62 | $hwid = $hwidChars[0]. $hwidChars[1]. uc($hwidChars[8]. $hwidChars[9]. $hwidChars[6]. $hwidChars[7]. $hwidChars[4]. $hwidChars[5]. $hwidChars[2]. $hwidChars[3]); |
74 | $hwid = $hwidChars[0]. $hwidChars[1]. uc($hwidChars[8]. $hwidChars[9]. $hwidChars[6]. $hwidChars[7]. $hwidChars[4]. $hwidChars[5]. $hwidChars[2]. $hwidChars[3]); |
| 63 | 75 | ||
| 64 | print "atomDude settings:\n"; |
76 | print "atomDude settings:\n"; |
| 65 | print "Hardware id: " . $hwid . "\n"; |
77 | print "Hardware id: " . $hwid . "\n"; |
| 66 | print "Atom address: " . $hostname . ":" . $port . "\n"; |
78 | print "Atom address: " . $hostname . ":" . $port . "\n"; |
| 67 | print "Hexfile: " . $filename . "\n"; |
79 | print "Hexfile: " . $filename . "\n"; |
| 68 | print "Parameters: " . "\n"; |
80 | print "Parameters: " . "\n"; |
| 69 | 81 | ||
| 70 | if ($reset eq "true" && $filename eq "") |
82 | if ($reset eq "true" && $filename eq "") |
| 71 | { |
83 | { |
| - | 84 | $socket = atomd_initialize($hostname, $port); |
|
| - | 85 | atomd_send_command($socket, "Node_Reset $hwid"); |
|
| - | 86 | print atomd_read_command_response($socket); |
|
| - | 87 | exit(1); |
|
| 72 |
|
88 | #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\""); |
| 73 |
|
89 | #exit($result); |
| 74 | } |
90 | } |
| 75 | else |
91 | else |
| 76 | { |
92 | { |
| - | 93 | $socket = atomd_initialize($hostname, $port); |
|
| - | 94 | atomd_send_command($socket, "Node_Program $hwid $bios $filename"); |
|
| - | 95 | print atomd_read_command_response($socket); |
|
| - | 96 | exit(1); |
|
| 77 |
|
97 | #my $result = system("atomic -s $hostname -p $port -c \"Node_Program $hwid $bios $filename\""); |
| 78 |
|
98 | # exit($result); |
| 79 | } |
99 | } |
| 80 | 100 | ||
| 81 | exit(0); |
101 | exit(0); |
| 82 | 102 | ||