TWI/I2C address verification

Not sure if this is the correct forum or should be in programming. Try here first so as to not cross post.

Setting device as TWI slave and enabling TWGCE means that the slave receives messages posted to its ID as well as any General Call message. My question, is there any way of knowing whether the received message was one or the other?

I want my slaves to have a priority in responding to a general call and not reply immediately in lieu of a response from a higher prioritized unit.

dkw

DKWatson:
Not sure if this is the correct forum or should be in programming. Try here first so as to not cross post.

Setting device as TWI slave and enabling TWGCE means that the slave receives messages posted to its ID as well as any General Call message. My question, is there any way of knowing whether the received message was one or the other?

I want my slaves to have a priority in responding to a general call and not reply immediately in lieu of a response from a higher prioritized unit.

dkw

To utilize General Call YOU are going to have to modify Wire.h library. Currently it does differentiate General Call and Slave Address data.

Look at ISR(TWI_vect) in C:\Program Files\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c

TW_SR_DATA_ACK, TW_SR_GCALL_DATA_ACK are combined into the same Switch() case. You will have to modify it to either support a different event callback or something.

Chuck.

Thanks Chuck. I decided to packetize the data and then use the dest_addr to differentiate. In the end I've tossed TWI/I2C in favour of RS485. Too much susceptibility to noise with the former. In any event, need to plan for longer distances than a meter.

Wrote a peer-to-peer protocol with CRC and ACK/NAK that works real well. It's on my GitHub page if anybody is interested.