Subversion Repositories HomeAutomation

Rev

Rev 782 | Rev 1701 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 782 Rev 1527
Line 210... Line 210...
210
    static private void printSyntax() {
210
    static private void printSyntax() {
211
        Console.WriteLine("Syntax: program.exe [options] -h <host> -p <port>");
211
        Console.WriteLine("Syntax: program.exe [options] -h <host> -p <port>");
212
        Console.WriteLine("Host and port are host and port of canDaemon, most likely localhost and 1200.");
212
        Console.WriteLine("Host and port are host and port of canDaemon, most likely localhost and 1200.");
213
        Console.WriteLine("Options:");
213
        Console.WriteLine("Options:");
214
        Console.WriteLine("  -f <hexfile>   Specify a file to be loaded to target.");
214
        Console.WriteLine("  -f <hexfile>   Specify a file to be loaded to target.");
-
 
215
        Console.WriteLine("  -n <nodeid>    Id of target node, hex or decimal, depricated.");
215
        Console.WriteLine("  -n <nodeid>    Id of target node, hex or decimal.");
216
        Console.WriteLine("  -i <HWid>      Id of target node, hex or decimal.");
216
        Console.WriteLine("  -t             Enter terminal mode.");
217
        Console.WriteLine("  -t             Enter terminal mode.");
217
        Console.WriteLine("  -r             Reset node before loading target.");
218
        Console.WriteLine("  -r             Reset node before loading target.");
218
        Console.WriteLine("  -s             Start node after loading target.");
219
        Console.WriteLine("  -s             Start node after loading target.");
219
        Console.WriteLine("  -b             Program hex as bios, use with caution.");
220
        Console.WriteLine("  -b             Program hex as bios, use with caution.");
220
    }
221
    }
221
   
222
   
222
    static private void printHelp() {
223
    static private void printHelp() {
223
        Console.WriteLine("canDude commands:");
224
        Console.WriteLine("canDude commands:");
224
        Console.WriteLine("load [<hexfile>] - reload hexfile or load new hexfile");
225
        Console.WriteLine("load [<hexfile>] - reload hexfile or load new hexfile");
-
 
226
        Console.WriteLine("node <nodeid>    - specify id of target node, hex or decimal, depricated");
225
        Console.WriteLine("node <nodeid>    - specify id of target node, hex or decimal");
227
        Console.WriteLine("hwid <HWid>      - specify id of target node, hex or decimal");
226
        Console.WriteLine("reset            - reset node");
228
        Console.WriteLine("reset            - reset node");
227
        Console.WriteLine("start            - start application in node (no feedback yet)");
229
        Console.WriteLine("start            - start application in node (no feedback yet)");
228
        Console.WriteLine("go               - start download application to target");
230
        Console.WriteLine("go               - start download application to target");
229
        Console.WriteLine("go bios          - start download bios to target, use with caution");
231
        Console.WriteLine("go bios          - start download bios to target, use with caution");
230
        Console.WriteLine("help             - prints this help");
232
        Console.WriteLine("help             - prints this help");
Line 295... Line 297...
295
    }
297
    }
296
   
298
   
297
    static private bool parseInput(string instr) {
299
    static private bool parseInput(string instr) {
298
        //parse commands entered on std in
300
        //parse commands entered on std in
299
        if (instr.Equals("reset")) {        //reset command, send a reset to current node
301
        if (instr.Equals("reset")) {        //reset command, send a reset to current node
300
            if (sNodeid) {
302
            if (sHWid) {
301
                dc.flushData();
303
                dc.flushData();
302
                CanNMT cpn = new CanNMT(HWID_INUSE);
304
                CanNMT cpn = new CanNMT(HWID_INUSE);
303
                cpn.doReset(dc, nodeid, HWid);
305
                cpn.doReset(dc, nodeid, HWid);
304
            } else {
306
            } else {
305
                if (DEBUG_LEVEL>0) { Console.WriteLine("No nodeid has been specified"); }
307
                if (DEBUG_LEVEL>0) { Console.WriteLine("No HWid has been specified"); }
306
            }
308
            }
307
        }
309
        }
308
        else if (instr.Equals("start")) {   //start command, send a start to current node
310
        else if (instr.Equals("start")) {   //start command, send a start to current node
309
            if (sNodeid) {
311
            if (sHWid) {
310
                CanNMT cpn = new CanNMT(HWID_INUSE);
312
                CanNMT cpn = new CanNMT(HWID_INUSE);
311
                cpn.doStart(dc, nodeid, HWid);
313
                cpn.doStart(dc, nodeid, HWid);
312
            } else {
314
            } else {
313
                if (DEBUG_LEVEL>0) { Console.WriteLine("No nodeid has been specified"); }
315
                if (DEBUG_LEVEL>0) { Console.WriteLine("No HWid has been specified"); }
314
            }
316
            }
315
        }
317
        }
316
        else if (instr.StartsWith("go")) {  //downloading command
318
        else if (instr.StartsWith("go")) {  //downloading command
317
            bool dlBios = false;
319
            bool dlBios = false;
318
            bool error = true;
320
            bool error = true;
Line 321... Line 323...
321
                error = false;
323
                error = false;
322
            } else if (instr.Equals("go")) {    //is an application should be downloaded
324
            } else if (instr.Equals("go")) {    //is an application should be downloaded
323
                error = false;
325
                error = false;
324
            }
326
            }
325
           
327
           
326
            if (!sNodeid) {
328
            if (!sHWid) {
327
                if (DEBUG_LEVEL>0) { Console.WriteLine("No nodeid has been specified"); }
329
                if (DEBUG_LEVEL>0) { Console.WriteLine("No HWid has been specified"); }
328
                error = true;
330
                error = true;
329
            }
331
            }
330
            if (!sHexfile) {
332
            if (!sHexfile) {
331
                if (DEBUG_LEVEL>0) { Console.WriteLine("No hexfile has been specified"); }
333
                if (DEBUG_LEVEL>0) { Console.WriteLine("No hexfile has been specified"); }
332
                error = true;
334
                error = true;
Line 387... Line 389...
387
                //second argument is nodeid
389
                //second argument is nodeid
388
                string node = instr.Substring(5);
390
                string node = instr.Substring(5);
389
                parseNodeId(node);
391
                parseNodeId(node);
390
            }
392
            }
391
            if (DEBUG_LEVEL>1) { Console.WriteLine("NodeId is 0x"+ String.Format("{0:x2}", nodeid)); }
393
            if (DEBUG_LEVEL>1) { Console.WriteLine("NodeId is 0x"+ String.Format("{0:x2}", nodeid)); }
-
 
394
        }
-
 
395
        else if (instr.StartsWith("hwid")) {
-
 
396
            //change hwid
-
 
397
            if (instr.Length > 5) {
-
 
398
                //second argument is nodeid
-
 
399
                string node = instr.Substring(5);
-
 
400
                parseHWId(node);
-
 
401
            }
-
 
402
            if (DEBUG_LEVEL>1) { Console.WriteLine("HWid is 0x"+ String.Format("{0:x8}", HWid)); }
392
        }
403
        }
393
        else if (instr.Equals("help")) {
404
        else if (instr.Equals("help")) {
394
            printHelp();
405
            printHelp();
395
        }
406
        }
396
        else if (instr.Equals("exit") || instr.Equals("quit") || instr.Equals("q")) {
407
        else if (instr.Equals("exit") || instr.Equals("quit") || instr.Equals("q")) {