Pickering Drivers in C/C++

The example code described here may be found at: http://downloads.pickeringtest.info/downloads/example_software/C++/

It is necessary to understand the topology of a Pickering card to successfully control a card. See section on topology.


PIPX40 (uses NI VISA)

Code:

pipx40_VISA_driver_for_PXI/PI_Switch_card_pipx40_PXI

#include <visa.h>
#include "Pipx40.h"
 
int _tmain(int argc, _TCHAR* argv[])
{
    ViSession handle;            // Handles current session and uses it as reference
    ViStatus Status = 0;            // checks Status of a function

Firstly the required header files must be included to provide the function definitions for the driver calls.
In the case of PIPX40, the VISA library must first be included to provide definitions of the data types being used.

    Status = pipx40_init ("PXI7::13::INSTR", 1, 1, &handle);
    if (Status != VI_SUCCESS)
    {
 

Here a control session is opened on a specific card using the pipx40_init function.
This takes a string as the first parameter that defines the address of the card in VISA resource string format.
The address of the card may be obtained in a number of ways, most commonly by inspecting the list of available devices in NI MAX.

The middle 2 parameters may be ignored for the present.

The last parameter is the address of a variable to hold a unique handle for the card being accessed.
If the function succeeds the return value of the function will be VI_SUCCESS (defined as a value of zero in visa.h).

Should the operation fail for any reason the function return will be non-zero, the value will indicate the nature of the error.


The error value may be queried to obtain a textual explanation of the error.

        pipx40_error_message(handle, Status, msg);
        printf("\nFailed to connect to card because:\n %i ,  %s ",Status, msg);
        return 0;
    }
 

Once a card is successfully opened there are a number of function calls available to allow the control and monitoring of the switching (or other) functions on the card.

The example code for download uses the pipx40_setChannelPattern function to control switches.

    /// Sets output of this sub-unit to the supplied bit-pattern.
 
    Status = pipx40_setChannelPattern(handle, subUnit, data);
 

This function is used to set a group of switches in a single operation. To set a single switch use the pipx40_setChannelState function.

Once the application has finished with the card, the session should be closed.

    if (handle!= 0)
    pipx40_close (handle);

Need help?



Support knowledgebase

Have questions or need some help? While we enjoy talking to you, you can find technical information for our entire product range here.

Technical know-how 


Long-term support

Because we manufacture our products in-house, we are able to provide you with guaranteed long-term support and low obsolescence.

Our support


Resource center

From success stories and product literature to newsletters, find the information you need about our switching and simulation solutions.

Get the resources you need


Worldwide presence

We supply and support our products across the globe, with seven offices in the Americas, Europe and Asia as well as additional representation. 

Find a local office or agent near you