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.
Scan the bus
Section titled “Scan the bus”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-aThe 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)Scan without identification
Section titled “Scan without identification”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 foundThis is faster and avoids potential issues with instruments that do not handle *IDN? gracefully.
Identify a specific instrument
Section titled “Identify a specific instrument”To get detailed identification for a single address:
> Identify the instrument at address 5 on bench-aThe 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 /A02The *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.
Interpret *IDN? responses
Section titled “Interpret *IDN? responses”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 instruments | May return partial or non-standard strings |
List instruments across bridges
Section titled “List instruments across bridges”After scanning, list_instruments shows everything discovered across all connected bridges:
> List all discovered instrumentsThe 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 SR830To filter to a single bridge, pass the bridge name:
> List instruments on bench-a onlyThe 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:
-
Scan without identification to confirm the address is active:
> Scan bench-a without identifying -
Try a known command for the instrument you expect at that address. For example, the HP 3478A uses
F1RAto configure DC voltage autorange:> Send "F1RA" to address 22 on bench-a and read the responseThe LLM calls
raw_scpi("bench-a", 22, "F1RA", read_after=True). -
Check the instrument’s front panel for a response. Many older instruments display “REMOTE” or “RMT” when they receive a valid command over GPIB.
Re-scan after power cycling
Section titled “Re-scan after power cycling”When you power cycle instruments or reconnect GPIB cables:
-
Wait for instruments to boot. Many instruments take 5—30 seconds for self-test after power-on.
-
Run a new bus scan:
> Scan bench-a againThis replaces the previous scan results entirely. Any instruments that are no longer on the bus will disappear from the list.
-
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
Automatic scanning on connect
Section titled “Automatic scanning on connect”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.