Accessing Pickering Drivers from Python
Pickering drivers are standard Windows dll's and as such can be accessed from most programming languages, including Python.
To access a library, use the ctypes library, here is an example of access to the non-VISA driver PILPXI:
At the command line
from ctypes import * pilpxi = windll.LoadLibrary("pilpxi") ver = pilpxi.PIL_Version()
A Python Library for PILPXI
An implementation of the library is provided here
It contains 2 class definitions:
- pilpxi_base
contains non card-specific functions to locate PXI cards
- pilpxi_card
contains all the card -specific functions to access and control Pickering PXI cards
Example:
from pilpxi import * base = pilpxi_base() e, count = base.CountFreeCards() e, bus, slot = base.FindFreeCards(count) cardnum = 0 while cardnum < count: card = pilpxi_card(bus[cardnum], slot[cardnum]) err, cid = card.CardId() print "Card ",cardnum print "Bus", bus[cardnum], " Device", slot[cardnum] print "ID = ", cid e, ins, outs = card.EnumerateSubs() print "subunits: ", ins, "input, ", outs, "output" sub = 1 while sub <= outs: e, inf = card.SubType(sub, 1) print "subunit ",sub, " = ", inf sub = sub + 1 cardnum = cardnum +1
In this example, pilpxi_base is used to locate all available cards. CountFreeCards returns the number of cards found, then FindFreeCards returns two arrays containing the bus and device numbers of the cards.
Next pilpxi_card is used to open each card and then basic card information is queried and the type of each subunit presented.
For basic details of the functions available the user is referred to pilpxi documentation.