Du kan bruge dette til at vente på CTS:
#include <stdio.h>
#include <windows.h>
int main(void)
{
DCB dcb;
HANDLE ComPort = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
GetCommState(ComPort, &dcb);
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.fRtsControl = RTS_CONTROL_ENABLE;
dcb.fErrorChar = TRUE;
dcb.fParity = TRUE;
dcb.Parity = ODDPARITY;
dcb.fAbortOnError = TRUE;
dcb.fOutxCtsFlow = 1;
SetCommState(ComPort, &dcb);
SetCommMask(ComPort, EV_CTS);
DWORD Event;
while(1)
{
WaitCommEvent(ComPort, &Event, 0);
printf("%08X\n", Event);
}
CloseHandle(ComPort);
return 0;
}
Du kan bruge GetCommState til at læse om porten er høj eller lav.