Refinement alongside Digital
r1198 | dcl | 2006-10-26 18:38:13 +1000 (Thu, 26 Oct 2006) | 2 lines
This commit is contained in:
@@ -7,7 +7,7 @@ CDEBUG = -ggdb3 -Wall
|
|||||||
LDFLAGS += -g
|
LDFLAGS += -g
|
||||||
TARGETS = Monitor
|
TARGETS = Monitor
|
||||||
|
|
||||||
OBJS = Monitor.o params.o utility.o sock.o display.o cntr.o hctr.o
|
OBJS = Monitor.o params.o utility.o sock.o display.o device.o hware.o
|
||||||
ifeq ($(MAKECMDGOALS),rlp)
|
ifeq ($(MAKECMDGOALS),rlp)
|
||||||
OBJECTS =
|
OBJECTS =
|
||||||
LIBS =
|
LIBS =
|
||||||
@@ -32,28 +32,25 @@ all: $(TARGETS)
|
|||||||
rlp: all
|
rlp: all
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) Monitor Pulser.o Pulser core
|
rm -f $(OBJS) Monitor core
|
||||||
|
|
||||||
Monitor : $(OBJS)
|
Monitor : $(OBJS)
|
||||||
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBFLAGS) -ggdb3
|
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBFLAGS) -ggdb3
|
||||||
|
|
||||||
Monitor.o: Monitor.c Monitor.h params.h utility.h sock.h cntr.h
|
Monitor.o: Monitor.c Monitor.h params.h utility.h sock.h device.h
|
||||||
|
|
||||||
cntr.o: cntr.c cntr.h params.h sock.h
|
device.o: device.c device.h params.h sock.h
|
||||||
|
|
||||||
display.o: display.c display.h utility.h params.h sock.h cntr.h
|
display.o: display.c display.h utility.h params.h sock.h device.h
|
||||||
|
|
||||||
hctr.o: hctr.c hctr.h
|
hware.o: hware.c hware.h
|
||||||
|
|
||||||
params.o: params.c params.h sock.h
|
params.o: params.c params.h sock.h
|
||||||
|
|
||||||
sock.o: sock.c sock.h utility.h display.h cntr.h
|
sock.o: sock.c sock.h utility.h display.h device.h
|
||||||
|
|
||||||
utility.o: utility.c utility.h
|
utility.o: utility.c utility.h
|
||||||
|
|
||||||
Pulser : Pulser.c
|
|
||||||
$(CXX) -o $@ $< $(CXXFLAGS) $(CDEBUG) $(LDFLAGS) $(LIBFLAGS)
|
|
||||||
|
|
||||||
%.o : %.c
|
%.o : %.c
|
||||||
$(CXX) -c -o $@ $< $(CXXFLAGS) $(CDEBUG)
|
$(CXX) -c -o $@ $< $(CXXFLAGS) $(CDEBUG)
|
||||||
|
|
||||||
|
|||||||
@@ -3,44 +3,15 @@
|
|||||||
* ANSI C program:
|
* ANSI C program:
|
||||||
* Monitor.c
|
* Monitor.c
|
||||||
*
|
*
|
||||||
* Description:
|
|
||||||
* This program counts digital events on a NI-6602
|
|
||||||
* Counter Input Channel. The Device, Counter Channel, Initial Count, Count
|
|
||||||
* Direction, and are all configurable.
|
|
||||||
*
|
|
||||||
* Edges are counted on the counter's default input terminal (refer
|
|
||||||
* to the I/O Connections Overview section below for more
|
|
||||||
* information), but could easily be modified to count edges on a
|
|
||||||
* PFI or RTSI line.
|
|
||||||
*
|
|
||||||
* Instructions for Running:
|
|
||||||
* 1. Select the Device and Channel which corresponds to the counter
|
|
||||||
* you want to count on.
|
|
||||||
* 2. Select the TCP/IP port number you want to listen on.
|
|
||||||
* 3. Enter the Initial Count, Count Direction, to specify how you want
|
|
||||||
* the counter to count.
|
|
||||||
*
|
|
||||||
* Steps:
|
|
||||||
* 1. Create a task.
|
|
||||||
* 2. Create a Counter Input channel to Count Events. The Edge
|
|
||||||
* parameter is used to determine if the counter will increment
|
|
||||||
* on rising or falling edges.
|
|
||||||
* 3. Call the Start function to arm the counter and begin
|
|
||||||
* counting. The counter will be preloaded with the Initial
|
|
||||||
* Count.
|
|
||||||
* 4. The counter will be continually polled.
|
|
||||||
* 5. Call the Clear Task function to clear the Task.
|
|
||||||
* 6. Display an error if any.
|
|
||||||
*
|
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#define CNTR_CHK(func) if (cntr_fatal(error=(func))) goto Error; else
|
#define DEVICE_CHK(func) if (device_fatal(error=(func))) goto Error; else
|
||||||
|
|
||||||
#include "Monitor.h"
|
#include "Monitor.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "params.h"
|
#include "params.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "cntr.h"
|
#include "device.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -54,8 +25,6 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define MAX_COUNTERS 8
|
|
||||||
|
|
||||||
int usage(int argc, char* argv[], const char* reason)
|
int usage(int argc, char* argv[], const char* reason)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -74,11 +43,11 @@ int main(int argc, char* argv[])
|
|||||||
char errBuff[2048]={'\0'};
|
char errBuff[2048]={'\0'};
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
uint64 last_poll;
|
uint64 last_poll;
|
||||||
char* device = DEFAULT_COUNTER_DEVICE;
|
char* device = DEFAULT_DEVICE;
|
||||||
uint dev_no;
|
uint dev_no;
|
||||||
int port = DEFAULT_LISTEN_PORT;
|
int port = DEFAULT_LISTEN_PORT;
|
||||||
int idx = 1;
|
int idx = 1;
|
||||||
COUNTER* counters[MAX_COUNTERS];
|
DEVICE* devices[MAX_DEVICES];
|
||||||
|
|
||||||
if (idx >= argc)
|
if (idx >= argc)
|
||||||
return usage(argc, argv, "no args");
|
return usage(argc, argv, "no args");
|
||||||
@@ -128,12 +97,12 @@ int main(int argc, char* argv[])
|
|||||||
dev_no = atoi(&device[3]);
|
dev_no = atoi(&device[3]);
|
||||||
sock_init();
|
sock_init();
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
for (idx = 0; idx < MAX_COUNTERS; ++idx)
|
for (idx = 0; idx < MAX_DEVICES; ++idx)
|
||||||
{
|
{
|
||||||
sprintf(device, "dev%d/ctr%d", dev_no, idx);
|
sprintf(device, "dev%d/ctr%d", dev_no, idx);
|
||||||
CNTR_CHK(cntr_init(&counters[idx], device));
|
DEVICE_CHK(device_init(&devices[idx], device));
|
||||||
sock_listen(port + idx, cntr_command, counters[idx]);
|
sock_listen(port + idx, device_command, devices[idx]);
|
||||||
counters[idx]->current_time = now;
|
devices[idx]->current_time = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Continuously polling. Press Ctrl+C to interrupt\n");
|
printf("Continuously polling. Press Ctrl+C to interrupt\n");
|
||||||
@@ -148,12 +117,12 @@ int main(int argc, char* argv[])
|
|||||||
sock_check(timeout);
|
sock_check(timeout);
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
timeofday = 1000 * (uint64) now.tv_sec + now.tv_usec / 1000;
|
timeofday = 1000 * (uint64) now.tv_sec + now.tv_usec / 1000;
|
||||||
for (idx = 0; idx < MAX_COUNTERS; ++idx)
|
for (idx = 0; idx < MAX_DEVICES; ++idx)
|
||||||
{
|
{
|
||||||
COUNTER* cp = counters[idx];
|
DEVICE* device = devices[idx];
|
||||||
PARAMETERS* pp = &cp->params;
|
PARAMETERS* pp = &device->params;
|
||||||
last_poll = 1000 * (uint64) cp->current_time.tv_sec
|
last_poll = 1000 * (uint64) device->current_time.tv_sec
|
||||||
+ cp->current_time.tv_usec / 1000;
|
+ device->current_time.tv_usec / 1000;
|
||||||
if (timeofday / pp->poll_period > last_poll / pp->poll_period)
|
if (timeofday / pp->poll_period > last_poll / pp->poll_period)
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
else
|
else
|
||||||
@@ -170,18 +139,18 @@ int main(int argc, char* argv[])
|
|||||||
next_timeout = timeout;
|
next_timeout = timeout;
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
{
|
{
|
||||||
cp->current_time = now;
|
device->current_time = now;
|
||||||
#if 1
|
#if 1
|
||||||
dbg_printf(0, "%d:-%s %s %.3f %s %.3f %4d\n",
|
dbg_printf(0, "%d:-%s %s %.3f %s %.3f %4d\n",
|
||||||
idx,
|
idx,
|
||||||
make_timestamp(&cp->current_time),
|
make_timestamp(&device->current_time),
|
||||||
make_timestamp(&cp->sample_timer),
|
make_timestamp(&device->sample_timer),
|
||||||
cntr_time_to_next_sample(cp),
|
device_time_to_next_sample(device),
|
||||||
make_timestamp(&cp->report_timer),
|
make_timestamp(&device->report_timer),
|
||||||
cntr_time_to_next_report(cp),
|
device_time_to_next_report(device),
|
||||||
cp->sample_index);
|
device->sample_index);
|
||||||
#endif
|
#endif
|
||||||
CNTR_CHK(cntr_poll(cp));
|
DEVICE_CHK(device_poll(device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (next_timeout > 999)
|
if (next_timeout > 999)
|
||||||
@@ -193,13 +162,13 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
Error:
|
Error:
|
||||||
puts("");
|
puts("");
|
||||||
if (cntr_fatal(error))
|
if (device_fatal(error))
|
||||||
{
|
{
|
||||||
cntr_errmsg(errBuff, sizeof(errBuff));
|
device_errmsg(errBuff, sizeof(errBuff));
|
||||||
printf("DAQmx Error: %s\n", errBuff);
|
printf("DAQmx Error: %s\n", errBuff);
|
||||||
}
|
}
|
||||||
for (idx = 0; idx < MAX_COUNTERS; ++idx)
|
for (idx = 0; idx < MAX_DEVICES; ++idx)
|
||||||
cntr_term(counters[idx]);
|
device_term(devices[idx]);
|
||||||
printf("End of program\n");
|
printf("End of program\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef _MONITOR_H_
|
#ifndef _MONITOR_H_
|
||||||
#define _MONITOR_H_
|
#define _MONITOR_H_
|
||||||
|
|
||||||
#define DEFAULT_COUNTER_DEVICE "DEV1/CTR0"
|
#define DEFAULT_DEVICE "DEV1"
|
||||||
#define DEFAULT_LISTEN_PORT 3000
|
#define DEFAULT_LISTEN_PORT 3000
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "params.h"
|
#include "params.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "cntr.h"
|
#include "device.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -162,8 +162,8 @@ void put_form(int n)
|
|||||||
dbg_printf(0, "put_form\n");
|
dbg_printf(0, "put_form\n");
|
||||||
BUFFER html;
|
BUFFER html;
|
||||||
BUFFER buffer;
|
BUFFER buffer;
|
||||||
COUNTER* cp = (COUNTER*) sock_device(n);
|
DEVICE* device = (DEVICE*) sock_device(n);
|
||||||
PARAMETERS* pp = &cp->params;
|
PARAMETERS* pp = &device->params;
|
||||||
char *bp;
|
char *bp;
|
||||||
buffer.length = 0;
|
buffer.length = 0;
|
||||||
bp = &buffer.body[buffer.length];
|
bp = &buffer.body[buffer.length];
|
||||||
@@ -323,24 +323,24 @@ void put_page(int n)
|
|||||||
dbg_printf(0, "put_page\n");
|
dbg_printf(0, "put_page\n");
|
||||||
BUFFER html;
|
BUFFER html;
|
||||||
BUFFER buffer;
|
BUFFER buffer;
|
||||||
COUNTER* cp = (COUNTER*) sock_device(n);
|
DEVICE* device = (DEVICE*) sock_device(n);
|
||||||
PARAMETERS* pp = &cp->params;
|
PARAMETERS* pp = &device->params;
|
||||||
SAMPLE* sp;
|
SAMPLE* sp;
|
||||||
char *bp;
|
char *bp;
|
||||||
int refresh;
|
int refresh;
|
||||||
#if 1
|
#if 1
|
||||||
{
|
{
|
||||||
refresh = (int) cntr_time_to_next_report(cp) + 1;
|
refresh = (int) device_time_to_next_report(device) + 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
make_report(cp);
|
make_report(device);
|
||||||
refresh = (pp->poll_period * pp->sample_period * pp->report_period + 500) / 1000;
|
refresh = (pp->poll_period * pp->sample_period * pp->report_period + 500) / 1000;
|
||||||
#endif
|
#endif
|
||||||
if (refresh < MIN_REFRESH)
|
if (refresh < MIN_REFRESH)
|
||||||
refresh = MIN_REFRESH;
|
refresh = MIN_REFRESH;
|
||||||
if (refresh > MAX_REFRESH)
|
if (refresh > MAX_REFRESH)
|
||||||
refresh = MAX_REFRESH;
|
refresh = MAX_REFRESH;
|
||||||
sp = &cp->report;
|
sp = &device->report;
|
||||||
buffer.length = 0;
|
buffer.length = 0;
|
||||||
bp = &buffer.body[buffer.length];
|
bp = &buffer.body[buffer.length];
|
||||||
snprintf(bp, sizeof(buffer.body) - buffer.length,
|
snprintf(bp, sizeof(buffer.body) - buffer.length,
|
||||||
@@ -351,25 +351,25 @@ void put_page(int n)
|
|||||||
"<tr><th align=\"right\">Field</th>\r\n"
|
"<tr><th align=\"right\">Field</th>\r\n"
|
||||||
"<th align=\"left\">Value</th></tr>\r\n");
|
"<th align=\"left\">Value</th></tr>\r\n");
|
||||||
buffer.length += strlen(bp);
|
buffer.length += strlen(bp);
|
||||||
show_text(&buffer, "State", cp->state == counter_stopped ? "STOPPED" :
|
show_text(&buffer, "State", device->state == counter_stopped ? "STOPPED" :
|
||||||
cp->state == counter_running ? "RUNNING" :
|
device->state == counter_running ? "RUNNING" :
|
||||||
cp->state == counter_paused ? "PAUSED" : "IDLE");
|
device->state == counter_paused ? "PAUSED" : "IDLE");
|
||||||
show_text(&buffer, "Direction", pp->direction == COUNT_UP ? "UP" : "DOWN");
|
show_text(&buffer, "Direction", pp->direction == COUNT_UP ? "UP" : "DOWN");
|
||||||
show_int(&buffer, "Scan", pp->poll_period);
|
show_int(&buffer, "Scan", pp->poll_period);
|
||||||
show_int(&buffer, "Sample", pp->sample_period);
|
show_int(&buffer, "Sample", pp->sample_period);
|
||||||
show_int(&buffer, "Report", pp->report_period);
|
show_int(&buffer, "Report", pp->report_period);
|
||||||
show_time(&buffer, "Start Time", &cp->start_time, false);
|
show_time(&buffer, "Start Time", &device->start_time, false);
|
||||||
show_time(&buffer, "Current Time", &cp->current_time, false);
|
show_time(&buffer, "Current Time", &device->current_time, false);
|
||||||
{
|
{
|
||||||
struct timeval tv = cp->stop_time;
|
struct timeval tv = device->stop_time;
|
||||||
if (cp->state == counter_running || cp->state == counter_paused)
|
if (device->state == counter_running || device->state == counter_paused)
|
||||||
{
|
{
|
||||||
tv = cp->current_time;
|
tv = device->current_time;
|
||||||
}
|
}
|
||||||
time_sub(&tv, &cp->start_time);
|
time_sub(&tv, &device->start_time);
|
||||||
show_time(&buffer, "Elapsed", &tv, true);
|
show_time(&buffer, "Elapsed", &tv, true);
|
||||||
}
|
}
|
||||||
show_time(&buffer, "Runtime", &cp->accumulated, true);
|
show_time(&buffer, "Runtime", &device->accumulated, true);
|
||||||
show_time(&buffer, "Report Time", &sp->timestamp, false);
|
show_time(&buffer, "Report Time", &sp->timestamp, false);
|
||||||
show_counter(&buffer, "Counter", sp->counter_value);
|
show_counter(&buffer, "Counter", sp->counter_value);
|
||||||
show_int(&buffer, "Num Polls", sp->num_polls);
|
show_int(&buffer, "Num Polls", sp->num_polls);
|
||||||
@@ -382,9 +382,9 @@ void put_page(int n)
|
|||||||
if (pp->range_check_enable)
|
if (pp->range_check_enable)
|
||||||
{
|
{
|
||||||
char* result;
|
char* result;
|
||||||
if (cp->range_error == 1)
|
if (device->range_error == 1)
|
||||||
result = "<font color=\"BLUE\">LOW</font>";
|
result = "<font color=\"BLUE\">LOW</font>";
|
||||||
else if (cp->range_error == 2)
|
else if (device->range_error == 2)
|
||||||
result = "<font color=\"RED\">HIGH</font>";
|
result = "<font color=\"RED\">HIGH</font>";
|
||||||
else
|
else
|
||||||
result = "<font color=\"GREEN\">OK</font>";
|
result = "<font color=\"GREEN\">OK</font>";
|
||||||
@@ -439,6 +439,7 @@ void put_page(int n)
|
|||||||
void process_form(int n, BUFFER* bp)
|
void process_form(int n, BUFFER* bp)
|
||||||
{
|
{
|
||||||
dbg_printf(0, "process_form\n");
|
dbg_printf(0, "process_form\n");
|
||||||
|
DEVICE* device = (DEVICE*) sock_device(n);
|
||||||
int i, j;
|
int i, j;
|
||||||
int state;
|
int state;
|
||||||
char name[80];
|
char name[80];
|
||||||
@@ -446,7 +447,6 @@ void process_form(int n, BUFFER* bp)
|
|||||||
char hex_str[3];
|
char hex_str[3];
|
||||||
unsigned int hex_val;
|
unsigned int hex_val;
|
||||||
char* tp;
|
char* tp;
|
||||||
COUNTER* cp = (COUNTER*) sock_device(n);
|
|
||||||
state = 0;
|
state = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < bp->length; ++i)
|
for (i = 0; i < bp->length; ++i)
|
||||||
@@ -498,7 +498,7 @@ void process_form(int n, BUFFER* bp)
|
|||||||
if (state == 9)
|
if (state == 9)
|
||||||
{
|
{
|
||||||
dbg_printf(0, "name=\"%s\", value=\"%s\"\n", name, value);
|
dbg_printf(0, "name=\"%s\", value=\"%s\"\n", name, value);
|
||||||
if (param_set(&cp->params, name, value))
|
if (param_set(&device->params, name, value))
|
||||||
;
|
;
|
||||||
else if (strcmp(name, "xxx"))
|
else if (strcmp(name, "xxx"))
|
||||||
{
|
{
|
||||||
@@ -522,16 +522,16 @@ void put_page_refresh(int n)
|
|||||||
BUFFER html;
|
BUFFER html;
|
||||||
BUFFER buffer;
|
BUFFER buffer;
|
||||||
char* bp;
|
char* bp;
|
||||||
COUNTER* cp = (COUNTER*) sock_device(n);
|
DEVICE* device = (DEVICE*) sock_device(n);
|
||||||
|
|
||||||
int refresh;
|
int refresh;
|
||||||
#if 1
|
#if 1
|
||||||
{
|
{
|
||||||
refresh = (int) cntr_time_to_next_report(cp) + 1;
|
refresh = (int) device_time_to_next_report(device) + 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
PARAMETERS* pp = &cp->params;
|
PARAMETERS* pp = &device->params;
|
||||||
make_report(cp);
|
make_report(device);
|
||||||
refresh = (pp->poll_period * pp->sample_period * pp->report_period + 500) / 1000;
|
refresh = (pp->poll_period * pp->sample_period * pp->report_period + 500) / 1000;
|
||||||
#endif
|
#endif
|
||||||
if (refresh < MIN_REFRESH)
|
if (refresh < MIN_REFRESH)
|
||||||
@@ -572,19 +572,19 @@ void put_page_refresh(int n)
|
|||||||
void put_form_refresh(int n)
|
void put_form_refresh(int n)
|
||||||
{
|
{
|
||||||
dbg_printf(0, "put_form_refresh\n");
|
dbg_printf(0, "put_form_refresh\n");
|
||||||
|
DEVICE* device = (DEVICE*) sock_device(n);
|
||||||
BUFFER html;
|
BUFFER html;
|
||||||
BUFFER buffer;
|
BUFFER buffer;
|
||||||
char* bp;
|
char* bp;
|
||||||
COUNTER* cp = (COUNTER*) sock_device(n);
|
|
||||||
|
|
||||||
int refresh;
|
int refresh;
|
||||||
#if 1
|
#if 1
|
||||||
{
|
{
|
||||||
refresh = (int) cntr_time_to_next_report(cp) + 1;
|
refresh = (int) device_time_to_next_report(device) + 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
PARAMETERS* pp = &cp->params;
|
PARAMETERS* pp = &device->params;
|
||||||
make_report(cp);
|
make_report(device);
|
||||||
refresh = (pp->poll_period * pp->sample_period * pp->report_period + 500) / 1000;
|
refresh = (pp->poll_period * pp->sample_period * pp->report_period + 500) / 1000;
|
||||||
#endif
|
#endif
|
||||||
if (refresh < MIN_REFRESH)
|
if (refresh < MIN_REFRESH)
|
||||||
@@ -625,13 +625,13 @@ void put_form_refresh(int n)
|
|||||||
void process_command(int n, BUFFER* bp)
|
void process_command(int n, BUFFER* bp)
|
||||||
{
|
{
|
||||||
dbg_printf(0, "process_command(%d, %s)\n", n, bp->body);
|
dbg_printf(0, "process_command(%d, %s)\n", n, bp->body);
|
||||||
|
DEVICE* device = (DEVICE*) sock_device(n);
|
||||||
bool sics = false;
|
bool sics = false;
|
||||||
int error = 1;
|
int error = 1;
|
||||||
char command[80];
|
char command[80];
|
||||||
char param[80];
|
char param[80];
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char* tp = bp->body;
|
char* tp = bp->body;
|
||||||
COUNTER* cp = static_cast<COUNTER*>(sock_device(n));
|
|
||||||
while (isspace(*tp))
|
while (isspace(*tp))
|
||||||
++tp;
|
++tp;
|
||||||
len = 0;
|
len = 0;
|
||||||
@@ -659,13 +659,13 @@ void process_command(int n, BUFFER* bp)
|
|||||||
while (isspace(*tp))
|
while (isspace(*tp))
|
||||||
++tp;
|
++tp;
|
||||||
if (strcasecmp(command, "START") == 0)
|
if (strcasecmp(command, "START") == 0)
|
||||||
error = cntr_start(cp);
|
error = device_start(device);
|
||||||
else if (strcasecmp(command, "STOP") == 0)
|
else if (strcasecmp(command, "STOP") == 0)
|
||||||
error = cntr_stop(cp);
|
error = device_stop(device);
|
||||||
else if (strcasecmp(command, "PAUSE") == 0)
|
else if (strcasecmp(command, "PAUSE") == 0)
|
||||||
error = cntr_pause(cp);
|
error = device_pause(device);
|
||||||
else if (strcasecmp(command, "RESUME") == 0)
|
else if (strcasecmp(command, "RESUME") == 0)
|
||||||
error = cntr_resume(cp);
|
error = device_resume(device);
|
||||||
else if (strcasecmp(command, "REPORT") == 0)
|
else if (strcasecmp(command, "REPORT") == 0)
|
||||||
{
|
{
|
||||||
int match = 1;
|
int match = 1;
|
||||||
@@ -688,23 +688,23 @@ void process_command(int n, BUFFER* bp)
|
|||||||
{
|
{
|
||||||
/* set parameter */
|
/* set parameter */
|
||||||
dbg_printf(0, "SET %s\n", tp);
|
dbg_printf(0, "SET %s\n", tp);
|
||||||
if (param_set_cmd(&cp->params, tp))
|
if (param_set_cmd(&device->params, tp))
|
||||||
error = 0;
|
error = 0;
|
||||||
}
|
}
|
||||||
else if (strcasecmp(command, "GET") == 0)
|
else if (strcasecmp(command, "GET") == 0)
|
||||||
{
|
{
|
||||||
/* get parameter */
|
/* get parameter */
|
||||||
param_get_cmd(&cp->params, tp, n);
|
param_get_cmd(&device->params, tp, n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (strcasecmp(command, "READ") == 0)
|
else if (strcasecmp(command, "READ") == 0)
|
||||||
{
|
{
|
||||||
cntr_read(cp, n);
|
device_read(device, n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!sics)
|
else if (!sics)
|
||||||
{
|
{
|
||||||
cntr_send(cp, n);
|
device_send(device, n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ static struct param_command_t {
|
|||||||
{CMD_SOURCE, TXT_SOURCE},
|
{CMD_SOURCE, TXT_SOURCE},
|
||||||
{0, NULL}
|
{0, NULL}
|
||||||
};
|
};
|
||||||
#define NUM_CMDS ((int) (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)
|
static int name_to_command(char* name)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user