src/eric7/MicroPython/MicroPythonDeviceInterface.py

branch
mpy_network
changeset 9775
c6806d24468b
parent 9766
f0e22f3a5878
child 9799
a79430a8811d
equal deleted inserted replaced
9774:c7b712056146 9775:c6806d24468b
187 self.__rawOff() 187 self.__rawOff()
188 self.__blockReadyRead = False 188 self.__blockReadyRead = False
189 189
190 return True 190 return True
191 191
192 def execute(self, commands): 192 def execute(self, commands, timeout=0):
193 """ 193 """
194 Public method to send commands to the connected device and return the 194 Public method to send commands to the connected device and return the
195 result. 195 result.
196 196
197 If no serial connection is available, empty results will be returned. 197 If no serial connection is available, empty results will be returned.
198 198
199 @param commands list of commands to be executed 199 @param commands list of commands to be executed
200 @type str or list of str 200 @type str or list of str
201 @param timeout per command timeout in milliseconds (0 for configured default)
202 (defaults to 0)
203 @type int (optional)
201 @return tuple containing stdout and stderr output of the device 204 @return tuple containing stdout and stderr output of the device
202 @rtype tuple of (bytes, bytes) 205 @rtype tuple of (bytes, bytes)
203 """ 206 """
204 if not self.__serial: 207 if not self.__serial:
205 return b"", b"" 208 return b"", b""
237 ok, self.__serial.readAll() 240 ok, self.__serial.readAll()
238 ).encode("utf-8"), 241 ).encode("utf-8"),
239 ) 242 )
240 243
241 # read until prompt 244 # read until prompt
242 response = self.__serial.readUntil(b"\x04>") 245 response = self.__serial.readUntil(b"\x04>", timeout=timeout)
243 if self.__serial.hasTimedOut(): 246 if self.__serial.hasTimedOut():
244 self.__blockReadyRead = False 247 self.__blockReadyRead = False
245 return b"", b"Timeout while processing commands." 248 return b"", b"Timeout while processing commands."
246 if b"\x04" in response[:-2]: 249 if b"\x04" in response[:-2]:
247 # split stdout, stderr 250 # split stdout, stderr

eric ide

mercurial