Configure Bridges
mcgpib supports two transport types for connecting to AR488 bridges: serial (USB) and TCP (WiFi). Each bridge gets its own [[bridge]] section in the TOML configuration file with transport-specific options and tuning parameters.
Configuration file locations
Section titled “Configuration file locations”mcgpib searches for its config file in this order:
- The path in the
$MCGPIB_CONFIGenvironment variable ./mcgpib.tomlin the current working directory~/.config/mcgpib/config.toml
If no file is found, mcgpib starts with no bridges configured.
Transport options
Section titled “Transport options”Serial is the simplest and most reliable transport. Connect the ESP32 to your machine with a USB cable.
[[bridge]]name = "bench-a"transport = "serial"port = "/dev/ttyUSB0"baudrate = 115200Required fields:
| Field | Description |
|---|---|
name | Unique identifier for this bridge. Alphanumeric with hyphens and underscores. |
transport | Set to "serial". |
port | Serial port path. |
baudrate | Baud rate matching the AR488 firmware (default 115200). |
Finding your serial port:
- Linux:
ls /dev/ttyUSB*orls /dev/ttyACM* - macOS:
ls /dev/cu.usbserial-*orls /dev/cu.usbmodem* - Windows: Check Device Manager for COM ports (e.g.,
COM3)
TCP transport connects to an AR488 bridge over the network. The ESP32 acts as a TCP server on port 23.
[[bridge]]name = "bench-b"transport = "tcp"host = "192.168.1.50"tcp_port = 23Required fields:
| Field | Description |
|---|---|
name | Unique identifier for this bridge. |
transport | Set to "tcp". |
host | IP address or hostname of the ESP32. |
tcp_port | TCP port number (default 23). |
Before using TCP transport, you need to configure WiFi on the AR488 bridge itself. This is a one-time setup done over USB serial.
-
Connect to the bridge over serial
Open a serial terminal at 115200 baud (e.g.,
picocom /dev/ttyUSB0 -b 115200). -
Set the WiFi credentials
++wifi ssid YourNetworkName++wifi pass YourPassword -
Enable WiFi and save
++wifi enable++savecfg -
Reboot the bridge
Power cycle the ESP32 or send
++rst. After rebooting, the bridge connects to your WiFi network and starts listening on port 23. -
Find the IP address
Check your router’s DHCP client list, or query the bridge:
++wifiThis prints the current WiFi status, including the assigned IP address.
Once you have the IP address, use it as the host value in your TCP bridge configuration.
Behavior options
Section titled “Behavior options”These fields are optional and apply to both serial and TCP bridges.
[[bridge]]name = "bench-a"transport = "serial"port = "/dev/ttyUSB0"baudrate = 115200auto_scan = trueauto_identify = trueread_timeout_ms = 3000inter_command_delay_ms = 10| Field | Default | Description |
|---|---|---|
auto_scan | true | Scan the bus for listeners immediately after connecting. |
auto_identify | true | Send *IDN? to each discovered listener during scan. |
read_timeout_ms | 3000 | How long to wait for an instrument response (1—32000 ms). |
inter_command_delay_ms | 10 | Pause between consecutive bus commands (0—1000 ms). |
Tuning timeouts
Section titled “Tuning timeouts”The right timeout depends on your instruments and transport:
| Scenario | read_timeout_ms | inter_command_delay_ms |
|---|---|---|
| Serial, fast instruments (34401A, 2000) | 3000 | 10 |
| Serial, slow instruments (electrometer, source measure) | 10000 | 10 |
| TCP, typical bench | 5000 | 20 |
| TCP, high-latency network | 10000 | 30 |
Disabling auto-scan
Section titled “Disabling auto-scan”Set auto_scan = false when:
- You want faster connection times and will scan manually later
- The bus has instruments that behave unpredictably when polled (some older instruments respond to
findlstninconsistently) - You are connecting to an empty bridge for diagnostic purposes
Set auto_identify = false (while keeping auto_scan = true) when:
- You want to discover listener addresses quickly without the overhead of
*IDN?queries - Your instruments do not support IEEE 488.2 identification
Multiple bridges
Section titled “Multiple bridges”Add multiple [[bridge]] sections to manage separate GPIB buses from a single mcgpib instance:
[server]log_level = "INFO"read_timeout_ms = 3000
[[bridge]]name = "bench-a"transport = "serial"port = "/dev/ttyUSB0"baudrate = 115200auto_scan = trueauto_identify = true
[[bridge]]name = "bench-b"transport = "tcp"host = "192.168.1.50"tcp_port = 23read_timeout_ms = 5000inter_command_delay_ms = 20Each bridge operates independently with its own connection, lock, and bus state. Operations on different bridges run concurrently. The name field must be unique across all bridges.
Server-level options
Section titled “Server-level options”The [server] section sets defaults that apply when a bridge does not specify its own value:
[server]log_level = "INFO"read_timeout_ms = 3000| Field | Default | Description |
|---|---|---|
log_level | "INFO" | Logging verbosity: DEBUG, INFO, WARNING, ERROR. |
read_timeout_ms | 3000 | Default read timeout, overridden by per-bridge read_timeout_ms. |
Changing configuration at runtime
Section titled “Changing configuration at runtime”Some bridge settings can be changed after connecting without editing the config file:
> Set the read timeout on bench-a to 10 secondsThe LLM calls configure_bridge("bench-a", read_timeout_ms=10000). Runtime-configurable parameters:
| Parameter | Description |
|---|---|
read_timeout_ms | Read timeout in milliseconds |
auto_mode | Auto-read mode (0=off, 1=prologix, 2=on-query, 3=continuous) |
eos | End-of-send character (0=CRLF, 1=CR, 2=LF, 3=None) |
eoi | Whether to assert EOI on the last byte sent |
Switching between transports
Section titled “Switching between transports”If you move a bridge from USB to WiFi (or vice versa), update the transport and its associated fields in the config:
[[bridge]]name = "bench-a"transport = "serial"port = "/dev/ttyUSB0"baudrate = 115200[[bridge]]name = "bench-a"transport = "tcp"host = "192.168.1.50"tcp_port = 23read_timeout_ms = 5000inter_command_delay_ms = 20Keep the name the same so that any scripts or saved conversations referencing "bench-a" continue to work. Restart mcgpib after changing the config file.