watchedserial
Installation
$ pip install watchedserial
Description
WatchedReaderThread is a subclass of pySerial’s serial.threaded.ReaderThread. Similar to ReaderThread, WatchedReaderThread implements a serial port read loop in it’s own thread but instead of killing the thread on a serial disconnection, it calls a callback and waits for the port to become available again before attempting a reconnect. On reconnect it calls a reconnect callback. This should make writing apps that need to deal with unreliable serial connections more seamless and make it easier to write apps that should allow the user to disconnect and reconnect a serial device safely.
Usage
Subclass watchedserial.WatchedReaderThread to implement the handle_reconnect() and handle_disconnect() callbacks. Both of these functions should be non-blocking (similar to an ISR).
import time
import serial
from watchedserial import WatchedReaderThread
PORT = "COM3"
class MyPacket(serial.threaded.FramedPacket):
def handle_packet(self, packet):
print(packet)
class MyWatchedReaderThread(WatchedReaderThread):
def handle_reconnect(self):
print("Reconnected")
def handle_disconnect(self, error):
print("Disconnected")
ser = serial.Serial(PORT, baudrate=115200)
with MyWatchedReaderThread(ser, MyPacket) as protocol:
while True:
time.sleep(1)
Metadata
Release files for watchedserial 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| watchedserial-1.0.1.tar.gz | 3.4 kB | Without provenance | Details for watchedserial-1.0.1.tar.gz |
Release files / watchedserial-1.0.1.tar.gz
| Download URL | watchedserial-1.0.1.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ce5fb9f986c1571aa313d88a6c6ed693525f313ab19aeef180ab083bedf38bd
|
|
BLAKE2b-256 checksum How to use checksums |
454d9be97efec8be22b0effdda180afc2348e26cd64f5f622869455edccd2c48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for watchedserial 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.