kplindegaard / smbus2

A drop-in replacement for smbus-cffi/smbus-python in pure Python
MIT License
243 stars 68 forks source link

Handle re-opening a closed bus #107

Closed henrik-nil-acc closed 6 months ago

henrik-nil-acc commented 7 months ago

Set address and _force_last to their initial values to be able to handle an open -> close -> open sequence.

sonarcloud[bot] commented 7 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

kplindegaard commented 6 months ago

Hi @henrik-nil-acc. Just so I understand what the intent is: You want to keep the SMBus object alive also after a close(), I presume. Later, you open the bus again. Is it potential lack of setting the address on after subsequent open() call that causes problems for you?

henrik-nil-acc commented 6 months ago

@kplindegaard, correct. I'm thinking it's a valid use-case and from the existing code in close() it looks like it might been intended to be supported since self._pec is set to it's initial value.

kplindegaard commented 6 months ago

Fair point, thanks.

kplindegaard commented 6 months ago

@henrik-nil-acc I'm on holiday but will make a new patch version soon.