Rev 2158 | Rev 2161 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2158 | Rev 2159 | ||
|---|---|---|---|
| Line 75... | Line 75... | ||
| 75 | 75 | ||
| 76 | print "atomDude settings:\n"; |
76 | print "atomDude settings:\n"; |
| 77 | print "Hardware id: " . $hwid . "\n"; |
77 | print "Hardware id: " . $hwid . "\n"; |
| 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 |
|
80 | #print "Parameters: " . "\n"; |
| 81 | 81 | ||
| 82 | if ($reset eq "true" && $filename eq "") |
82 | if ($reset eq "true" && $filename eq "") |
| 83 | { |
83 | { |
| 84 | if ($port == 1203) |
84 | if ($port == 1203) |
| 85 | { |
85 | { |
| 86 | $socket = atomd_initialize($hostname, $port); |
86 | $socket = atomd_initialize($hostname, $port); |
| 87 | atomjs_write($socket, "Node_ResetNative('".$hwid."');\n"); |
87 | atomjs_write($socket, "Node_ResetNative('".$hwid."');\n"); |
| 88 | print atomjs_read_line($socket); |
88 | print atomjs_read_line($socket); |
| - | 89 | $success = 0; |
|
| 89 | for ($count = 0; $count < 15; $count++) |
90 | for ($count = 0; $count < 15; $count++) |
| 90 | { |
91 | { |
| 91 | atomjs_write($socket, "Node_ResetPollNative();\n"); |
92 | atomjs_write($socket, "Node_ResetPollNative();\n"); |
| 92 | if (atomjs_read_line($socket) =~ m/true/) |
93 | if (atomjs_read_line($socket) =~ m/true/) |
| 93 | { |
94 | { |
| 94 | print "\033[32m" . $hwid . " started okay.\033[0m\n"; |
95 | print "\033[32m" . $hwid . " started okay.\033[0m\n"; |
| - | 96 | $success = 1; |
|
| 95 | last; |
97 | last; |
| 96 | } |
98 | } |
| 97 | usleep(200000); |
99 | usleep(200000); |
| 98 | } |
100 | } |
| - | 101 | if ($success == 0) |
|
| - | 102 | { |
|
| - | 103 | print "\033[31mTimed out waiting for reset.\033[0m\n"; |
|
| - | 104 | } |
|
| 99 | } |
105 | } |
| 100 | else |
106 | else |
| 101 | { |
107 | { |
| 102 | $socket = atomd_initialize($hostname, $port); |
108 | $socket = atomd_initialize($hostname, $port); |
| 103 | 109 | ||
| 104 | usleep(100000); |
110 | usleep(100000); |
| 105 | atomd_kill_promt($socket); |
111 | atomd_kill_promt($socket); |
| 106 | atomd_send_command($socket, "Node_Reset $hwid"); |
112 | atomd_send_command($socket, "Node_Reset $hwid"); |
| 107 | print atomd_read_command_response($socket); |
113 | print atomd_read_command_response($socket); |
| 108 | #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\""); |
114 | #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\""); |
| 109 | #exit($result); |
115 | #exit($result); |
| 110 | } |
116 | } |
| 111 | } |
117 | } |
| 112 | else |
118 | else |
| 113 | { |
119 | { |
| 114 | if ($port == 1203) |
120 | if ($port == 1203) |
| 115 | { |
121 | { |
| 116 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
122 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
| 117 | @filecontents = <FP>; |
123 | @filecontents = <FP>; |
| 118 | close FP; |
124 | close FP; |
| 119 | $socket = atomd_initialize($hostname, $port); |
125 | $socket = atomd_initialize($hostname, $port); |
| 120 | - | ||
| 121 | atomjs_write($socket, " |
126 | atomjs_write($socket, "Node_ClearHex();\n"); |
| 122 |
|
127 | atomjs_read_line($socket); |
| - | 128 | my $linenums = 0; |
|
| 123 | foreach $filerow (@filecontents) |
129 | foreach $filerow (@filecontents) |
| - | 130 | { |
|
| 124 | $filerow =~ s/^\s+//; |
131 | $filerow =~ s/^\s+//; |
| 125 | $filerow =~ s/\s+$//; |
132 | $filerow =~ s/\s+$//; |
| - | 133 | $linenums += 1; |
|
| - | 134 | $command = "Node_AppendHexNative('".$filerow."');\n"; |
|
| 126 | atomjs_write($socket, |
135 | atomjs_write($socket, $command); |
| 127 |
|
136 | atomjs_read_line($socket); |
| 128 | } |
137 | } |
| - | 138 | $command = "Node_ProgramNative('".$hwid."', '".$bios."', '".$linenums."');\n"; |
|
| 129 | atomjs_write($socket, |
139 | atomjs_write($socket, $command); |
| 130 |
|
140 | #print $command; |
| - | 141 | print atomjs_read_line($socket); |
|
| - | 142 | atomd_disconnect($socket); |
|
| - | 143 | # $success = 0; |
|
| - | 144 | # for ($count = 0; $count < 150; $count++) |
|
| - | 145 | # { |
|
| - | 146 | # atomjs_write($socket, "Node_ProgramPollNative();\n"); |
|
| - | 147 | # if (atomjs_read_line($socket) =~ m/true/) |
|
| - | 148 | # { |
|
| - | 149 | # print "\033[32m" . $hwid . " started okay.\033[0m\n"; |
|
| - | 150 | # $success = 1; |
|
| - | 151 | # last; |
|
| - | 152 | # } |
|
| - | 153 | # usleep(200000); |
|
| - | 154 | # } |
|
| - | 155 | # if ($success == 0) |
|
| - | 156 | # { |
|
| - | 157 | # print "\033[31mTimed out waiting for program to finish.\033[0m\n"; |
|
| - | 158 | # } |
|
| 131 | } |
159 | } |
| 132 | else |
160 | else |
| 133 | { |
161 | { |
| 134 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
162 | open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n"; |
| 135 | @filecontents = <FP>; |
163 | @filecontents = <FP>; |
| 136 | close FP; |
164 | close FP; |
| 137 | $socket = atomd_initialize($hostname, $port); |
165 | $socket = atomd_initialize($hostname, $port); |
| 138 | usleep(100000); |
166 | usleep(100000); |
| 139 | atomd_kill_promt($socket); |
167 | atomd_kill_promt($socket); |
| 140 | 168 | ||
| 141 | #print "Sending Node_ClearHex\n"; |
169 | #print "Sending Node_ClearHex\n"; |
| 142 | atomd_send_command($socket, "Node_ClearHex"); |
170 | atomd_send_command($socket, "Node_ClearHex"); |
| 143 | atomd_kill_promt($socket); |
171 | atomd_kill_promt($socket); |
| 144 | 172 | ||
| 145 | my $linenums = 0; |
173 | my $linenums = 0; |
| 146 | foreach $filerow (@filecontents) |
174 | foreach $filerow (@filecontents) |
| - | 175 | { |
|
| 147 | #print "Sending Node_AppendHex $filerow \n"; |
176 | #print "Sending Node_AppendHex $filerow \n"; |
| 148 | #$filerow =~ s/^\s+//; |
177 | #$filerow =~ s/^\s+//; |
| 149 | #$filerow =~ s/\s+$//; |
178 | #$filerow =~ s/\s+$//; |
| 150 | atomd_send_command($socket, "Node_AppendHex $filerow"); |
179 | atomd_send_command($socket, "Node_AppendHex $filerow"); |
| 151 | atomd_kill_promt($socket); |
180 | atomd_kill_promt($socket); |
| Line 156... | Line 185... | ||
| 156 | 185 | ||
| 157 | print atomd_read_command_response($socket); |
186 | print atomd_read_command_response($socket); |
| 158 | 187 | ||
| 159 | # my $result = system("atomic -s $hostname -p $port -c \"Node_Program $hwid $bios $filename\""); |
188 | # my $result = system("atomic -s $hostname -p $port -c \"Node_Program $hwid $bios $filename\""); |
| 160 | # exit($result); |
189 | # exit($result); |
| - | 190 | } |
|
| 161 | } |
191 | } |
| 162 | 192 | ||
| 163 | exit(0); |
193 | exit(0); |