nanoframework / Home

:house: The landing page for .NET nanoFramework repositories.
https://www.nanoframework.net
MIT License
861 stars 79 forks source link

NanoDeviceOperations.Dispose() breaks functionality of subsequent NanoDeviceOperations instantiations #1460

Closed aburns-skwks closed 5 months ago

aburns-skwks commented 6 months ago

Tool

nanoff

Description

Calling Dispose() on an instance of NanoDeviceOperations(NDO) causes subsequent instantiations of NDO to fail when calling ListDevices(). I have one board with a Gecko MCU connected via USB on COM port 3; calling ListDevices() once will return a 1 as expected but after the first NDO instance has been closed and a second one instantiated ListDevices() takes significantly longer to return and returns a 0.

How to reproduce

A solution that reproduces the issue can be found at: https://github.com/Skyworks-Timing-Software/publicNanoframeworkSamples/tree/main/NanoFFNanoDeviceOperationsDisposeBug. The code being called can be found in the screenshot below: image

Expected behaviour

NDO instance B's functionality should not be affected by calling Dispose() on instance A prior to instance B's creation. With the solution provided above, calling ListDevices() should return 1 both times instead of 1 then 0.

Screenshots

No response

Aditional context

NuGet packages installed:

image
aburns-skwks commented 5 months ago

Played around with this a tiny bit more. I found that this bug is not exercised if ListDevices(false) is called. Calling it with getDeviceDetails == true does still trigger the issue, however.