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

Function openPortNative

src/test/c/testEventsWindows.c:133–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void* openPortNative(const char *portName)
134{
135 // Try to open the serial port with read/write access
136 void *portHandle = CreateFileA(portName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_OVERLAPPED, NULL);
137 if (portHandle != INVALID_HANDLE_VALUE)
138 {
139 // Configure the port parameters and timeouts
140 if (!configPort(portHandle))
141 {
142 // Close the port if there was a problem setting the parameters
143 PurgeComm(portHandle, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR);
144 if (CancelIoEx)
145 CancelIoEx(portHandle, NULL);
146 SetCommMask(portHandle, 0);
147 CloseHandle(portHandle);
148 portHandle = INVALID_HANDLE_VALUE;
149 }
150 }
151 return portHandle;
152}
153
154void closePortNative(void *portHandle)
155{

Callers 1

mainFunction · 0.70

Calls 1

configPortFunction · 0.70

Tested by

no test coverage detected