Access any serial device in your lan
Project description
WSPyserial
A WSPyserial é uma biblioteca para possibilitar a comunicação entre dispostivos seriais via rede utilizando o protocolo websocket.
Sua arquitetura é baseada no modelo cliente/servidor. Onde o Dispotivo serial é o servidor e qualquer cliente que conheca seu endereço e porta pode se comunicar com ele.
Uso/Exemplos
# python -m wspyserial -h
usage: __main__.py [-h] [-c] [-s] [-r] [-p PORT] [-a ADDRESS] [-d DEVICE] [-b BAUDRATE] [-v]
wspyserial - Websocket to Serial Bridge
options:
-h, --help show this help message and exit
-c, --client Run as a client
-s, --server Run as a server
-r, --raw Send raw data
-p PORT, --port PORT Port to listen on
-a ADDRESS, --address ADDRESS
Address to connect to (default: localhost)
-d DEVICE, --device DEVICE
Serial device to connect to (default: 0)
-b BAUDRATE, --baudrate BAUDRATE
Baudrate to use (default: 115200)
Server - [Cmdlt, Instance and Context Manager]
# Start a server at 8020 with command line
python -m wspyerial -s -p 8020
# Server as Instance
from wspyserial.server import Server
import asyncio
async def main():
await Server("0.0.0.0", 8010, 0, 115200).run()
asyncio.run(main())
# Server as context manager]
from wspyserial.server import Server
import asyncio
async def main():
async with Server("0.0.0.0", 8010, 0, 115200) as server:
await asyncio.sleep(10)
asyncio.run(main())
Client - [Cmdlt, Instance and Context Manager]
# Connect a client on server at 0.0.0.0:8010
python -m wspyerial -c -a 0.0.0.0 -p 8010
# Client as Instance
from wspyserial.client import Device as Client
from wspyserial.protocol import package
import asyncio
async def main():
await client = Client("ws://0.0.0.0:8010")
await client.connect()
await client.send(package("M114 R", 2))
await client.stop()
asyncio.run(main())
# Client as context manager
from wspyserial.client import Device as Client
from wspyserial.protocol import package
import asyncio
async def main():
async with Client("ws://0.0.0.0:8010") as client:
PACKAGES = [package("G28 X", -1, 120, "ok"), package("M114 R", 2)]
for command in PACKAGES:
await client.send(command)
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wspyserial-1.1.0.tar.gz.
File metadata
- Download URL: wspyserial-1.1.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22d94f9855f5f34723609af2052f2bc56215f3df555e66ba8f4a2302692b0baa
|
|
| MD5 |
95822130cb63ac40c4914ee69d912db7
|
|
| BLAKE2b-256 |
41bd287e20e24dc0dc96ebe1201d9fbbf85181ec02bff897c6e43a585c13a781
|
File details
Details for the file wspyserial-1.1.0-py3-none-any.whl.
File metadata
- Download URL: wspyserial-1.1.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
898b45457e1679a8034335a02649f3d1ae05f122c0c6dfb2a099084d393fc799
|
|
| MD5 |
0f1230e3f7a7fa59b2a5592281d83efe
|
|
| BLAKE2b-256 |
ae77607528fe3bded26638b2b50acf7f8dff8db01052306d29110469bbe56b83
|