Rev 456 | Rev 459 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 456 | Rev 458 | ||
|---|---|---|---|
| Line 130... | Line 130... | ||
| 130 | } |
130 | } |
| 131 | 131 | ||
| 132 | if (success) { |
132 | if (success) { |
| 133 | if (DEBUG_LEVEL>0) { |
133 | if (DEBUG_LEVEL>0) { |
| 134 | Console.WriteLine(""); |
134 | Console.WriteLine(""); |
| 135 |
|
135 | printHelp(); |
| 136 | //Console.WriteLine("reset - reset communication."); |
- | |
| 137 | Console.WriteLine("exit - exit program"); |
- | |
| 138 | Console.WriteLine("load [<hexfile>] - reload hexfile or load new hexfile"); |
- | |
| 139 | Console.WriteLine("node <nodeid> - specify id of target node, hex or decimal"); |
- | |
| 140 | Console.WriteLine("reset - reset node"); |
- | |
| 141 | Console.WriteLine("start - start application in node (no feedback yet)"); |
- | |
| 142 | Console.WriteLine("go - start download application to target"); |
- | |
| 143 | Console.WriteLine("go bios - start download bios to target, use with caution"); |
- | |
| 144 | Console.WriteLine(""); |
136 | Console.WriteLine(""); |
| 145 | //Thread.Sleep(1000); |
137 | //Thread.Sleep(1000); |
| 146 | } |
138 | } |
| 147 | 139 | ||
| 148 | string instr; |
140 | string instr; |
| Line 181... | Line 173... | ||
| 181 | } |
173 | } |
| 182 | 174 | ||
| 183 | //if a hexfile is loaded and we are connected to candaemon then start autodownloading sequence |
175 | //if a hexfile is loaded and we are connected to candaemon then start autodownloading sequence |
| 184 | if (success) { |
176 | if (success) { |
| 185 | bool autosuccess = true; |
177 | bool autosuccess = true; |
| 186 | 178 | ||
| 187 | CanNMT cpn = new CanNMT(); |
179 | CanNMT cpn = new CanNMT(); |
| 188 | if (aReset) { |
180 | if (aReset) { |
| 189 | //send a reset command (and wait for feedback) |
181 | //send a reset command (and wait for feedback) |
| 190 | if (!cpn.doReset(dc, nodeid)) { |
182 | if (!cpn.doReset(dc, nodeid)) { |
| 191 | Console.WriteLine("Target node did not respond to reset, I quit"); |
183 | Console.WriteLine("Target node did not respond to reset, I quit"); |
| 192 | autosuccess = false; |
184 | autosuccess = false; |
| 193 | } |
185 | } |
| 194 | } |
186 | } |
| 195 | 187 | ||
| 196 | if (autosuccess) { |
188 | if (autosuccess) { |
| 197 | //send application |
189 | //send application |
| 198 | Console.WriteLine("Programming not implemented yet, I quit"); |
190 | Console.WriteLine("Programming not implemented yet, I quit"); |
| 199 | autosuccess = false; |
191 | autosuccess = false; |
| 200 | } |
192 | } |
| 201 | 193 | ||
| 202 | if (autosuccess && aStart) { |
194 | if (autosuccess && aStart) { |
| 203 | //start applikation |
195 | //start applikation |
| 204 | cpn.doStart(dc, nodeid); |
196 | cpn.doStart(dc, nodeid); |
| 205 | } |
197 | } |
| 206 | 198 | ||
| 207 | } |
199 | } |
| - | 200 | } |
|
| 208 | } |
201 | } |
| - | 202 | ||
| - | 203 | static private void printHelp() { |
|
| - | 204 | Console.WriteLine("canDude commands:"); |
|
| - | 205 | //Console.WriteLine("reset - reset communication."); |
|
| - | 206 | Console.WriteLine("load [<hexfile>] - reload hexfile or load new hexfile"); |
|
| - | 207 | Console.WriteLine("node <nodeid> - specify id of target node, hex or decimal"); |
|
| - | 208 | Console.WriteLine("reset - reset node"); |
|
| - | 209 | Console.WriteLine("start - start application in node (no feedback yet)"); |
|
| - | 210 | Console.WriteLine("go - start download application to target"); |
|
| - | 211 | Console.WriteLine("go bios - start download bios to target, use with caution"); |
|
| - | 212 | Console.WriteLine("help - prints this help"); |
|
| - | 213 | Console.WriteLine("exit or quit - exit program"); |
|
| 209 | } |
214 | } |
| 210 | 215 | ||
| 211 | static private bool parseNodeId(string node) { |
216 | static private bool parseNodeId(string node) { |
| 212 | sNodeid = false; |
217 | sNodeid = false; |
| 213 | if (node.Length > 0) { |
218 | if (node.Length > 0) { |
| Line 233... | Line 238... | ||
| 233 | } catch { |
238 | } catch { |
| 234 | Console.WriteLine("nodeadress error!"); |
239 | Console.WriteLine("nodeadress error!"); |
| 235 | return false; |
240 | return false; |
| 236 | } |
241 | } |
| 237 | } else { |
242 | } else { |
| 238 | Console.WriteLine("nodeadress error!"); |
243 | Console.WriteLine("nodeadress error!"); |
| 239 | return false; |
244 | return false; |
| 240 | } |
245 | } |
| 241 | } |
246 | } |
| 242 | } |
247 | } |
| 243 | 248 | ||
| 244 | return true; |
249 | return true; |
| 245 | } |
250 | } |
| 246 | 251 | ||
| 247 | static private bool parseInput(string instr) { |
252 | static private bool parseInput(string instr) { |
| 248 | if (instr.Equals("reset")) { |
253 | if (instr.Equals("reset")) { |
| 249 | if (sNodeid) { |
254 | if (sNodeid) { |
| 250 | CanNMT cpn = new CanNMT(); |
255 | CanNMT cpn = new CanNMT(); |
| 251 | cpn.doReset(dc, nodeid); |
256 | cpn.doReset(dc, nodeid); |
| 252 | } else { |
257 | } else { |
| 253 | Console.WriteLine("No nodeid has been specified"); |
258 | Console.WriteLine("No nodeid has been specified"); |
| 254 | } |
259 | } |
| 255 | } |
260 | } |
| 256 | else if (instr.Equals("start")) { |
261 | else if (instr.Equals("start")) { |
| 257 | if (sNodeid) { |
262 | if (sNodeid) { |
| 258 | CanNMT cpn = new CanNMT(); |
263 | CanNMT cpn = new CanNMT(); |
| 259 | cpn.doStart(dc, nodeid); |
264 | cpn.doStart(dc, nodeid); |
| 260 | } else { |
265 | } else { |
| 261 | Console.WriteLine("No nodeid has been specified"); |
266 | Console.WriteLine("No nodeid has been specified"); |
| 262 | } |
267 | } |
| 263 | } |
268 | } |
| 264 | else if (instr.StartsWith("go")) { |
269 | else if (instr.StartsWith("go")) { |
| 265 | bool dlBios = false; |
270 | bool dlBios = false; |
| 266 | bool error = true; |
271 | bool error = true; |
| 267 | if (instr.Equals("go bios")) { |
272 | if (instr.Equals("go bios")) { |
| 268 | dlBios = true; |
273 | dlBios = true; |
| 269 | error = false; |
274 | error = false; |
| 270 | } else if (instr.Equals("go")) { |
275 | } else if (instr.Equals("go")) { |
| 271 | error = false; |
276 | error = false; |
| 272 | } |
277 | } |
| 273 | 278 | ||
| 274 | if (!sNodeid) { |
279 | if (!sNodeid) { |
| 275 | Console.WriteLine("No nodeid has been specified"); |
280 | Console.WriteLine("No nodeid has been specified"); |
| 276 | error = true; |
281 | error = true; |
| 277 | } |
282 | } |
| Line 283... | Line 288... | ||
| 283 | CanNMT cpn = new CanNMT(); |
288 | CanNMT cpn = new CanNMT(); |
| 284 | if (!error && aReset) { |
289 | if (!error && aReset) { |
| 285 | //send a reset command (and wait for feedback) |
290 | //send a reset command (and wait for feedback) |
| 286 | if (!cpn.doReset(dc, nodeid)) { |
291 | if (!cpn.doReset(dc, nodeid)) { |
| 287 | Console.WriteLine("Target node did not respond to reset"); |
292 | Console.WriteLine("Target node did not respond to reset"); |
| 288 | error = true; |
293 | error = true; |
| 289 | } |
294 | } |
| 290 | } |
295 | } |
| 291 | 296 | ||
| 292 | if (!error) { |
297 | if (!error) { |
| 293 | //send application |
298 | //send application |
| Line 335... | Line 340... | ||
| 335 | string node = instr.Substring(5); |
340 | string node = instr.Substring(5); |
| 336 | parseNodeId(node); |
341 | parseNodeId(node); |
| 337 | } |
342 | } |
| 338 | Console.WriteLine("NodeId is 0x"+ String.Format("{0:x2}", nodeid)); |
343 | Console.WriteLine("NodeId is 0x"+ String.Format("{0:x2}", nodeid)); |
| 339 | } |
344 | } |
| 340 | else if (instr.Equals(" |
345 | else if (instr.Equals("help")) { |
| - | 346 | printHelp(); |
|
| - | 347 | } |
|
| - | 348 | else if (instr.Equals("exit") || instr.Equals("quit")) { |
|
| 341 | return false; |
349 | return false; |
| 342 | } |
350 | } |
| 343 | else { |
351 | else { |
| 344 | Console.WriteLine("Unknown command."); |
352 | Console.WriteLine("Unknown command."); |
| 345 | } |
353 | } |