X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tools%2Fplatforms%2Fmsp430%2Fcppbsl%2Fsrc%2FParameters.cc;fp=tools%2Fplatforms%2Fmsp430%2Fcppbsl%2Fsrc%2FParameters.cc;h=578035c3e8ed5830e22a89ca2ce92431910839fc;hb=4c09f86cfeeec05eb3c8b416e7be96c75480ab7d;hp=fff595848c81764c1629a0e23690aa01addc445d;hpb=1341c02a1a54cd12ec6258f339441180f01b58c7;p=tinyos-2.x.git diff --git a/tools/platforms/msp430/cppbsl/src/Parameters.cc b/tools/platforms/msp430/cppbsl/src/Parameters.cc index fff59584..578035c3 100644 --- a/tools/platforms/msp430/cppbsl/src/Parameters.cc +++ b/tools/platforms/msp430/cppbsl/src/Parameters.cc @@ -31,52 +31,96 @@ #include #include #include -#include "cmdline.h" +#include #include "Parameters.h" using namespace std; Parameters::Parameters(int argc, char **argv) { + int c; action = NONE; - gengetopt_args_info args_info; - cmdline_parser_init(&args_info); - if(cmdline_parser(argc, argv, &args_info) != 0) { - exit(1); + device = 0; + verbose = false; + action = NONE; + image = 0; + telosb = false; + + poptOption optionsTable[] = { + {"debug",'D', 0, 0, 'd', "print many statements on progress"}, + {"f1x",'1', 0, 0, '1', "Specify CPU family, in case autodetect fails"}, + {"invert-reset",'R', 0, 0, 'R', "RESET pin is inverted"}, + {"invert-test",'T', 0, 0, 'T', "TEST pin is inverted"}, + {"telosb",'b', 0, 0, 'b', "Assume a TelosB node"}, + {"tmote",'b', 0, 0, 'b', "Assume a Tmote node"}, + {"intelhex",'I', 0, 0, 'I', "force fileformat to be IntelHex"}, + {"erase",'e', 0, 0, 'e', "erase device"}, + {"reset",'r', 0, 0, 'r', "reset device"}, + {"program",'p', POPT_ARG_STRING, &image, 0, + "Program file", ""}, + {"comport",'c', POPT_ARG_STRING, &device, 0, + "communicate with MSP430 using this device", ""}, + POPT_AUTOHELP + POPT_TABLEEND + }; + + poptContext optCon; /* context for parsing command-line options */ + optCon = poptGetContext(NULL, argc, (const char**)argv, optionsTable, 0); + /* Now do options processing */ + while((c = poptGetNextOpt(optCon)) >= 0) { + switch(c) { + case 'R': + invertReset = true; + break; + case 'T': + invertTest = true; + break; + case 'd': + verbose = true; + break; + case 'r': + if(action < RESET) { + action = RESET; + } + break; + case 'e': + if(action < ERASE) { + action = ERASE; + } + break; + case 'b': + telosb = true; + break; + default: + break; + } } - if(args_info.invert_test_given) { - invertTest = true; - } else { - invertTest = false; + if (c < -1) { + /* an error occurred during option processing */ + fprintf(stderr, "%s: %s\n", + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(c)); + exit(1); } - if(args_info.invert_reset_given) { - invertReset = true; - } else { + if(telosb) { invertReset = false; + invertTest = false; } - if(args_info.debug_given) { - verbose = true; - } else { - verbose = false; - } - if((args_info.erase_given) && (action < ERASE)) { - action = ERASE; + if(image != 0) { + action = FLASH; } - if((args_info.reset_given) && (action < RESET)) { - action = RESET; + if(device != 0) { + dev = device; } - if(args_info.program_given) { - action = FLASH; - img = args_info.program_arg; + else { + exit(1); } - if(args_info.comport_given) { - dev = args_info.comport_arg; + if(image != 0) { + img = image; } - if(args_info.telosb_given || args_info.tmote_given) { - telosb = true; - invertReset = false; - invertTest = false; + else if(action == FLASH) { + exit(1); } - cmdline_parser_free(&args_info); + poptFreeContext(optCon); };