-
Notifications
You must be signed in to change notification settings - Fork 16
make TCA work for slaves with same address or even in general #38
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
Conversation
In order to route an i2c request to a connected slave, the tca itself has to make sure that the right path to the slave is set. There was no such thing in the code. If I am right, then without my code change, only one or no slave could be addressed... the reported bug one year ago sounds like suffering from this lack, too. I added this one line: "self.tca.i2c.writeto(self.tca.address, self.channel_switch)" before all requests (readfrom_into, writeto, and write_then_readfrom). With this, the TCA register will be set with the desired channel_switch. I do not know, whether this is thread safe. It might not... but without it, the TCA will not work at all. If so, please add it to the main branch. If am totally misunderstanding, then please just forget about this. In any case: Thank you for your time.
pretty sure thats what the lock/unlock part is doing - did you try the examples? |
Yep, it's taken care of with lock/unlock. Example should work. The current library sort of works automagically. The plumbing is not super obvious by just looking at the code. Here's the specific line that does the muxing:
But it requires the library code be written to use it. This general manual muxing need keeps coming up. Opened a related issue for this a while back: @ingenerd What are you using the TCA with? |
Ahhhh, I see. Okay - I created the problem;-) I do not understand all of the TCA code. The locking part is a little piece of magic to me. So in order to get my BMP180 going, I assume, I habe to integrate the locking mechanism into my code. If possible, could you please push me into the right direction, where I have to look for orientation? |
You don't need to directly lock / unlock in your driver code. Instead, use a context manager (the If you write your driver code like that, and then also pass in a TCA channel (not the TCA itself), like this: bmp = BMP180(tca[0]) then it should work. The context manager calls the dunder methods TLDR = you should be able to get this to work with some minor changes to your driver code |
@caternuson Tanks. I got it. Very minor changes indeed in my code do the trick. Excellent. Thank you very much for everything. |
In order to route an i2c request to a connected slave, the tca itself has to make sure that the right path to the slave is set. There was no such thing in the code. If I am right, then without my code change, only one or no slave could be addressed... the reported bug one year ago sounds like suffering from this lack, too.
I added this one line: "self.tca.i2c.writeto(self.tca.address, self.channel_switch)" before all requests (readfrom_into, writeto, and write_then_readfrom). With this, the TCA register will be set with the desired channel_switch. I do not know, whether this is thread safe. It might not... but without it, the TCA will not work at all. If so, please add it to the main branch. If am totally misunderstanding, then please just forget about this. In any case: Thank you for your time.