Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: ["**"]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies (service)
working-directory: benchmesh-serial-service
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
python -m pip install pytest

- name: Run tests
run: |
python -m pytest -q benchmesh-serial-service/tests
31 changes: 31 additions & 0 deletions .openhands/microagents/repo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Repository summary for microagents

1) Purpose
BenchMesh provides a consistent, browser-accessible cockpit for lab instruments, enabling connection, control, logging, correlation, and automation from one place. The benchmesh-serial-service sub-project is a Python service that manages multiple serial connections to instruments defined in a YAML configuration, with a modular driver architecture to support different instrument models.

2) General setup
- Languages/Runtime: Python 3.8+
- Key libraries: pyserial (serial communication), pyyaml (config parsing), loguru/logging (logging)
- Configuration: YAML files (top-level config.yaml and benchmesh-serial-service/config.yaml) define devices and their serial parameters.
- Entry point for serial service: python -m src.benchmesh_service.main (run from benchmesh-serial-service directory)
- Packaging: pyproject.toml in benchmesh-serial-service defines a Poetry package (packages include src/benchmesh_service)

3) Repository structure (brief)
- README.md: Top-level project description
- config.yaml: Example top-level device configuration
- benchmesh-serial-service/
- README.md: Service overview and usage
- requirements.txt: Minimal runtime dependencies
- pyproject.toml: Poetry configuration
- config.yaml: Service-specific example configuration
- src/benchmesh_service/
- main.py: Service bootstrap; loads config and spawns connection monitor
- serial_manager.py: Core connection manager (opens, monitors, and probes serial connections for devices)
- config.py: YAML config loader and helper class
- device.py: Simple device abstraction
- logger.py: Logger setup
- drivers/: Device-specific drivers (owon_oel, owon_spm, tenma_psu, owon_xdm)
- drivers/, system/, exampleRS232.py: Additional examples/ancillary code at repository root

CI/Workflows under .github
- No .github directory or GitHub workflows were found in this repository at the time of writing. Therefore, there are no repository-defined CI checks (e.g., linting, tests) enforced via GitHub Actions.
24 changes: 8 additions & 16 deletions benchmesh-serial-service/config.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
version: 1
devices:
- id: eol-1
name: "OWON OEL"
driver: owon_oel
port: /dev/ttyOEL1515
baud: 115200
serial: 8N1
seol: "\n"
reol: "\n"
model: OEL1515
- id: eol-1 # unique ID for this device used in WS and MQTT topics
name: "OWON OEL" # friendly name for UI more details about device will come from SCPI query if available
driver: owon_oel # driver name from drivers/ folder
port: /dev/ttyOEL1515 # adjust to your /dev/ path
baud: 115200 # many OWON units use 115200 baud
serial: 8N1 # optional, defaults to 8N1 if not specified
model: OEL1515 # optional model override if auto-detect fails
- id: psu-1
name: "OWON SPM"
driver: owon_spm
port: /dev/ttySPM3103
baud: 115200
serial: 8N1
seol: "\n"
reol: "\n"
model: SPM3103
- id: tenmapsu-1
name: "TENMA PSU"
driver: tenma_psu
port: /dev/tty722540
baud: 115200
baud: 9600
serial: 8N1
seol: "\r\n"
reol: "\n"
model: 72-2540
- id: dmm-1
name: "OWON XDM"
driver: owon_xdm
port: /dev/ttyXDM1241
baud: 115200
serial: 8N1
seol: "\r\n"
reol: "\n"
model: XDM1241
2 changes: 1 addition & 1 deletion benchmesh-serial-service/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
serial
pyserial
pyyaml
loguru
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"classes": [
"AFG"
],
"connection": {
"seol": "\r",
"reol": "\r",
"connection_verification_command": "*IDN?"
},
"instrument_class": {
"AFG": {
"features": {
Expand Down
45 changes: 0 additions & 45 deletions benchmesh-serial-service/src/benchmesh_service/drivers/owon_oel.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Package init for owon_oel driver
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from ...transport import SerialTransport

class OwonOEL:
def __init__(self, port, baudrate=115200, serial_mode='8N1', seol='\r', reol='\r'):
self.t = SerialTransport(port, baudrate, serial_mode=serial_mode, seol=seol, reol=reol).open()

def identify(self):
self.t.write_line('*IDN?')
return self.t.read_until_reol(1024)

def write(self, data: bytes):
self.t.write(data)

def read(self, size=1024):
return self.t.read(size)

def close(self):
self.t.close()
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"classes": [
"ELL"
],
"connection": {
"seol": "\r",
"reol": "\r",
"connection_verification_command": "*IDN?"
},
"instrument_class": {
"ELL": {
"features": {
Expand Down
45 changes: 0 additions & 45 deletions benchmesh-serial-service/src/benchmesh_service/drivers/owon_spm.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Package init for owon_spm driver
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from ...transport import SerialTransport

class OWONSPM:
def __init__(self, port, baudrate=115200, serial_mode='8N1', seol='\r', reol='\r'):
self.t = SerialTransport(port, baudrate, serial_mode=serial_mode, seol=seol, reol=reol).open()

def identify(self):
self.t.write_line('*IDN?')
return self.t.read_until_reol(1024)

def write(self, text: str):
self.t.write_line(text)

def read(self, size=1024):
return self.t.read(size)

def close(self):
self.t.close()
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"PSU",
"DMM"
],
"connection": {
"seol": "\r",
"reol": "\r",
"connection_verification_command": "*IDN?"
},
"instrument_class": {
"PSU": {
"features": {
Expand Down
61 changes: 0 additions & 61 deletions benchmesh-serial-service/src/benchmesh_service/drivers/owon_xdm.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Package init for owon_xdm driver
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from ...transport import SerialTransport

class OWONXDM:
def __init__(self, port, baudrate=115200, serial_mode='8N1', seol='\r', reol='\r'):
self.t = SerialTransport(port, baudrate, serial_mode=serial_mode, seol=seol, reol=reol).open()

def identify(self):
self.t.write_line('*IDN?')
return self.t.read_until_reol(1024)

def write(self, data: bytes):
self.t.write(data)

def read(self, size=1024):
return self.t.read(size)

def close(self):
self.t.close()

def is_connected(self):
return self.t.is_open
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"classes": [
"DMM"
],
"connection": {
"seol": "\r",
"reol": "\r",
"connection_verification_command": "*IDN?"
},
"instrument_class": {
"DMM": {
"features": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Package init for tenma_72 driver
from .driver import TenmaPSU as tenma_psu
Loading