static int const nMeasFuncs = sizeof(StrMeasFuncs) /
sizeof(StrMeasFuncs[0]);
// defaults
static int const DefAddr = 10;
static double const DefPacing = 100e-6; // s
static int const DefMeasFunc = 2;
static double const DefRefFreq = 10e6; // Hz
static double const DefDelta = 10e5; // Hz
// assign some defaults
pArgs->bUSB = true;
pArgs->nAddr = DefAddr;
pArgs->Pacing = DefPacing;
strcpy(pArgs->Func, StrMeasFuncs[DefMeasFunc]);
pArgs->bPeriod = (DefMeasFunc < nFirstFreq);
pArgs->RefFreq = DefRefFreq;
pArgs->Delta = DefDelta;
// parse command line
bool bError = (argc < 2); // at least interface should be
// specified
for(inti=1,nArg = i; ! bError && i < argc; i++, nArg++
)
{
char const *s = argv[i];
switch (nArg)
{
case 1: // interface
{
// find ':' delimiter
intj=0;
for(j=0;0!=s[j] && ':' != s[j]; j++ );
// check interface and read address (if any)
int const nInterface = CheckStr(s, j,
StrInterfaces, 2);
if ( nInterface<0){bError = true; break; }
pArgs->bUSB = (0 == nInterface);
sscanf(s + j, ":%d", &(pArgs->nAddr));
break;
}
case 2: // Pacing
{
if(1==sscanf(s, "%lf", &(pArgs->Pacing)) )
{
if ( pArgs->Pacing < 50e-6 ) pArgs->Pacing =
50e-6;
Programming Examples
4-16 Error Code