ReadInputByte
Reads a byte from an input of a real or simulated I/O module.
Syntax
KsError ReadInputByte(
int Index,
int ByteOffset,
BYTE* Value
);
Parameters
Index: the index of an I/O module. Indexes are zero based. Aliases affect this parameter.
ByteOffset: specifies a byte offset to the location to read a BYTE value. The max offset is determined by InputLength in the SlaveStatus structure.
Value: pointer to the value that will receive the BYTE read.
Return value
If the function succeeds, it returns errNoError
, otherwise an error code. For more information about the error code, see the KsError list.
Remarks
ReadInputByte can only be called once a link is established and started.
Usable EtherCAT states
ecatOP
Example
VOID PrintAllInputs(INT Index) {
SlaveStatus moduleStatus = { 0 };
int nRet = GetIOByIndex(Index, &moduleStatus);
RtPrintf("Device %d Input Bit Length %d, Inputs 0x", Index, moduleStatus.InputLength);
for (int i = 0; i < ceil((float)moduleStatus.InputLength / 8); i++) {
BYTE value = 0;
nRet = ReadInputByte(Index, i, &value);
RtPrintf("%02x", (value & 0xFF));
}
RtPrintf("\n", nRet);
}
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksapi.h | ksapi.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also