Make C++ compiler friendly and handle all eight counters in one process.

r1171 | dcl | 2006-10-24 15:44:25 +1000 (Tue, 24 Oct 2006) | 2 lines
This commit is contained in:
Douglas Clowes
2006-10-24 15:44:25 +10:00
parent 74ad3d225f
commit 2ab57e1eb2
13 changed files with 294 additions and 191 deletions

View File

@@ -53,7 +53,7 @@ static struct param_command_t {
{CMD_SYNC, TXT_SYNC},
{0, NULL}
};
#define NUM_CMDS (sizeof(param_command)/sizeof(param_command[0]))
#define NUM_CMDS ((int) (sizeof(param_command)/sizeof(param_command[0])))
static int name_to_command(char* name)
{
@@ -74,22 +74,22 @@ bool param_set(pPARAMETERS pp, char* name, char* value)
{
case CMD_DIRECTION:
result = true;
dprintf(0, "Direction=%s", pp->direction ? "Down" : "Up");
dbg_printf(0, "Direction=%s", pp->direction ? "Down" : "Up");
if (strcasecmp(value, "down") == 0)
pp->direction = COUNT_DOWN;
else
pp->direction = COUNT_UP;
dprintf(0, "=>%s\n", pp->direction ? "Down" : "Up");
dbg_printf(0, "=>%s\n", pp->direction ? "Down" : "Up");
break;
case CMD_INITIAL:
result = true;
dprintf(0, "Initial=%llu", pp->initial_count);
dbg_printf(0, "Initial=%llu", pp->initial_count);
pp->initial_count = strtoull(value, NULL, 10);
dprintf(0, "=>%llu\n", pp->initial_count);
dbg_printf(0, "=>%llu\n", pp->initial_count);
break;
case CMD_OUTPUT:
result = true;
dprintf(0, "Direction=%s", pp->output_line == 2 ? "Inverted":
dbg_printf(0, "Output=%s", pp->output_line == 2 ? "Inverted":
pp->output_line == 1 ? "Enabled" : "Disabled");
if (strcasecmp(value, "enabled") == 0)
pp->output_line = 1;
@@ -97,105 +97,105 @@ bool param_set(pPARAMETERS pp, char* name, char* value)
pp->output_line = 2;
else
pp->output_line = 0;
dprintf(0, "=>%s\n", pp->output_line == 2 ? "Inverted":
dbg_printf(0, "=>%s\n", pp->output_line == 2 ? "Inverted":
pp->output_line == 1 ? "Enabled" : "Disabled");
break;
case CMD_REPORT:
result = true;
dprintf(0, "Report=%d", pp->report_period);
dbg_printf(0, "Report=%d", pp->report_period);
pp->report_period = strtol(value, NULL, 10);
if (pp->report_period < 1)
pp->report_period = 1;
else if (pp->report_period > 1000)
pp->report_period = 1000;
dprintf(0, "=>%d\n", pp->report_period);
dbg_printf(0, "=>%d\n", pp->report_period);
break;
case CMD_RANGE_MODE:
result = true;
dprintf(0, "range_mode=%d", pp->range_mode);
dbg_printf(0, "range_mode=%d", pp->range_mode);
pp->range_mode = strtol(value, NULL, 10);
if (pp->range_mode < 0)
pp->range_mode = 0;
else if (pp->range_mode > 2)
pp->range_mode = 0;
dprintf(0, "=>%d\n", pp->range_mode);
dbg_printf(0, "=>%d\n", pp->range_mode);
break;
case CMD_RANGE_GATE:
result = true;
dprintf(0, "range_gate=%s",
dbg_printf(0, "range_gate=%s",
pp->range_gate_enable ? "Enabled" : "Disabled");
if (strcasecmp(value, "enabled") == 0)
pp->range_gate_enable = true;
else
pp->range_gate_enable = false;
dprintf(0, "=>%s\n",
dbg_printf(0, "=>%s\n",
pp->range_gate_enable ? "Enabled" : "Disabled");
break;
case CMD_RE_CHECK:
result = true;
dprintf(0, "RE_Check=%s",
dbg_printf(0, "RE_Check=%s",
pp->range_check_enable ? "Enabled" : "Disabled");
if (strcasecmp(value, "enabled") == 0)
pp->range_check_enable = true;
else
pp->range_check_enable = false;
dprintf(0, "=>%s\n",
dbg_printf(0, "=>%s\n",
pp->range_check_enable ? "Enabled" : "Disabled");
break;
case CMD_RANGE_HIGH:
result = true;
dprintf(0, "RangeHigh=%g", pp->range_high);
dbg_printf(0, "RangeHigh=%g", pp->range_high);
pp->range_high = strtod(value, NULL);
if (pp->range_high < 0.0)
pp->range_high = 0.0;
dprintf(0, "=>%g\n", pp->range_high);
dbg_printf(0, "=>%g\n", pp->range_high);
break;
case CMD_RANGE_LOW:
result = true;
dprintf(0, "RangeLow=%g", pp->range_low);
dbg_printf(0, "RangeLow=%g", pp->range_low);
pp->range_low = strtod(value, NULL);
if (pp->range_low < 0.0)
pp->range_low = 0.0;
dprintf(0, "=>%g\n", pp->range_low);
dbg_printf(0, "=>%g\n", pp->range_low);
break;
case CMD_SCAN:
result = true;
dprintf(0, "Scan=%d", pp->poll_period);
dbg_printf(0, "Scan=%d", pp->poll_period);
pp->poll_period = strtol(value, NULL, 10);
if (pp->poll_period < 1)
pp->poll_period = 1;
else if (pp->poll_period > 1000)
pp->poll_period = 1000;
dprintf(0, "=>%d\n", pp->poll_period);
dbg_printf(0, "=>%d\n", pp->poll_period);
break;
case CMD_SAMPLE:
result = true;
dprintf(0, "Sample=%d", pp->sample_period);
dbg_printf(0, "Sample=%d", pp->sample_period);
pp->sample_period = strtol(value, NULL, 10);
if (pp->sample_period < 1)
pp->sample_period = 1;
else if (pp->sample_period > 1000)
pp->sample_period = 1000;
dprintf(0, "=>%d\n", pp->sample_period);
dbg_printf(0, "=>%d\n", pp->sample_period);
break;
case CMD_SYNC:
result = true;
dprintf(0, "Sync=%s", pp->sync ? "External" : "Internal");
dbg_printf(0, "Sync=%s", pp->sync ? "External" : "Internal");
if (strcasecmp(value, "external") == 0)
pp->sync = true;
else
pp->sync = false;
dprintf(0, "=>%s\n", pp->sync ? "External" : "Internal");
dbg_printf(0, "=>%s\n", pp->sync ? "External" : "Internal");
break;
case CMD_TERMINAL:
result = true;
dprintf(0, "Sample=%llu", pp->terminal_count);
dbg_printf(0, "Sample=%llu", pp->terminal_count);
pp->terminal_count = strtoull(value, NULL, 10);
dprintf(0, "=>%llu\n", pp->terminal_count);
dbg_printf(0, "=>%llu\n", pp->terminal_count);
break;
case CMD_TE_CHECK:
result = true;
dprintf(0, "TE_Check=%s",
dbg_printf(0, "TE_Check=%s",
pp->terminal_check_type == 0 ? "None" :
pp->terminal_check_type == 1 ? "Counter" :
pp->terminal_check_type == 2 ? "Timer" : "Unknown");
@@ -205,13 +205,13 @@ bool param_set(pPARAMETERS pp, char* name, char* value)
pp->terminal_check_type = 2;
else
pp->terminal_check_type = 0;
dprintf(0, "=>%s\n",
dbg_printf(0, "=>%s\n",
pp->terminal_check_type == 0 ? "None" :
pp->terminal_check_type == 1 ? "Counter" :
pp->terminal_check_type == 2 ? "Timer" : "Unknown");
break;
default:
dprintf(0, "Unknown Parameter: \"%s\" = \"%s\"\n", name, value);
dbg_printf(0, "Unknown Parameter: \"%s\" = \"%s\"\n", name, value);
break;
}
return result;
@@ -364,7 +364,7 @@ bool param_get_cmd(pPARAMETERS pp, char* cmd, int n)
result = true;
}
else
dprintf(0, "Unknown GET Parameter: \"%s\"\n", name);
dbg_printf(0, "Unknown GET Parameter: \"%s\"\n", name);
break;
}
if (!result)