Skip to content

Commit e4a22f9

Browse files
jenshnielsenWilliamHPNielsen
authored andcommitted
Fix: ip instrument log empty responce and ensure all data is send (#719)
* Fix: ip instrument log empty responce As I understand it that is a sign of a closed socket This should probably be an error in the future * Use sendall fixes #748
1 parent 41530ba commit e4a22f9

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

qcodes/instrument/ip.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Ethernet instrument driver class based on sockets."""
22
import socket
3+
import logging
34

45
from .base import Instrument
56

7+
log = logging.getLogger(__name__)
68

79
class IPInstrument(Instrument):
810

@@ -139,10 +141,14 @@ def set_terminator(self, terminator):
139141

140142
def _send(self, cmd):
141143
data = cmd + self._terminator
142-
self._socket.send(data.encode())
144+
self._socket.sendall(data.encode())
143145

144146
def _recv(self):
145-
return self._socket.recv(self._buffer_size).decode()
147+
result = self._socket.recv(self._buffer_size)
148+
if result == b'':
149+
log.warning("Got empty response from Socket recv() "
150+
"Connection broken.")
151+
return result.decode()
146152

147153
def close(self):
148154
"""Disconnect and irreversibly tear down the instrument."""

0 commit comments

Comments
 (0)