Rev 2164 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2164 | Rev 2187 | ||
|---|---|---|---|
| Line 79... | Line 79... | ||
| 79 | print "Hexfile: " . $filename . "\n"; |
79 | print "Hexfile: " . $filename . "\n"; |
| 80 | #print "Parameters: " . "\n"; |
80 | #print "Parameters: " . "\n"; |
| 81 | 81 | ||
| 82 | ############################## RESET ############################## |
82 | ############################## RESET ############################## |
| 83 | if ($reset eq "true" && $filename eq "") |
83 | if ($reset eq "true" && $filename eq "") |
| 84 | { |
- | |
| 85 | if ($port == 1203) |
- | |
| 86 | { |
84 | { |
| 87 | $socket = atomd_initialize($hostname, $port); |
85 | $socket = atomd_initialize($hostname, $port); |
| - | 86 | if ($port == 1203) |
|
| - | 87 | { |
|
| 88 | atomjs_write($socket, "Node_ResetNative('".$hwid."');\n"); |
88 | atomjs_write($socket, "Node_ResetNative('".$hwid."');\n"); |
| 89 | $response = atomjs_read_line($socket); |
89 | $response = atomjs_read_line($socket); |
| 90 | if ($response =~ m/Error/) |
90 | if ($response =~ m/Error/) |
| 91 | { |
91 | { |
| 92 | die $response; |
92 | die $response; |
| 93 | } |
93 | } |
| 94 | print $response; |
94 | print $response; |
| 95 | 95 | ||
| 96 | $success = 0; |
96 | $success = 0; |
| 97 | for ($count = 0; $count < 15; $count++) |
97 | for ($count = 0; $count < 15; $count++) |
| 98 | { |
98 | { |
| 99 | atomjs_write($socket, "Node_ResetPollNative();\n"); |
99 | atomjs_write($socket, "Node_ResetPollNative();\n"); |
| 100 | if (atomjs_read_line($socket) =~ m/true/) |
100 | if (atomjs_read_line($socket) =~ m/true/) |
| 101 | { |
101 | { |
| 102 | print "\033[32m" . $hwid . " started okay.\033[0m\n"; |
102 | print "\033[32m" . $hwid . " started okay.\033[0m\n"; |
| 103 | $success = 1; |
103 | $success = 1; |
| 104 | last; |
104 | last; |
| 105 | } |
105 | } |
| 106 | usleep(200000); |
106 | usleep(200000); |
| 107 | } |
107 | } |
| 108 | if ($success == 0) |
108 | if ($success == 0) |
| 109 | { |
109 | { |
| 110 | print "\033[31mTimed out waiting for reset.\033[0m\n"; |
110 | print "\033[31mTimed out waiting for reset.\033[0m\n"; |
| 111 | } |
111 | } |
| 112 | } |
112 | } |
| 113 | else |
113 | else |
| 114 | { |
114 | { |
| 115 | $socket = atomd_initialize($hostname, $port); |
- | |
| 116 | - | ||
| 117 | usleep(100000); |
115 | usleep(100000); |
| 118 | atomd_kill_promt($socket); |
116 | atomd_kill_promt($socket); |
| 119 | atomd_send_command($socket, "Node_Reset $hwid"); |
117 | atomd_send_command($socket, "Node_Reset $hwid"); |
| 120 | print atomd_read_command_response($socket); |
118 | print atomd_read_command_response($socket); |
| 121 | #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\""); |
119 | #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\""); |
| 122 | #exit($result); |
120 | #exit($result); |
| 123 | } |
121 | } |
| 124 | } |
122 | } |
| 125 | ############################## REPROGRAM ############################## |
123 | ############################## REPROGRAM ############################## |
| 126 | else |
124 | else |
| 127 | { |
125 | { |
| 128 | if ($port == 1203) |
- | |
| 129 | { |
- | |
| 130 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
126 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
| 131 | @filecontents = <FP>; |
127 | @filecontents = <FP>; |
| 132 | close FP; |
128 | close FP; |
| 133 | $socket = atomd_initialize($hostname, $port); |
129 | $socket = atomd_initialize($hostname, $port); |
| - | 130 | ||
| - | 131 | if ($port == 1203) |
|
| - | 132 | { |
|
| 134 | atomjs_write($socket, "Node_ClearHex();\n"); |
133 | atomjs_write($socket, "Node_ClearHex();\n"); |
| 135 | atomjs_read_line($socket); |
134 | atomjs_read_line($socket); |
| 136 | my $linenums = 0; |
135 | my $linenums = 0; |
| 137 | foreach $filerow (@filecontents) |
136 | foreach $filerow (@filecontents) |
| 138 | { |
137 | { |
| Line 148... | Line 147... | ||
| 148 | } |
147 | } |
| 149 | } |
148 | } |
| 150 | $command = "Node_ProgramNative('".$hwid."', '".$bios."', '".$linenums."');\n"; |
149 | $command = "Node_ProgramNative('".$hwid."', '".$bios."', '".$linenums."');\n"; |
| 151 | atomjs_write($socket, $command); |
150 | atomjs_write($socket, $command); |
| 152 | #print $command; |
151 | #print $command; |
| 153 | $response = atomjs_read_line($socket); |
152 | $response = atomjs_read_line($socket); |
| 154 | if ($response =~ m/Error/) |
153 | if ($response =~ m/Error/) |
| 155 | { |
154 | { |
| 156 | die $response; |
155 | die $response; |
| 157 | } |
156 | } |
| 158 | print $response; |
157 | print $response; |
| 159 | #atomd_disconnect($socket); |
158 | #atomd_disconnect($socket); |
| Line 191... | Line 190... | ||
| 191 | print "\n\033[31mTimed out waiting for program to finish.\033[0m\n"; |
190 | print "\n\033[31mTimed out waiting for program to finish.\033[0m\n"; |
| 192 | } |
191 | } |
| 193 | } |
192 | } |
| 194 | else |
193 | else |
| 195 | { |
194 | { |
| 196 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
- | |
| 197 | @filecontents = <FP>; |
- | |
| 198 | close FP; |
- | |
| 199 | $socket = atomd_initialize($hostname, $port); |
- | |
| 200 | usleep(100000); |
195 | usleep(100000); |
| 201 | atomd_kill_promt($socket); |
196 | atomd_kill_promt($socket); |
| 202 | 197 | ||
| 203 | #print "Sending Node_ClearHex\n"; |
198 | #print "Sending Node_ClearHex\n"; |
| 204 | atomd_send_command($socket, "Node_ClearHex"); |
199 | atomd_send_command($socket, "Node_ClearHex"); |