Concurrency agnostic serialio API
A python concurrency agnostic serial line library.
Helpful when handling with instrumentation which work over serial line and implement simple REQ-REP communication protocols (example: SCPI).
So far, only serial line over RFC2217 protocol and raw socket are available. It should be compatible with:
- ser2net bridge with telnet and raw configurations
- gserial[ser2tcp] bridge (RFC2217)
Base implementation written in asyncio with support for different concurrency models:
- classic blocking API (TODO)
- future based API (TODO)
Here is a summary of what is forseen and what is implemented
From within your favourite python environment:
pip install serialio
import asyncio from serialio.aio.tcp import Serial async def main(): sl = Serial('raw.ser2net.com', 5000) # Assuming a SCPI complient on the other end we can ask for: reply = await sl.write_readline(b'*IDN?\n') print(reply) asyncio.run(main())
from serialio.sio.tcp import Serial sl = Serial('raw.ser2net.com', 5000) reply = sl.write_readline(b'*IDN?\n') print(reply)
from serialio.sio.tcp import Serial sl = Serial('raw.ser2net.com', 5000, resolve_futures=False) reply = sl.write_readline(b'*IDN?\n').result() print(reply)
The main goal of a serialio Serial object is to facilitate communication with instruments connected to a serial line.
The most frequent cases include instruments which expect a REQ/REP semantics with ASCII protocols like SCPI. In these cases most commands translate in small packets being exchanged between the host and the instrument. When a raw TCP or RFC2217 bridge is used to access the serial line, serialio uses the sockio library.
Many instruments out there have a Request-Reply protocol. A serialio Serial
write_read family of methods which simplify communication
with these instruments.
TODO: Write this chapter
In line based protocols, sometimes people decide
\n is not a good EOL character.
A serialio can be customized with a different EOL character. Example:
sl = Serial('raw.ser2net.com', 5000, eol=b'\r')
The EOL character can be overwritten in any of the
readline methods. Example:
await sl.write_readline(b'*IDN?\n', eol=b'\r')
TODO: Write this chapter
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size serialio-0.1.1.tar.gz (17.8 kB)||File type Source||Python version None||Upload date||Hashes View hashes|