I am using the code below trying to receive all the data from I socket. When I send the SCPI command "FETCh?\\n" to the device, it returns a large amount of data, and the recv() function only returns part of it.
Does anyone know how to solve this problem? Thanks in advance!
class SCPI:
PORT = 5025
def __init__(self, host, port=PORT):
self.host = host
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.s.connect((host, port))
self.f = self.s.makefile("rb")
def scan(self):
self.s.send("FETCh?\n")
data = self.s.recv(268435456)
print(data)
return data
recv
returns up to the amount requested. You have to check the return value and call it again until you receive the amount expected. Implement a buffer that accumulates data and returns the exact amount requested.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.