You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry but I never received any notification on this issue.
Do you still have the problem?
I think you should be able to use get the last address as switch (WireSim.lastAddress()) {
on the receiveEvent method too. Then you will know to which slave the data is intended to go.
I cannot try it myself since I have no Arduino with me right know but you can try it and let me know about the result. If it does not work I will find a solution.
Cheers
I noticed the same problem when testing this library. The problem is that TWDR gets overwritten by the time receiveEvent() is called. So in my case WireSim.lastAddress() returned the byte that was written to the slave address instead of the address.
I managed to work around it by modifying twi.c to store the address right after it's received:
This file is located in an Arduino related include folder. On MacOs it's probably ~/Library/Arduino15/packages/arduino/hardware/avr/1.8.1/libraries/Wire/src/utility/twi.c
After the line static volatile uint8_t twi_rxBufferIndex;
volatile int lastAddr = -1;
After the line case TW_ST_SLA_ACK:
lastAddr = TWDR >> 1;
After the line case TW_SR_SLA_ACK:
lastAddr = TWDR >> 1;
Then in my sketch I have extern volatile int lastAddr;. Hacky solution, but it works.
This is great but there seems to be one thing missing, or at least I'm not seeing it.
switch (WireSim.lastAddress()) {
Lets you test for the incoming request address, but where is the equivalent to determine the incoming address for simple writes?
Seems like that would be needed to emulating multiple devices requiring initialization or any sort of output.
thx
The text was updated successfully, but these errors were encountered: