Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft232H I2C Create Device always returns 'Device already open' #2094

Closed
gjnijenhuis opened this issue Jul 4, 2023 · 0 comments · Fixed by #2095
Closed

Ft232H I2C Create Device always returns 'Device already open' #2094

gjnijenhuis opened this issue Jul 4, 2023 · 0 comments · Fixed by #2095

Comments

@gjnijenhuis
Copy link
Contributor

I'm unable to create an I2C device using the Ft232H device. It always returns 'Device already open'.
Even running the sample code returns this issue.

Looking through the code I found this line of code:

if (!_usedAddresses.ContainsKey(deviceAddress))
{
throw new ArgumentException($"Device with address 0x{deviceAddress,0X2} is already open.", nameof(deviceAddress));
}

This checks if the device is already in the used addresses list, and if not in the list it will throw the error.
This is the wrong way around. The error should be thrown when the device is in the list, not when it is not in the list.
Inverting the check makes the samples run fine again.

@ghost ghost added the untriaged label Jul 4, 2023
gjnijenhuis pushed a commit to gjnijenhuis/iot that referenced this issue Jul 4, 2023
@krwq krwq closed this as completed in #2095 Jul 8, 2023
krwq pushed a commit that referenced this issue Jul 8, 2023
…#2095)

As per issue #2094

Co-authored-by: Gido Nijenhuis <g-nijenhuis@sensata.com>
@ghost ghost added the Status: Fixed label Jul 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant