Moxa IA261-I-LX [64/71] Digital i o

Moxa IA261-I-LX [64/71] Digital i o
IA260/IA261/IA262/EM-2260 Linux User’s Manual Programmer’s Guide
$(STRIP) $(TARGET)-release $(TARGET1)-release
clean:
rm -f *.o $(TARGET)-debug $(TARGET)-release $(TARGET1)-debug $(TARGET1)-release
Digital I/O
Digital Output channels can be set to high or low. The channels are controlled by the function call
set_dout_state( ). The digital input channels can be used to detect the state change of the digital
input signal. The DI channels can also be used to detect whether or not the state of a digital signal
changes during a fixed period of time. This can be done by the function call, set_din_event( ).
Moxa provides 5 function calls to handle the digital I/O state change and event handling.
Application Programming Interface
Return error code definitions:
#define DIO_ERROR_PORT -1 // no such port
#define DIO_ERROR_MODE -2 // no such mode or state
#define DIO_ERROR_CONTROL -3 // open or ioctl fail
#define DIO_ERROR_DURATION -4 // The value of duration is not 0 or not in the range, 40
<= duration <= 3600000 milliseconds (1 hour)
#define DIO_ERROR_DURATION_20MS -5 // The value of duration must be a multiple of 20
ms
#define DIO_OK 0
The definition for DIN and DOUT:
#define DIO_HIGH 1
#define DIO_LOW 0
int set_dout_state(int doport, int state)
Description: To set the DOUT port to high or low state.
Input: int doport - which DOUT port you want to set. Port starts from 0 to 3.
int state - to set high or low state; DIO_HIGH (1) for high, DIO_LOW (0) for low.
Output: none.
Return: reference the error code.
int get_din_state(int diport, int *state)
Description: To get the DIN port state.
Input: int diport - get the current state of which DIN port. Port numbering is from 0 to 3.
int *state - save the current state.
Output: state - DIO_HIGH (1) for high, DIO_LOW (0) for low.
Return: reference the error code.
int get_dout_state(int doport, int *state)
6-8

Содержание

Похожие устройства

Скачать