Reading pin value via I2C

Hi, i have established I2C communication between my 2 arduino boards. Can anyone suggest an algorithm or library for a master to read a slave arduino pin value? Thanks!

You have to define a protocol, sounds more difficult than you think but is less difficult if you think ;)

Let the master send the string "DRnn" meaning do a digitalRead of pin nn. The slave responds 0 or 1

analogRead ==> "ARpp" pp = pin The slave returns an int (2 bytes)

digitalWrite ==> "DWpp v" pp = pin v=0/1 ... H or L can also be used The slave returns OK

analogWrite ==> AWpp vvv pin value Slave returns OK

eepromWrite ==> EWaaa vvv address value Slave returns OK

eepromRead ==> ERaaa Slave returns vvv

etc.

got the idea?