Skip to content

Commit

Permalink
tighten up coprocessor write
Browse files Browse the repository at this point in the history
  • Loading branch information
ctacke authored and CartBlanche committed Sep 29, 2023
1 parent 7af0825 commit d5f0605
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
}
Expand Down
23 changes: 6 additions & 17 deletions Source/v2/Meadow.Hcom/Connections/SerialConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -890,32 +890,21 @@ public override async Task<bool> 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,
RequestType.HCOM_MDOW_REQUEST_END_ESP_FILE_TRANSFER,
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
{
Expand Down

0 comments on commit d5f0605

Please sign in to comment.