For testing purposes of my firmware of an ESP32 I would like to simulate the sensor it's communicating with through I2C. Therefore I'm trying to setup my Raspberry Pi 3B+ as an I2C Slave So it could generate the values the ESP32 is reading. I'm using the pigpio library with the bsc_isc/bsc_Xfer function for the handling of the protocol. Basic communication and writing data works great, but I'm running into sync issues while reading data (tested both in C and in Python) It seems like when I add data to the FiFo with the bsc_Xfer function upon the receiving event, I put the data ready for the next message. Basically it's running out of sync by 1 message. A solution that worked was sending the messsage twice from the master and only process the second message, but for final use I'm unable to change any firmware on the master side. Other solutions found online all used changes to the master.
Is it possible to answer a read request with the intended value? or do I always need to have the data ready in the FiFo for when this request turns up (making reading different registers almost impossible)