diff --git a/Source/v2/Meadow.Hcom/Connections/SerialConnection.ListenerProc.cs b/Source/v2/Meadow.Hcom/Connections/SerialConnection.ListenerProc.cs index 8da21441..56f76937 100644 --- a/Source/v2/Meadow.Hcom/Connections/SerialConnection.ListenerProc.cs +++ b/Source/v2/Meadow.Hcom/Connections/SerialConnection.ListenerProc.cs @@ -223,7 +223,7 @@ private async Task ListenerProc() // When the F7 has finished sending the data it will send a // HCOM_HOST_REQUEST_UPLOAD_FILE_COMPLETED message. When it is received // we then close the open file and the process is completed. - var folder = Path.GetDirectoryName(_readFileInfo.LocalFileName); + var folder = Path.GetDirectoryName(_readFileInfo!.LocalFileName); if (!Directory.Exists(folder)) throw new DirectoryNotFoundException(folder); _readFileInfo.FileStream = File.Create(_readFileInfo.LocalFileName); @@ -276,7 +276,7 @@ private async Task ListenerProc() } else { - Debug.WriteLine($"{response.GetType().Name} for:{response.RequestType}"); + Debug.WriteLine($"{response?.GetType().Name} for:{response?.RequestType}"); // try to match responses with the requests } } diff --git a/Source/v2/Meadow.Hcom/Connections/SerialConnection.cs b/Source/v2/Meadow.Hcom/Connections/SerialConnection.cs index cbdab95a..15854eda 100644 --- a/Source/v2/Meadow.Hcom/Connections/SerialConnection.cs +++ b/Source/v2/Meadow.Hcom/Connections/SerialConnection.cs @@ -890,6 +890,8 @@ public override async Task WriteCoprocessorFile( try { + RaiseConnectionMessage("\nTransferring file to coprocessor..."); + // push the file to the device await WriteFile(localFileName, null, RequestType.HCOM_MDOW_REQUEST_START_ESP_FILE_TRANSFER, @@ -897,25 +899,12 @@ await WriteFile(localFileName, null, destinationAddress, cancellationToken); - RaiseConnectionMessage("\nTransferring file to coprocessor..."); - - // now wait for the STM32 to finish writing to the ESP32 - return await WaitForResult(() => - { - if (InfoMessages.Count != infoCount) - { - infoCount = InfoMessages.Count; - RaiseConnectionMessage(InfoMessages.Last()); - } - if (_lastRequestConcluded != null) - { - return true; - } + _lastRequestConcluded = null; - return false; - }, - cancellationToken); + // now wait for the STM32 to finish writing to the ESP32 + await WaitForConcluded(null, cancellationToken); + return true; } finally {