Code: Select all
import usocket
buf = bytearray(64)
#...
socket = usocket.socket(*addrinfo[:3])
socket.connect(addrinfo[-1])
#...
socket.write('{0} /{1} HTTP/1.0\r\n'.format(method, path))
socket.write('Host: {0}\r\n'.format(host))
socket.write('\r\n')
#... fill buf with eeprom data...
socket.write(buf)
Problem is data can exceed 64 bytes -- the eeprom is 8kbytes and teoretically I could have the need to send thm all -- and I would like to write all data to the same socket reusing the same buffer over and over.
I tried with an iterator, only the first buffer is sent, following socket.write are lost
Code: Select all
def ipayload(self, buf):
size = len(buf)
for memaddr in range(self.__head_pointer, self.__tail_pointer, size):
self.read_into(memaddr, buf)
yield min(self.__tail_pointer - memaddr, size)
#...
for c in eeprom.ipayload(buf):
socket.write(buf)