Rev 1039 | Rev 1043 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1039 | Rev 1040 | ||
|---|---|---|---|
| Line 11... | Line 11... | ||
| 11 | my $hostname = "localhost"; |
11 | my $hostname = "localhost"; |
| 12 | my $port = 1202; |
12 | my $port = 1202; |
| 13 | my $filename = ""; |
13 | my $filename = ""; |
| 14 | my $hwid = ""; |
14 | my $hwid = ""; |
| 15 | my $bios = "false"; |
15 | my $bios = "false"; |
| - | 16 | my $reset = "false"; |
|
| 16 | 17 | ||
| 17 | foreach $argnum (0 .. $#ARGV) |
18 | foreach $argnum (0 .. $#ARGV) |
| 18 | { |
19 | { |
| 19 | if ($ARGV[$argnum] eq "-h") |
20 | if ($ARGV[$argnum] eq "-h") |
| 20 | { |
21 | { |
| 21 | $hostname = $ARGV[$argnum+1]; |
22 | $hostname = $ARGV[$argnum+1]; |
| - | 23 | next; |
|
| - | 24 | ||
| 22 | } |
25 | } |
| 23 | elsif ($ARGV[$argnum] eq "-p") |
26 | elsif ($ARGV[$argnum] eq "-p") |
| 24 | { |
27 | { |
| 25 | $port = $ARGV[$argnum+1]; |
28 | $port = $ARGV[$argnum+1]; |
| - | 29 | next; |
|
| - | 30 | ||
| 26 | } |
31 | } |
| 27 | elsif ($ARGV[$argnum] eq "-i") |
32 | elsif ($ARGV[$argnum] eq "-i") |
| 28 | { |
33 | { |
| 29 | $hwid = $ARGV[$argnum+1]; |
34 | $hwid = $ARGV[$argnum+1]; |
| - | 35 | next; |
|
| - | 36 | ||
| 30 | } |
37 | } |
| 31 | elsif ($ARGV[$argnum] eq "-f") |
38 | elsif ($ARGV[$argnum] eq "-f") |
| 32 | { |
39 | { |
| 33 | $filename = $ARGV[$argnum+1]; |
40 | $filename = $ARGV[$argnum+1]; |
| - | 41 | next; |
|
| - | 42 | ||
| 34 | } |
43 | } |
| 35 | elsif ($ARGV[$argnum] eq "-b") |
44 | elsif ($ARGV[$argnum] eq "-b") |
| 36 | { |
45 | { |
| 37 | $bios = "true"; |
46 | $bios = "true"; |
| 38 | } |
47 | } |
| 39 | } |
- | |
| 40 | - | ||
| 41 |
|
48 | elsif ($ARGV[$argnum] eq "-r") |
| 42 | { |
49 | { |
| 43 |
|
50 | $reset = "true"; |
| 44 |
|
51 | } |
| 45 | } |
52 | } |
| - | 53 | ||
| 46 |
|
54 | if ($hwid eq "") |
| 47 | { |
55 | { |
| 48 | die "You must specify a hardware id!\n"; |
56 | die "You must specify a hardware id!\n"; |
| 49 | exit 1; |
57 | exit 1; |
| 50 | } |
58 | } |
| 51 | 59 | ||
| 52 | #0x14f90d1f to 0x1f0df914 |
60 | #0x14f90d1f to 0x1f0df914 |
| 53 | @hwidChars = split(//, $hwid); |
61 | @hwidChars = split(//, $hwid); |
| 54 | $hwid = @hwidChars[0]. @hwidChars[1]. @hwidChars[8]. @hwidChars[9]. @hwidChars[6]. @hwidChars[7]. @hwidChars[4]. @hwidChars[5]. @hwidChars[2]. @hwidChars[3]; |
62 | $hwid = @hwidChars[0]. @hwidChars[1]. @hwidChars[8]. @hwidChars[9]. @hwidChars[6]. @hwidChars[7]. @hwidChars[4]. @hwidChars[5]. @hwidChars[2]. @hwidChars[3]; |
| 55 | 63 | ||
| - | 64 | print "atomDude settings:\n"; |
|
| - | 65 | print "Hardware id: " . $hwid . "\n"; |
|
| 56 |
|
66 | print "Atom address: " . $hostname . ":" . $port . "\n"; |
| 57 |
|
67 | print "Hexfile: " . $filename . "\n"; |
| 58 |
|
68 | print "Parameters: " . "\n"; |
| 59 | 69 | ||
| 60 | my $sock = new IO::Socket::INET( |
70 | my $sock = new IO::Socket::INET( |
| 61 | PeerAddr => $hostname, |
71 | PeerAddr => $hostname, |
| 62 | PeerPort => $port, |
72 | PeerPort => $port, |
| 63 | Proto => 'tcp' |
73 | Proto => 'tcp' |
| 64 | ); |
74 | ); |
| 65 | die "Could not create socket: $!\n" unless $sock; |
75 | die "Could not create socket: $!\n" unless $sock; |
| - | 76 | print "Connected to Atom\n"; |
|
| 66 | 77 | ||
| - | 78 | if ($filename ne "") |
|
| - | 79 | { |
|
| - | 80 | open(FILE, $filename) || die("Could not open file!"); |
|
| - | 81 | @fileData=<FILE>; |
|
| 67 |
|
82 | close(FILE); |
| - | 83 | print "Hexfile loaded\n"; |
|
| 68 | 84 | ||
| 69 | print $sock "programNode('", $hwid, "','"; |
85 | print $sock "programNode('", $hwid, "','"; |
| 70 | 86 | ||
| 71 | foreach $line (@fileData) |
87 | foreach $line (@fileData) |
| 72 | { |
88 | { |
| 73 | print $sock $line; |
89 | print $sock $line; |
| 74 | } |
90 | } |
| 75 | 91 | ||
| 76 | print $sock "', ", $bios, ");\n"; |
92 | print $sock "', ", $bios, ");\n"; |
| - | 93 | ||
| - | 94 | my $pLoop = 1; |
|
| 77 | 95 | ||
| 78 |
|
96 | while ($pLoop eq 1) |
| 79 | { |
97 | { |
| 80 | $sock->recv($text, 128); |
98 | $sock->recv($text, 128); |
| 81 | 99 | ||
| 82 | if (rindex($text, "STOP") ne -1) |
100 | if (rindex($text, "STOP") ne -1) |
| 83 | { |
101 | { |
| 84 |
|
102 | print $text; |
| 85 |
|
103 | $pLoop = 0; |
| 86 | } |
104 | } |
| 87 | elsif ($text ne '') |
105 | elsif ($text ne '') |
| 88 | { |
106 | { |
| 89 | print $text; |
107 | print $text; |
| 90 | } |
108 | } |
| 91 | else |
109 | else |
| 92 | { |
110 | { |
| 93 | print "Connection closed by other side!"; |
111 | print "Connection closed by other side!"; |
| - | 112 | close($sock); |
|
| 94 | exit |
113 | exit 1; |
| - | 114 | } |
|
| - | 115 | } |
|
| - | 116 | } |
|
| - | 117 | ||
| - | 118 | if ($reset eq "true") |
|
| - | 119 | { |
|
| - | 120 | print $sock "resetNode('", $hwid, "');\n"; |
|
| - | 121 | ||
| - | 122 | my $rLoop = 1; |
|
| - | 123 | ||
| - | 124 | while ($rLoop eq 1) |
|
| - | 125 | { |
|
| - | 126 | $sock->recv($text, 128); |
|
| - | 127 | print $text; |
|
| - | 128 | ||
| - | 129 | if (rindex($text, "Success") ne -1) |
|
| - | 130 | { |
|
| - | 131 | $rLoop = 0; |
|
| - | 132 | } |
|
| - | 133 | elsif (rindex($text, "Failed") ne -1) |
|
| - | 134 | { |
|
| - | 135 | close($sock); |
|
| - | 136 | exit 1; |
|
| - | 137 | } |
|
| - | 138 | elsif ($text eq '') |
|
| - | 139 | { |
|
| - | 140 | print "Connection closed by other side!"; |
|
| - | 141 | close($sock); |
|
| - | 142 | exit 1; |
|
| - | 143 | } |
|
| 95 | } |
144 | } |
| 96 | } |
145 | } |
| 97 | 146 | ||
| 98 | close($sock); |
147 | close($sock); |
| - | 148 | exit 0; |
|