Slave code is very simple. Essentially, the slave first gets an event with the payload of the TX (up to three bytes - though I only send one). For the TXi, this sets the desired output that the Teletype wants to poll. Immediately after that the slave gets a request for a certain number of bytes (in this case, two) and returns the value for that input.
I was worried that there might be timing issues - but I’ve been able to pound the i2c bus requesting data from 8 different inputs and get really fast response rates (and the proper data) passing it through the Teletype and back out. Longer term it might make sense to cache the response for at least the length of a script to reduce redundant polling, but for now it seems to be working.
For most flexibility, the function would take an array for the the three packet.addr bytes and set the length based on how many the calling function was passing. I left it as-is for now.
Cheers!
b