Maixpy i2c communication

I get an error on my master device, a Raspberry Pi, when i do multiple reads from my slave device, a Sipeed M1W. Has anyone else encountered this or has working code for the slave side? Mine looks like this:

from machine import I2C
import time

i = -1
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]

def on_receive (data):
print (“on_receive:”, data)

def on_transmit ():
global i, data
i += 1
print (“on_transmit, send:”, data[i])
return data[i]

def on_event (event):
print (“on_event:”, event)

i2c = I2C (I2C.I2C0, mode = I2C.MODE_SLAVE, scl = 40, sda = 41, addr = 0x60, addr_size = 7, on_receive = on_receive, on_transmit = on_transmit, on_event = on_event)

while True:

The code for the RPi is following:
import smbus
import time

channel = 1
address = 0x60
bus = smbus.SMBus(channel)

for i in range (15):

The first 5, or 6 reads work properly but then i recieve:
IOError: [Errno 5] Input/output error

Could it be that you have declared ‘data’ as a global variable in the on_transmit function and also using ‘data’ as a local variable in the on_receive function. Try changing the on_recieve data variable name.

I too have been having some trouble with this routine and I had to initiallise the i2c before it would work with the maix bit device. The global variables also presented problems.

Also, are the i2c logic voltage levels the same for the two devices?