wsh_shell_adapter
Python adapter for working with wsh-shell over:
- serial/UART (
pyserial) - local process via PTY (
PtyProcessTransport)
Features
- connect by fixed
portor auto-discover byvid/pid - synchronize/authenticate with shell (
Press <Enter>->Login->Password-> prompt) - optionally verify sync by
ping_command_and_response - execute commands with timeout and retry logic
- parse command output into structured
dict(jsonorkey: value) - recover on failures with optional fallback ping
Quick Start
From repository root:
Minimal usage:
Config File (TOML)
Default path: wsh_shell_adapter/config.toml
[adapter] maps to AdapterConfig fields.
[local_shell] is used by run_local_shell.py.
Example:
If ping_command_and_response is set, sync() sends the command after prompt detection and
expects the configured response as the full cleaned output or as one full output line before marking
the adapter as synced.
If ping_command_and_response is missing or [], sync() sends a fixed probe command and treats
any non-empty command output as proof that the shell is alive.
auto_recover controls whether the adapter tries soft/hard recovery after command failures.
Load config directly:
Resolve port selection in application code without touching pyserial directly:
Helper Scripts
Local PTY helper
Before first run in a clean checkout, build example binary:
USB helper
It loads [adapter] settings from wsh_shell_adapter/config.toml and starts interactive REPL.
Tests
Install test dependencies:
Run all adapter tests: