Moxa V2426A-C7 [34/88] Counter

Moxa V2426A-C2 [34/88] Counter
V2400A Series Expansion Modules Software Installation and Programming Guide
4-14
}
if (digit_io_timer_add_callback(mngr, HWIndex, port, DGTIO_GET_OUTPUT, interval,
output_get_cb, &port) < 0) {
printf("add %d get output callback error\n", port);
return -5;
}
}
}
digit_io_timer_dispatch(mngr);
return 0;
}
Example 2: (Reading the EPM-3438 Counter Value and Clearing the
Counter)
Folder and file: /examples/ExpansionCard/LX/EPM3438/digit_input_change/tcounter.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include “mxdgio.h” // For counter reading or clear
#define COUNTER_NODE1 "/dev/epm_3438_counter1" // The first EPM-3438
#define COUNTER_NODE2 "/dev/epm_3438_counter2" // The second EPM-3438
int main(int argc, char * argv[])
{
int retval;
int fd, fd2, len;
unsigned int counter_value;
fd=open(COUNTER_NODE1, O_RDONLY);
while( 1 ) {
printf("\nSelect a number of menu, other key to exit. \n\
1. Get counter value \n\
2. Clear the counter \n\
Others. quit \n\
Choose : ");
scanf("%d", &retval);
if ( retval == 1 ) { // Get counter without reset
counter_value = mxdgio_epm3438_get_counter(fd);
printf("EPM-3438 board #1 counter:%d\n", counter_value);
}
else if ( retval == 2 ) { // Get counter with reset
retval = mxdgio_epm3438_clear_counter(fd);
if ( retval < 0 )
printf("EPM-3438 board #1 counter reset fail\n");
}
else {
break;
}
}
close(fd);
return 0;

Содержание

Скачать