@adamg thanks! I have this running right now as well, seems like all the slave function codes work.
The only thing that I found a bit confusing is that in the slave, the Modbus data address offset isn’t implemented (if it were, coils 0000-270E would map to memory locations 1-9999). Consequently, in the slave input data array (au16data) there’s no distinguishing what type of data (coil, register, etc) each memory location holds, and leaves it up to the master to know what kind of data is where.
Whats also a little confusing is that the address of discrete inputs and coils are mapped to bits in the input data array, such that coils 1-16 map to bits 0-15 of au16data, 17-32 map to bits 0-15 of au16data, and so on. As a result, you could write 7 to register 0, and read it either as holding register 0 = 8, or coil 4 = 1 and coil 3 = 1.
Not a big deal for me, since I’m mostly interested in the master, but would probably be worth implementing (I might do it if I have time)