serial-com 0.1.7__tar.gz → 0.1.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: serial-com
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary:
5
5
  Author: Andrey Linyushin
6
6
  Author-email: 89202979894@mail.ru
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "serial-com"
3
- version = "0.1.7"
3
+ version = "0.1.8"
4
4
  description = ""
5
5
 
6
6
  authors = [
@@ -178,8 +178,12 @@ class IPPort(socket.socket):
178
178
  logger.debug(f"{self} no answer")
179
179
  ans = b""
180
180
  except OSError as e:
181
- if e.errno in (10038, 10054): # socket was closed
182
- raise SocketClosedError("Socket was closed. A new one must be created")
181
+ if platform == "win32":
182
+ if e.errno in (10038, 10054): # socket was closed
183
+ raise SocketClosedError("Socket was closed. A new one must be created")
184
+ elif platform == "linux":
185
+ if e.errno in (104, 113, 5):
186
+ raise SocketClosedError("Socket was closed. A new one must be created")
183
187
  return ans
184
188
 
185
189
  def write(self, bl: bytes, *args, **kwargs) -> int:
@@ -190,7 +194,7 @@ class IPPort(socket.socket):
190
194
  if e.errno in (10038, 10054): # socket was closed
191
195
  raise SocketClosedError("Socket was closed. A new one must be created")
192
196
  elif platform == "linux":
193
- if e.errno == 104:
197
+ if e.errno in (104, 113, 5):
194
198
  raise SocketClosedError("Socket was closed. A new one must be created")
195
199
  raise e
196
200
 
@@ -293,7 +297,8 @@ class WorkerProperty:
293
297
  port_type: str
294
298
  name: str
295
299
 
296
- def __init__(self, port_type: str = PORT_TYPE, name: str = "", listener: str = "", baudrate: int = 19200): #TODO: stopbits etc.
300
+ def __init__(self, port_type: str = PORT_TYPE, name: str = "", listener: str = "", baudrate: int = 19200,
301
+ reconnect=True): #TODO: stopbits etc.
297
302
  if port_type not in (SERIAL_PORT, NETWORK_PORT):
298
303
  raise ValueError(f"Invalid port type for PortProperty {port_type}")
299
304
  if port_type == SERIAL_PORT:
@@ -458,7 +463,7 @@ def listen_port(dev_id: str,
458
463
  logger.debug(f"{request.__repr__()} to {dev_id} will be sent on {port}")
459
464
  ans = ser_request(request, attempt, port, length=length, read_until=read_until)
460
465
  except (serial.SerialException, ) as e:
461
- if "ClearCommError" in str(e):
466
+ if "ClearCommError" in str(e) or "FileNotFound" in str(e) or "Input/output error" in str(e):
462
467
  CONNECTOR.recreate_port(port_name)
463
468
  logger.debug(e)
464
469
  raise e
@@ -522,7 +527,7 @@ def ser_request(request: bytearray|bytes, attempt: int, port: Port, length=None,
522
527
  except Exception as e:
523
528
  sleep(1)
524
529
  logger.info(f"Unsuccessful attempt to poll device{e}")
525
- ser_request(request, attempt + 1, port, length, read_until)
530
+ return ser_request(request, attempt + 1, port, length, read_until)
526
531
  else:
527
532
  raise ConnectionError(f"Couldn't read serial data after {max_retries} unsuccessful attempts")
528
533
 
File without changes