DioReadInputState

Applies To

GX5055, GX5295

Purpose

Reads a block of output memory from the specified board (Master or Slave).

Syntax

DioReadInputState (nHandle, nChannel, pnState, pnStatus)

Parameters

Name
Type
Comments
nHandle
SHORT
DIO or File board handle.
nChannel
SHORT
Specified channel in the DIO domain, channel can be between 0 to the last channel number in the domain. E.g. if the domain has two DIO boards, then the channel range is 0-63.
GX5295:
Auxiliary channels (Master only): DIO_AUX_CHANNEL_0 (1000) to DIO_AUX_CHANNEL_3 (1003).
pnState
PSHORT
Reads the channel's input state:
 0=Input signal is lower than low and high threshold value.
-1=Input signal is between the low and high threshold value (invalid signal level).
 1=Input signal is above the low and high threshold value.
pnStatus
PSHORT
Returned status: 0 on success, negative number on failure.

Comments

The function can be called at any point, even while the DIO domain is running.

Note: It is recommended to use this function in order to read the channels’ input states rather than using DioReadIOPinsValue and  DioReadIOPinsValidity APIs.

Example

The following example reads the input of channel 0 and print out the channel’s state:

 

SHORT nStatus;

SHORT nState;

DioReadInputState (nHandle, 0, &nState, &nStatus);

if (nState==0)

    printf (“Channel 0 input is valid logic low”);

else if (nState==-1)

    printf (“Channel 0 input is invalid”);

else if (nState==1)

    printf (“Channel 0 input is valid logic high”);

 

See Also

DioWriteIOPinsValue, DioReadIOPinsValidity, DioSetupIOConfiguration, DioGetIOConfiguration, DioGetErrorString