Skip to content

raffber/comsrv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6fe2331 · Mar 25, 2025
Mar 25, 2025
Dec 12, 2023
Dec 5, 2024
Feb 18, 2025
Mar 24, 2025
Mar 24, 2025
Mar 24, 2025
Mar 24, 2025
Aug 29, 2022
Mar 24, 2025
Mar 24, 2025
Sep 7, 2024
Feb 18, 2025
Mar 25, 2025
Mar 24, 2025
May 7, 2024
Dec 5, 2024
Aug 16, 2022
Aug 16, 2022
Dec 5, 2024
Sep 7, 2024
Apr 23, 2024
Mar 24, 2025
Jun 20, 2023
Aug 14, 2023
Aug 14, 2023
Mar 24, 2025

Repository files navigation

comsrv Communication Relay

Rust Stable

The comsrv utility exposes an RPC interface mainly intended for communicating with lab instruments. Currently, the following type of instruments are supported:

  • Serial Ports
  • VXI-11/LXI Instruments
  • Prologix USB-to-GPIB adapters
  • Modbus/TCP instruments
  • Modbus/RTU over serial ports or TCP streams
  • Raw TCP Sockets
  • USB HID based devices
  • FTDI devices
  • CAN over PCAN and SocketCAN (linux-only)
  • All VISA controlled instruments as fallback (requires VISA installation)

comsrv automatically manages connections and operating system handles:

  • If no connection has been established, the connection is automatically opened
  • If the connection drops and a new request is issued, the connection is automatically reopened
  • In case the configuration of a instrument changes (such as the baud-rate on a serial port), it is appropriately re-initialized

Thus, the application using the comsrv should not care much about how connections are managed. It must also not care about spawning threadpools for IO, bridging async and sync interface or worry about library support for exotic protcols. As a consequence most of the connectivity error handling is offloaded to the comsrv.

The RPC protocol uses standard technology, specifically HTTP, WebSockets and JSON to simplify integration with various stacks or programming languages. The reference implementation is found here. It is even possible to directly interact with the comsrv using the web browser.

Furthermore, it allows connecting from different processes to the same OS handles in a synchronized way. Clients may lock instruments to fine grained control, otherwise RPC requests are just queued and processed in the order that they are arriving, which is sufficient for most applications.

Examining the comsrv log

To enable logging, start comsrv with the -v option:

comsrv -v  # enables logging

The log will print executed commands as well as inform about communication errors that occur.

Documentation

  • The RPC protocol is: https://github.com/raffber/wsrpc. comsrv specific information here.
  • The Python API is described here.
  • Optional VISA-compatible resource strings for short-hand initialization of instrument are documented here.

Building

Apart from the rust toolchain you also need the following debian/ubuntu packages:

  • libuv-dev
  • libclang-dev

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.