MCPcopy Create free account
hub / github.com/Fazecast/jSerialComm / closePortNative

Function closePortNative

src/test/c/testEventsWindows.c:154–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void closePortNative(void *portHandle)
155{
156 // Force the port to enter non-blocking mode to ensure that any current reads return
157 COMMTIMEOUTS timeouts;
158 memset(&timeouts, 0, sizeof(COMMTIMEOUTS));
159 timeouts.WriteTotalTimeoutMultiplier = 0;
160 timeouts.ReadIntervalTimeout = MAXDWORD;
161 timeouts.ReadTotalTimeoutMultiplier = 0;
162 timeouts.ReadTotalTimeoutConstant = 0;
163 timeouts.WriteTotalTimeoutConstant = 0;
164 SetCommTimeouts(portHandle, &timeouts);
165
166 // Purge any outstanding port operations
167 PurgeComm(portHandle, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR);
168 if (CancelIoEx)
169 CancelIoEx(portHandle, NULL);
170 SetCommMask(portHandle, 0);
171
172 // Close the port
173 if (!CloseHandle(portHandle))
174 printf("Error Line = %d, Code = %d\n", __LINE__ - 1, GetLastError());
175}
176
177int waitForEvent(void *portHandle)
178{

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected