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

multiple i2c_open() calls for same I2C port/address returns valid handles - should be single valid handle for each I2C Port/Address #10

Closed
PSkeberdis opened this issue Aug 5, 2021 · 2 comments

Comments

@PSkeberdis
Copy link

Expecting that the first i2c_open for s specific port/address would provide a valid handle, but that a second i2c_open for the same port/address without a close would not provide a valid handle.

First instance of program run well, then second instance stomps the first instance as it also receives a valid handle.

Am testing on Pi4B+ running Ubuntu 21.04:
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute

Code snippet from lcd_i2c.py:
...
import lgpio
import time
from RPLCD.i2c import CharLCD

from datetime import datetime

address = 0x27

cols = 20
rows = 4

lcd = CharLCD(i2c_expander='PCF8574', address=address, port=1,
cols=cols, rows=rows,
charmap='A02', # A00, A02 or ST0B
backlight_enabled=True)
...

Fix would be to only issue a valid handle for I2C Port/address if a current handle for the same I2C Port/Address did not exist.

@PSkeberdis PSkeberdis changed the title multiple i2c_open for same port/address returns validate handles multiple i2c_open for same port/address returns valid handles - should be single valid handle for each I2C Port/Address Aug 5, 2021
@PSkeberdis PSkeberdis changed the title multiple i2c_open for same port/address returns valid handles - should be single valid handle for each I2C Port/Address multiple i2c_open() calls for same I2C port/address returns valid handles - should be single valid handle for each I2C Port/Address Aug 5, 2021
@joan2937
Copy link
Owner

joan2937 commented Aug 5, 2021

That is by design. If the underlying operating system is happy to have the same device opened multiple times then so is lg.

@PSkeberdis
Copy link
Author

PSkeberdis commented Aug 8, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants