Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
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).
Besides local serial line, serialio also supports serial line over RFC2217 protocol, raw TCP socket and tango.
As far as RFC2217 is concerned, it should be compatible with:
As far as tango is concerned, it should be compatible with the tango classes:
Base implementation written in asyncio with support for different concurrency models:
Here is a summary of what is forseen and what is implemented
Concurrency | Local | RFC2217 | Raw TCP | Tango |
---|---|---|---|---|
asyncio | Y | Y | Y | Y |
classic sync | Y | Y | Y | Y |
conc. futures | Y | Y | Y | Y |
From within your favourite python environment:
pip install serialio
import asyncio
import serialio.aio.tcp
async def main():
sl = serialio.serial_for_url("serial-tcp://lab1.acme.org:5000")
# or the equivalent:
# sl = serialio.aio.tcp.Serial("lab1.acme.org", 5000)
await sl.open()
# Assuming a SCPI complient on the other end we can ask for:
reply = await sl.write_readline(b"*IDN?\n")
print(reply)
await sl.close()
asyncio.run(main())
local serial line
import serialio.aio.posix
sl = serialio.aio.posix.Serial("/dev/ttyS0")
# or the equivalent
sl = serialio.serial_for_url("serial:///dev/ttyS0")
raw TCP socket
import serialio.aio.tcp
sl = serialio.aio.tcp.Serial("lab1.acme.org:5000")
# or the equivalent
sl = serialio.serial_for_url("serial+tcp://lab1.acme.org:5000")
RFC2217 (telnet)
import serialio.aio.rfc2217
sl = serialio.aio.rfc2217.Serial("lab1.acme.org:5000")
# or the equivalent
sl = serialio.serial_for_url("rfc2217://lab1.acme.org:5000")
Tango
(needs a pip install serialio[tango]
installation)
import serialio.aio.tango
sl = serialio.aio.tango.Serial("lab/01/serial-01")
# or the equivalent
sl = serialio.serial_for_url("serial+tango://lab/01/serial-01")
from serialio.aio.tcp import Serial
sl = Serial("lab1.acme.org", 5000)
reply = sl.write_readline(b"*IDN?\n")
print(reply)
from serialio.sio.tcp import Serial
sl = Serial("lab1.acme.org", 5000, resolve_futures=False)
reply = sl.write_readline(b"*IDN?\n").result()
print(reply)
open()
coroutine must be called explicitly before using the serial lineawait ser_line.set_XXX(value)
instead of ser_line.XXX = value
(ex: await ser_line.set_baudrate()
))eol
character (serial is fixed to b"\n"
)write_read()
family)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.
Many instruments out there have a Request-Reply protocol. A serialio Serial
provides helpful write_read
family of methods which simplify communication
with these instruments.
In line based protocols, sometimes people decide \n
is not a good EOL character.
A serialio can be customized with a different EOL character.
For example, the XIA-PFCU always
replies with ;\r\n
, so we could configure it using the following snippet:
sl = serialio.serial_for_url("serial:///dev/ttyS0", eol=b";\r\n")
await sl.open()
The initial 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
FAQs
Concurrency agnostic serialio API
We found that serialio demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.