pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
196 stars 167 forks source link

AttributeError: 'socket' object has no attribute 'readinto' #610

Open rroeber opened 1 year ago

rroeber commented 1 year ago

Board: fipy

Firmware info:

(sysname='FiPy', nodename='FiPy', release='1.20.2.r6', version='v1.11-c5a0a97 on 2021-10-28', machine='FiPy with ESP32', lorawan='1.0.2', sigfox='1.0.1', pybytes='1.7.1')

I implemented a function to read data from a socket connection into a buffer. The relevant code is:

s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) 

buf = bytearray(NUM_PACKETS)
mv = memoryview(buf)

idx = 0
while idx < num_packets:
    bytes_read = s.readinto(mv[idx:])
    idx += bytes_read
    print('.', end='')

The s.send() and s.receive() functions elsewhere in my program work correctly. When the program executes the s.readinto() function it gives the error: AttributeError: 'socket' object has no attribute 'readinto'

What do I need to do to correct the error? Thanks.