Rev 2157 | Rev 2159 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2157 | Rev 2158 | ||
|---|---|---|---|
| Line 78... | Line 78... | ||
| 78 | print "Atom address: " . $hostname . ":" . $port . "\n"; |
78 | print "Atom address: " . $hostname . ":" . $port . "\n"; |
| 79 | print "Hexfile: " . $filename . "\n"; |
79 | print "Hexfile: " . $filename . "\n"; |
| 80 | print "Parameters: " . "\n"; |
80 | print "Parameters: " . "\n"; |
| 81 | 81 | ||
| 82 | if ($reset eq "true" && $filename eq "") |
82 | if ($reset eq "true" && $filename eq "") |
| - | 83 | { |
|
| - | 84 | if ($port == 1203) |
|
| - | 85 | { |
|
| - | 86 | $socket = atomd_initialize($hostname, $port); |
|
| - | 87 | atomjs_write($socket, "Node_ResetNative('".$hwid."');\n"); |
|
| - | 88 | print atomjs_read_line($socket); |
|
| - | 89 | for ($count = 0; $count < 15; $count++) |
|
| - | 90 | { |
|
| - | 91 | atomjs_write($socket, "Node_ResetPollNative();\n"); |
|
| - | 92 | if (atomjs_read_line($socket) =~ m/true/) |
|
| - | 93 | { |
|
| - | 94 | print "\033[32m" . $hwid . " started okay.\033[0m\n"; |
|
| - | 95 | last; |
|
| - | 96 | } |
|
| - | 97 | usleep(200000); |
|
| - | 98 | } |
|
| - | 99 | } |
|
| - | 100 | else |
|
| 83 | { |
101 | { |
| 84 | $socket = atomd_initialize($hostname, $port); |
102 | $socket = atomd_initialize($hostname, $port); |
| - | 103 | ||
| 85 | usleep(100000); |
104 | usleep(100000); |
| 86 | atomd_kill_promt($socket); |
105 | atomd_kill_promt($socket); |
| 87 | # atomjs_write("Node_Reset('".$hwid."')"); |
- | |
| 88 | atomd_send_command($socket, "Node_Reset $hwid"); |
106 | atomd_send_command($socket, "Node_Reset $hwid"); |
| 89 | print atomd_read_command_response($socket); |
107 | print atomd_read_command_response($socket); |
| 90 | exit(0); |
- | |
| 91 | #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\""); |
108 | #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\""); |
| 92 | #exit($result); |
109 | #exit($result); |
| - | 110 | } |
|
| 93 | } |
111 | } |
| - | 112 | else |
|
| - | 113 | { |
|
| - | 114 | if ($port == 1203) |
|
| - | 115 | { |
|
| - | 116 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
|
| - | 117 | @filecontents = <FP>; |
|
| - | 118 | close FP; |
|
| - | 119 | $socket = atomd_initialize($hostname, $port); |
|
| - | 120 | ||
| - | 121 | atomjs_write($socket, "Node_ProgramNative('".$hwid."', '".$bios."'"); |
|
| - | 122 | # print "Node_ProgramNative('".$hwid."', '".$bios."'"; |
|
| - | 123 | foreach $filerow (@filecontents) { |
|
| - | 124 | $filerow =~ s/^\s+//; |
|
| - | 125 | $filerow =~ s/\s+$//; |
|
| - | 126 | atomjs_write($socket, ", '" . $filerow . "'"); |
|
| - | 127 | print ", '".$filerow."'"; |
|
| - | 128 | } |
|
| - | 129 | atomjs_write($socket, ");\n"); |
|
| - | 130 | # print ");\n"; |
|
| - | 131 | } |
|
| 94 | else |
132 | else |
| 95 | { |
133 | { |
| 96 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
134 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
| 97 | @filecontents = <FP>; |
135 | @filecontents = <FP>; |
| 98 | close FP; |
136 | close FP; |
| 99 | - | ||
| 100 | $socket = atomd_initialize($hostname, $port); |
137 | $socket = atomd_initialize($hostname, $port); |
| 101 | usleep(100000); |
138 | usleep(100000); |
| 102 | atomd_kill_promt($socket); |
139 | atomd_kill_promt($socket); |
| 103 | 140 | ||
| 104 | #print "Sending Node_ClearHex\n"; |
141 | #print "Sending Node_ClearHex\n"; |
| Line 106... | Line 143... | ||
| 106 | atomd_kill_promt($socket); |
143 | atomd_kill_promt($socket); |
| 107 | 144 | ||
| 108 | my $linenums = 0; |
145 | my $linenums = 0; |
| 109 | foreach $filerow (@filecontents) { |
146 | foreach $filerow (@filecontents) { |
| 110 | #print "Sending Node_AppendHex $filerow \n"; |
147 | #print "Sending Node_AppendHex $filerow \n"; |
| - | 148 | #$filerow =~ s/^\s+//; |
|
| - | 149 | #$filerow =~ s/\s+$//; |
|
| 111 | atomd_send_command($socket, "Node_AppendHex $filerow"); |
150 | atomd_send_command($socket, "Node_AppendHex $filerow"); |
| 112 | atomd_kill_promt($socket); |
151 | atomd_kill_promt($socket); |
| 113 | $linenums += 1; |
152 | $linenums += 1; |
| 114 | } |
153 | } |
| 115 | #print "Sending Node_ProgramHex $hwid $bios $linenums \n"; |
154 | #print "Sending Node_ProgramHex $hwid $bios $linenums \n"; |
| 116 | atomd_send_command($socket, "Node_ProgramHex $hwid $bios $linenums"); |
155 | atomd_send_command($socket, "Node_ProgramHex $hwid $bios $linenums"); |
| 117 | # atomd_kill_promt($socket); |
- | |
| 118 | - | ||
| 119 | #atomd_send_command($socket, "Node_Program $hwid $bios $filename"); |
- | |
| 120 | 156 | ||
| 121 | print atomd_read_command_response($socket); |
157 | print atomd_read_command_response($socket); |
| 122 | exit(0); |
- | |
| 123 | 158 | ||
| 124 | # my $result = system("atomic -s $hostname -p $port -c \"Node_Program $hwid $bios $filename\""); |
159 | # my $result = system("atomic -s $hostname -p $port -c \"Node_Program $hwid $bios $filename\""); |
| 125 | # exit($result); |
160 | # exit($result); |
| 126 | } |
161 | } |
| 127 | 162 | ||