<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>It seems that it is indeed a Wire library issue as it doesn't
      play nice with Teensy 3.x. In <a moz-do-not-send="true"
href="https://forum.pjrc.com/threads/60734-I2C-Slave-on-T3-6-receiving-all-messages-after-first-match?highlight=i2c_t3+teensy">this
        thread</a> from the Teensy forum it is mentioned that the same
      issue with mine appeared and switching to i2c_t3 lib solves it.</p>
    <p>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).</p>
    <p>Thanks again!<br>
    </p>
    <div class="moz-cite-prefix">On 24/9/20 6:27 μ.μ., Martin Peach
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAN5xZ3ZU6o7Qs513C1XnUGV1K5195JBmxK=8Zs8RXDmMOcz0bw@mail.gmail.com">
      <pre class="moz-quote-pre" wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:chakekatzil@gmail.com"><chakekatzil@gmail.com></a> wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
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:
<a class="moz-txt-link-freetext" href="https://github.com/nox771/i2c_t3">https://github.com/nox771/i2c_t3</a>
But I'll try your code later and see what I get.

Martin

On Wed, Sep 23, 2020 at 3:40 AM Alexandros <a class="moz-txt-link-rfc2396E" href="mailto:adrcki@gmail.com"><adrcki@gmail.com></a> wrote:
</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">
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:
</pre>
          <blockquote type="cite">
            <pre class="moz-quote-pre" wrap="">On Thu, Sep 10, 2020 at 2:25 PM Alexandros <a class="moz-txt-link-rfc2396E" href="mailto:adrcki@gmail.com"><adrcki@gmail.com></a> wrote:
</pre>
            <blockquote type="cite">
              <pre class="moz-quote-pre" wrap="">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]


</pre>
            </blockquote>
            <pre class="moz-quote-pre" wrap="">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
<a class="moz-txt-link-freetext" href="https://github.com/nox771/i2c_t3">https://github.com/nox771/i2c_t3</a>) 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
</pre>
          </blockquote>
        </blockquote>
      </blockquote>
    </blockquote>
  </body>
</html>