PROLOGIX_READ
 
 Returns the response from the GPIB instrument. For example if you query a VISA instrument with "*IDN?" using a
SERIAL_WRITE block, this block must be used to return the response.
Not required if the PROLOGIX_AUTO setting is "on" (not recommended).
Requires an OPEN_SERIAL block.  Params:    connection : Serial  The open serial connection with the instrument.     Returns:    out : String  Response from the Prologix USB-to-GPIB controller.    
   Python Code
import serial
from flojoy import flojoy, SerialConnection, DataContainer, String
from typing import cast, Optional
@flojoy(inject_connection=True)
def PROLOGIX_READ(
    connection: SerialConnection,
    default: Optional[DataContainer] = None,
) -> String:
    """Returns the response from the GPIB instrument.
    For example if you query a VISA instrument with "*IDN?" using a
    SERIAL_WRITE block, this block must be used to return the response.
    Not required if the PROLOGIX_AUTO setting is "on" (not recommended).
    Requires an OPEN_SERIAL block.
    Parameters
    ----------
    connection: Serial
        The open serial connection with the instrument.
    Returns
    -------
    String
        Response from the Prologix USB-to-GPIB controller.
    """
    # Start serial communication with the instrument
    ser = cast(serial.Serial, connection.get_handle())
    if ser is None:
        raise ValueError("Serial communication is not open")
    cmd = "++read eoi\n"
    ser.write(cmd.encode())
    s = ser.read(256)
    if isinstance(s, bytes):
        s = s.decode("utf-8")
    return String(s)
Example
Having problems with this example app? Join our Discord community and we will help you out!
This app prepares the Prologix GPIB-USB adapter for use with a VISA instrument. The user can then send a SCPI command to a VISA instrument using the GPIB-USB adapter.
Parameters:
- Connection on all of the Blocks should be the COM port of the adapter.
- PROLOGIX AUTO: auto = off
- PROLOGIX MODE: mode = CONTROLLER
- PROLOGIX EOI: EOI = true, EOS = None (instrument dependent)
- GPIB address should match the instrument’s (see the instrument’s manual on how to find it)
- OPEN SERIAL: writing “*IDN?” with bytes encoding and a LF terminator
This app has two rows that are run seperately:
- The top, setup, row with AUTO,MODEandEOIblocks.
- The bottom row with WRITEandREAD.
The two constants on the bottom left control which row runs. If they are equal, the setup row runs. Otherwise, the read/write row runs. The setup should be run before connecting the adapter to the instrument.
Note that the PROLOGIX READ should be used to recieve a response from the instrument. The AUTO mode can be turned on which recieves a response upon every command (PROLOGIX AUTO block controls this setting). However, this causes errors in some VISA instruments.