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

Function main

src/test/c/testEventsWindows.c:252–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252int main(int argc, char *argv[])
253{
254 // Check for correct input parameters
255 if (argc != 2)
256 {
257 printf("USAGE: ./testEventsWindows [PORT_FILE_NAME]\n");
258 return -1;
259 }
260
261 // Open the serial port
262 void *portHandle = INVALID_HANDLE_VALUE;
263 if ((portHandle = openPortNative(argv[1])) == INVALID_HANDLE_VALUE)
264 {
265 printf("ERROR: Could not open port: %s\n", argv[1]);
266 return -2;
267 }
268 printf("Port opened\n");
269
270 // Wait forever for incoming events
271 int events = 0;
272 while ((events & com_fazecast_jSerialComm_SerialPort_LISTENING_EVENT_PORT_DISCONNECTED) == 0)
273 {
274 events = waitForEvent(portHandle);
275 printf("Received Events: %d\n", events);
276 if (events & com_fazecast_jSerialComm_SerialPort_LISTENING_EVENT_PORT_DISCONNECTED)
277 printf(" Including LISTENING_EVENT_PORT_DISCONNECTED\n");
278 if (events & com_fazecast_jSerialComm_SerialPort_LISTENING_EVENT_DATA_AVAILABLE)
279 printf(" Including LISTENING_EVENT_DATA_AVAILABLE\n");
280 if (events & com_fazecast_jSerialComm_SerialPort_LISTENING_EVENT_DATA_WRITTEN)
281 printf(" Including LISTENING_EVENT_DATA_WRITTEN\n");
282 }
283
284 // Close the serial port
285 closePortNative(portHandle);
286 return 0;
287}

Callers

nothing calls this directly

Calls 3

openPortNativeFunction · 0.70
waitForEventFunction · 0.70
closePortNativeFunction · 0.70

Tested by

no test coverage detected