Skip to content

Commit 527498a

Browse files
committed
Add bufsize argument to TCPInterface.recv()
Default to 4096, the reasonable example value from upstream docs, which is commonly used in existing agents.
1 parent 54027b0 commit 527498a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

socs/agents/cryomech_cpa/drivers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_data(self):
5353
Gets the raw data from the PTC and returns it in a usable format.
5454
"""
5555
self.send(self.buildRegistersQuery())
56-
data = self.recv()
56+
data = self.recv(1024)
5757
data_flag, brd = self.breakdownReplyData(data)
5858

5959
return data_flag, brd

socs/tcp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,18 @@ def _check_ready(self):
123123
if not sel.select(self.timeout):
124124
raise ConnectionError("Socket not ready to read. Possible timeout.")
125125

126-
def recv(self):
126+
def recv(self, bufsize=4096):
127127
"""Receive response from the device.
128128
129129
This method will check if the socket is ready to be read from before
130130
performing the recv. If there is no data to read, or the socket is
131131
otherwise unready an exception is raised.
132132
133+
Parameters
134+
----------
135+
bufsize : int
136+
Amount of data to be recieved in bytes. Defaults to 4096.
137+
133138
Returns
134139
-------
135140
``str`` or ``bytes``
@@ -143,7 +148,7 @@ def recv(self):
143148
144149
"""
145150
self._check_ready()
146-
data = self.comm.recv(1024)
151+
data = self.comm.recv(bufsize)
147152
return data
148153

149154
def __del__(self):

0 commit comments

Comments
 (0)