Before I test this, I notice you use Wire for the i2c slaves. Wire is known to not work properly in slave mode. I use this library for teensy i2c, it works very well: https://github.com/nox771/i2c_t3 But I'll try your code later and see what I get.
Martin On Wed, Sep 23, 2020 at 3:40 AM Alexandros <[email protected]> wrote: > > Sorry for coming back to this thread after so long, didn't have a Pi at > hand. I have attached a very simple patch which reproduces the bug. > You'll need to connect two I2C slave Teensy LC to the Pi. I have also > attached the two Arduino files that should be loaded to the Teensies. > > What happens with this setup is that the Teensy that listens to 0x09 > (i2c_mess2.ino file) receives messages even when something is sent to > 0x0A. The Teensy that listens to 0x0A (i2c_mess1.ino file) doesn't seem > to be receiving anything. > > One Teensy prints to the serial console and the other responds by > lighting up and turning off the LED on pin 13. > > On 12/9/20 11:02 μ.μ., Martin Peach wrote: > > On Thu, Sep 10, 2020 at 2:25 PM Alexandros <[email protected]> wrote: > >> When trying to send messages to two I2C slaves from the Pi with [pii2c] > >> the following happens: > >> > >> If I send this message to [pii2c 0x0A]: > >> "write 3 127 7" > >> > >> it arrives properly at the slave address 0x0A. > >> > >> If I change the address to 0x09 with the message "addr 0x09" and then > >> send this message: > >> "write 97" > >> > >> then both messages will be sent to the respective slaves, meaning that > >> "3 127 7" will be sent to slave 0x0A and "97" to slave 0x09. If I then > >> change the message sent to 0x09 to "98", this will be sent to 0x09, but > >> again "3 127 7" will be sent to 0x0A. If I resend "3 127 7" to 0x0A, > >> "98" (the last message set to 0x09) will be sent to 0x09 as well. > >> > >> The same behavior occurs when I send the message "write 0x09 98". The > >> same behavior also occurs if I use two different [pii2c] objects, like > >> this: > >> > >> [write 3 127 7( > >> | > >> [pii2c 0x0A] > >> > >> [write 97( > >> | > >> [pii2c 0x09] > >> > >> > > Hmmm I don't get this. Do you have a patch that will reproduce the bug? > > (I am also able to send messages longer than 32 bytes, with > > MAX_I2C_BUF_SIZE 64 in my copy of pii2c.c.) > > I used a teeny 3.2 as a slave (using i2c_t3 from > > https://github.com/nox771/i2c_t3) listening on all addresses. It only > > receives the messages on the addresses I set in the Pd patch. > > > > Perhaps you have a hidden [pii2c 0x0A] somewhere that is also > > receiving your write messages. > > Since [pii2c] is using the same memory space for each message any new > > message will effectively erase the old ones, so it's hard to explain > > two different messages coming from a single object. > > > > Martin _______________________________________________ [email protected] mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
