WriteOutputByte
Writes a byte into an output of a real or simulated I/O module.
Syntax
KsError WriteOutputByte(
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 write a BYTE value. The max offset is determined by OutputLength in the SlaveStatus structure.
Value: a BYTE value to write.
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
WriteOutputByte can only be called once a link is established and started.
Usable EtherCAT states
ecatOP
Example
VOID EnableAllOutputs(INT Index) {
SlaveStatus moduleStatus = { 0 };
int nRet = GetIOByIndex(Index, &moduleStatus);
RtPrintf("Device %d Output Bit Length %d\n", Index, moduleStatus.OutputLength);
for (int i = 0; i < ceil((float)moduleStatus.OutputLength / 8); i++) {
BYTE value = 0xFF;
nRet = WriteOutputByte(Index, i, value);
}
}
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksapi.h | ksapi.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also