diff --git a/meshtastic.c b/meshtastic.c index 0c3a436..84928ec 100644 --- a/meshtastic.c +++ b/meshtastic.c @@ -117,7 +117,7 @@ int mt_connect(MeshtasticAccount *mta, char *port, enum connection_type type) // Configure read and write operations to time out after 100 ms. COMMTIMEOUTS timeouts = {0}; - timeouts.ReadIntervalTimeout = 10; + timeouts.ReadIntervalTimeout = MAXDWORD; timeouts.ReadTotalTimeoutConstant = 0; timeouts.ReadTotalTimeoutMultiplier = 0; timeouts.WriteTotalTimeoutConstant = 10; @@ -143,6 +143,13 @@ int mt_connect(MeshtasticAccount *mta, char *port, enum connection_type type) CloseHandle(mta->handle); return 1; } + success = FlushFileBuffers(mta->handle); + if (!success) + { + purple_debug_error(PROTO_NAME, "Failed to flush handle buffers\n"); + CloseHandle(mta->handle); + return 1; + } mta->mt_handle_timeout = purple_timeout_add(100, (GSourceFunc)mt_read_handle, mta); return 0; #endif