DA-710 Series Linux
Programmer Guide
4-6
Example: DIO Program Source Code
File Name: tdio.c
Description: This program connects DO1 to DI1, changes the digital output state to high or low by manual input,
then detects and counts the state changed events from DI1.
#include <stdio.h>
#include <stdlib.h>
#ifdef NO_MOXADEVICE_HEADER
#include "moxadevice.h"
#else
#include <moxadevice.h>
#endif
#include <fcntl.h>
/* Due to hardware limitation, MIN_DURATION should be 60 for DA710 */
#define MIN_DURATION 40
static char *DataString[2]={"Low ", "High "};
static void hightolowevent(int diport)
{
printf("\nDIN port %d high to low.\n", diport);
}
static void lowtohighevent(int diport)
{
printf("\nDIN port %d low to high.\n", diport);
}
int main(int argc, char * argv[])
{
int i, j, state, retval;
unsigned long duration;
while( 1 ) {
printf("\nSelect a number of menu, other key to exit. \n\
1.set high to low event \n\
2.get now data. \n\
3.set low to high event \n\
4.clear event \n\
5.set high data. \n\
6.set low data. \n\
7. quit \n\