Skip to content

Configuration

mcgpib uses a TOML configuration file to define bridges and server behavior. If no configuration file is found, the server starts with no bridges configured.

The server looks for a configuration file in this order, using the first one found:

  1. $MCGPIB_CONFIG — environment variable pointing to an explicit path
  2. ./mcgpib.toml — current working directory
  3. ~/.config/mcgpib/config.toml — XDG user config directory

If none of these paths exist, the server starts with an empty configuration (zero bridges). You can still add bridges dynamically in future versions, but for now at least one [[bridge]] section is required for useful operation.

The [server] section controls global server behavior.

[server]
log_level = "INFO" # DEBUG, INFO, WARNING, ERROR
read_timeout_ms = 3000 # Default GPIB read timeout (overridden per-bridge)
KeyTypeDefaultDescription
log_levelstring"INFO"Python logging level. DEBUG logs every ++ command sent to bridges
read_timeout_msinteger3000Default GPIB read timeout in milliseconds (1—32000). Individual bridges can override this value

Each [[bridge]] section defines a single AR488 bridge. You can define as many bridges as needed — they are accessed independently and concurrently (one lock per bridge, concurrent across bridges).

[[bridge]]
name = "bench-a" # Unique identifier (alphanumeric, hyphens, underscores)
transport = "serial" # "serial" or "tcp"
port = "/dev/ttyUSB0" # Serial port path
baudrate = 115200 # Serial baud rate (default: 115200)
auto_scan = true # Scan bus on connect (default: true)
auto_identify = true # Send *IDN? to discovered listeners (default: true)
read_timeout_ms = 3000 # GPIB read timeout for this bridge (default: 3000)
inter_command_delay_ms = 10 # Delay between commands in ms (default: 10)
[[bridge]]
name = "bench-b"
transport = "tcp"
host = "192.168.1.50" # IP address or hostname of ESP32
tcp_port = 23 # AR488 WiFi default port (default: 23)
auto_scan = false # Skip initial scan (useful for slow WiFi links)
read_timeout_ms = 5000 # Longer timeout for WiFi latency
inter_command_delay_ms = 20 # Larger delay for WiFi stability
KeyTypeDefaultDescription
namestring(required)Unique bridge identifier. Alphanumeric with hyphens and underscores only
transportstring"serial"Transport type: "serial" or "tcp"
portstringnullSerial port path (required for serial transport)
baudrateinteger115200Serial baud rate
hoststringnullTCP host address (required for TCP transport)
tcp_portinteger23TCP port number
auto_scanbooleantrueRun ++findlstn immediately after connecting
auto_identifybooleantrueSend *IDN? to each listener found by auto_scan
read_timeout_msinteger3000GPIB read timeout in milliseconds (1—32000)
inter_command_delay_msinteger10Delay between consecutive ++ commands (0—1000 ms)
VariableDescription
MCGPIB_CONFIGAbsolute path to TOML config file. Overrides the default search order

A complete configuration with two bridges — one serial and one WiFi:

mcgpib.toml
[server]
log_level = "INFO"
read_timeout_ms = 3000
# USB-connected bridge on the main bench
[[bridge]]
name = "main-bench"
transport = "serial"
port = "/dev/ttyUSB0"
baudrate = 115200
auto_scan = true
auto_identify = true
read_timeout_ms = 3000
inter_command_delay_ms = 10
# WiFi-connected bridge in the RF shielded room
[[bridge]]
name = "rf-bench"
transport = "tcp"
host = "192.168.1.50"
tcp_port = 23
auto_scan = true
auto_identify = true
read_timeout_ms = 5000
inter_command_delay_ms = 20