Package: prologix-gpib-async
prologix_gpib_asyncPython3 AsyncIO Prologix GPIB Driver. This library requires Pythonasyncio. In contrast to a synchronous implementation, this library
makes it possible to control multiple GPIB controllers at once and work with large setups.The library is fully type-hinted.Supported HardwareDeviceSupportedTestedCommentsGPIB-ETHERNET Controller 1.2:heavy_check_mark::heavy_check_mark:GPIB-USB Controller 6.0:x::x:Need hardwareTested using Linux, should work for Mac OSX, Windows and any OS with Python support.SetupTo install the library in a virtual environment (always use venvs with every project):python3-mvenvenv# virtual environment, optionalsourceenv/bin/activate
pipinstallprologix-gpib-asyncUsageThis library makes use of asynchronous context managers to hide all connection related stuff and
also handle cleanup. By the way: Context managers are great!Initialize the GPIB adapterfromprologix_gpib_asyncimportAsyncPrologixGpibEthernetController# Create a controller and talk to device address 22asyncwithAsyncPrologixGpibEthernetController("127.0.0.1",pad=22)asgpib_device:# Add your code here...Sending a "my command" command to address 22 (as set up previously)awaitgpib_device.write("my command")Reading data from address 22data=awaitgpib_device.read()Example program, that queries the version string as can be found atexamples/example.pyimportasyncio# Devicesfromprologix_gpib_asyncimportAsyncPrologixGpibEthernetControllerasyncdefmain():try:asyncwithAsyncPrologixGpibEthernetController("127.0.0.1",pad=22)asgpib_device:version=awaitgpib_device.version()print("Controller version:",version)except(ConnectionError,ConnectionRefusedError):print("Could not connect to remote target. Is the device connected?")asyncio.run(main())Seeexamples/for more working examples.Support for Multiple DevicesThe Prologix GPIB adapter supports talking to multiple devices, but there are (theoretical) hardware limits. The
Prologix adapters do not have line drivers, so only a limited number of devices can be driven using one controller.On the software side, there is full support for multiple devices and the driver will switch between different addresses
transparently. The driver internally manages the connection and keeps track of the GPIB controller state and manages the
state for each gpib object. It is important, that the driver is the only client editing the state of the GPIB
controller. Otherwise, the driver state and the controller state may get out of sync.:warning:Concurrency with multiple devices: Note, that when using a single adapter to control multiple devices,
there is no concurrency on the GPIB bus. Whenever reading or writing to a remote device, the driver will lock the GPIB
controller to ensure that reading from a controller is synchronous. This means, there isnospeed increase, when
making asynchronous reads from multiple devices on the bus. Using a GPIB Group Execute Trigger (GET) by invoking the
trigger() function, concurrent measurements can be triggered though. Some devices also allow asynchronous function
calls, that signal status updates via the srq register.Example:importasynciofromcontextlibimportAsyncExitStack# Devicesfromprologix_gpib_asyncimportAsyncPrologixGpibEthernetControllerip_address="127.0.0.1"asyncdefmain():try:asyncwithAsyncExitStack()asstack:gpib_device1,gpib_device2=awaitasyncio.gather(stack.enter_async_context(AsyncPrologixGpibEthernetController(ip_address,pad=22)),stack.enter_async_context(AsyncPrologixGpibEthernetController(ip_address,pad=10)),)awaitgpib_device1.write(b"*IDN?")# Automatically changes address to device 22print(awaitgpib_device1.read())awaitgpib_device2.write(b"*IDN?")# Automatically changes address to device 10print(awaitgpib_device2.read())except(ConnectionError,ConnectionRefusedError):print("Could not connect to remote target. Is the device connected?")asyncio.run(main())VersioningI useSemVerfor versioning. For the versions available, see thetags on this repository.DocumentationI use theNumpydocstyle for documentation.AuthorsPatrick Baus-Initial work-PatrickBausLicenseThis project is licensed under the GPL v3 license - see theLICENSEfile for details