Skip to content

Scan and Identify Instruments

After connecting to a bridge, you need to discover what instruments are on the GPIB bus. mcgpib provides bus_scan for discovery and instrument_identify for detailed identification of individual devices.

A bus scan sends the AR488 ++findlstn command, which polls every GPIB address from 1 to 30 and returns the addresses that acknowledge.

> Scan the GPIB bus on bench-a

The LLM calls bus_scan("bench-a"). With the default identify=True, it also sends *IDN? to each listener:

Bus scan on bench-a: 3 listener(s)
Address 1: HEWLETT-PACKARD 34401A (S/N: 3146A02377)
Address 5: KEITHLEY INSTRUMENTS INC. 2000 (S/N: 1234567)
Address 22: Agilent Technologies E3631A (S/N: MY12345678)

If you only need to know which addresses have active listeners, pass identify=False:

> Scan bench-a without sending *IDN?

The LLM calls bus_scan("bench-a", identify=False):

Bus scan on bench-a: 3 listener(s)
Address 1: listener found
Address 5: listener found
Address 22: listener found

This is faster and avoids potential issues with instruments that do not handle *IDN? gracefully.

To get detailed identification for a single address:

> Identify the instrument at address 5 on bench-a

The LLM calls instrument_identify("bench-a", 5):

Address 5 on bench-a:
Manufacturer: KEITHLEY INSTRUMENTS INC.
Model: 2000
Serial: 1234567
Firmware: A04 /A02
Raw: KEITHLEY INSTRUMENTS INC.,2000,1234567,A04 /A02

The *IDN? response follows the IEEE 488.2 format: four comma-separated fields for manufacturer, model, serial number, and firmware version. mcgpib parses these into structured fields.

Not all instruments return clean *IDN? strings. Here is what to expect:

Instrument era*IDN? behavior
Modern IEEE 488.2 (Keysight, R&S, Keithley)Clean four-field response
Older HP/Agilent (34401A, E3631A)Standard response but may vary in field formatting
Pre-488.2 instruments (HP 3478A, Fluke 8842A)No response — times out
Mixed-protocol instrumentsMay return partial or non-standard strings

After scanning, list_instruments shows everything discovered across all connected bridges:

> List all discovered instruments

The LLM calls list_instruments():

Discovered instruments:
[bench-a] Address 1: HEWLETT-PACKARD 34401A
[bench-a] Address 5: KEITHLEY INSTRUMENTS INC. 2000
[bench-a] Address 22: Agilent Technologies E3631A
[bench-b] Address 3: Stanford_Research_Systems SR830

To filter to a single bridge, pass the bridge name:

> List instruments on bench-a only

The LLM calls list_instruments(bridge_name="bench-a").

Handle instruments that do not support *IDN?

Section titled “Handle instruments that do not support *IDN?”

For pre-488.2 instruments, you need a different approach:

  1. Scan without identification to confirm the address is active:

    > Scan bench-a without identifying
  2. Try a known command for the instrument you expect at that address. For example, the HP 3478A uses F1RA to configure DC voltage autorange:

    > Send "F1RA" to address 22 on bench-a and read the response

    The LLM calls raw_scpi("bench-a", 22, "F1RA", read_after=True).

  3. Check the instrument’s front panel for a response. Many older instruments display “REMOTE” or “RMT” when they receive a valid command over GPIB.

When you power cycle instruments or reconnect GPIB cables:

  1. Wait for instruments to boot. Many instruments take 5—30 seconds for self-test after power-on.

  2. Run a new bus scan:

    > Scan bench-a again

    This replaces the previous scan results entirely. Any instruments that are no longer on the bus will disappear from the list.

  3. If instruments are missing, check:

    • GPIB cable connections (the connectors are stackable — make sure they are seated firmly)
    • Power status on each instrument
    • GPIB address switches or menu settings have not changed

If auto_scan = true and auto_identify = true in the bridge config, instrument discovery happens automatically when you call connect_bridge. The scan results are immediately available through list_instruments without a separate bus_scan call.

To skip automatic scanning (for faster connections or to avoid disturbing instruments), set auto_scan = false in the config and scan manually when ready.