[PD] [pii2c] keeps and resends previous messages when addresses change

Alexandros adrcki at gmail.com
Thu Oct 1 18:56:41 CEST 2020


It seems that it is indeed a Wire library issue as it doesn't play nice
with Teensy 3.x. In this thread
<https://forum.pjrc.com/threads/60734-I2C-Slave-on-T3-6-receiving-all-messages-after-first-match?highlight=i2c_t3+teensy>
from the Teensy forum it is mentioned that the same issue with mine
appeared and switching to i2c_t3 lib solves it.

As I wrote to you personally, I didn't check your code as I don't have a
Teensy 3.x at hand, but from your message and the thread I posted above
it seems that i2c_t3 is the solution (for the list, Martin's code uses
i2c_t3 instead of Wire).

Thanks again!

On 24/9/20 6:27 μ.μ., Martin Peach wrote:
> I uploaded a new version of [pii2c] yesterday via deken. It has some
> slight changes, (mainly adding optional address to the read message).
> I still don't get the double sends. I attach my code for teensy that
> listens on all the addresses. When I try your patch with it, the
> teensy only receives on the intended address. If I do 'i2cdetect -y 1'
> in the terminal it receives on all addresses 0x03-0x77.
>
> Martin
>
>
> On Wed, Sep 23, 2020 at 11:49 AM Martin Peach <chakekatzil at gmail.com> wrote:
>> 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 <adrcki at gmail.com> 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 <adrcki at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20201001/9815de72/attachment-0001.html>


More information about the Pd-list mailing list