C/C++ Driver Interface | Software |
|
|
Examples
Examples can be found on CD in the path /Examples/linux. There is one subdirectory for each board family. You’ll find board specific ex- amples for that family there. The examples are bus type independent. As a result that means that the MI30xx directory contains examples for the MI.30xx, the MC.30xx and the MX.30xx families. The examples are simple one file programs and can be compiled using the Gnu C compiler gcc. It’s not necessary to use a makefile for them.
Other Windows C/C++ compilers
Include Driver
To access the driver, the driver functions must be loaded from the driver dll. This can be easily done by standard windows functions. There is one example in the directory /Examples/other that shows the process. After loading the functions from the dll one can proceed with the examples that are given for Microsoft Visual C++.
Example of function loading:
//definition of external function that has to be loaded from DLL typedef int16 (SPCINITPCIBOARDS) (int16* pnCount, int16* pnPCIVersion);
typedef int16 (SPCSETPARAM) | (int16 nNr, int32 lReg, | int32 lValue); | ||
typedef int16 (SPCGETPARAM) | (int16 nNr, int32 lReg, | int32* plValue); | ||
... | pfnSpcInitPCIBoards; |
|
| |
SPCINITPCIBOARDS* |
|
| ||
SPCSETPARAM* | pfnSpcSetParam; |
|
|
|
SPCGETPARAM* | pfnSpcGetParam; |
|
|
|
... |
|
|
|
|
// |
|
|
| |
hDLL = LoadLibrary ("spectrum.dll"); |
|
| ||
// |
| (hDLL, "SpcInitPCIBoards"); | ||
pfnSpcInitPCIBoards = (SPCINITPCIBOARDS*) GetProcAddress | ||||
pfnSpcSetParam = | (SPCSETPARAM*) | GetProcAddress | (hDLL, "SpcSetParam"); | |
pfnSpcGetParam = | (SPCGETPARAM*) | GetProcAddress | (hDLL, "SpcGetParam"); |
National Instruments LabWindows/CVI
Include Drivers
To use the Spectrum driver under LabWindows/CVI it is necessary to first load the functions from the driver dll. This is more or less similar to the above shown process with the only difference that LabWindows/CVI uses it’s own library handling functions instead of the windows standard functions.
Example of function loding under LabWindows/CVI:
//
DriverId = LoadExternalModule ("spectrum.lib");
//
SpcInitPCIBoards = (SPCINITPCIBOARDS*) | GetExternalModuleAddr (DriverId, "SpcInitPCIBoards", &Status); | |||||
SpcSetParam | = | (SPCSETPARAM*) | GetExternalModuleAddr | (DriverId, | "SpcSetParam", | &Status); |
SpcGetParam | = | (SPCGETPARAM*) | GetExternalModuleAddr | (DriverId, | "SpcGetParam", | &Status); |
Examples
Examples for LabWindows/CVI can be found on CD in the directory /Examples/cvi. Theses examples show mainly how to include the driver in a LabWindows/CVI environment and don’t use any special functions of the boards. The examples have to be merged with the standard windows examples described under Visual C++.
Driver functions
The driver contains five functions to access the hardware.
Function SpcInitPCIBoard
This function initializes all installed PCI, PXI and CompactPCI boards. The boards are recognized automatically. All installation parameters are read out from the hardware and stored in the driver. The number of PCI boards will be given back in the value Count and the version of the PCI bus itself will be given back in the value PCIVersion.
Function SpcInitPCIBoards:
int16 SpcInitPCIBoards (int16* count, int16* PCIVersion);
Under Linux this function is not available. Instead one must open and close the driver with the standard file functions open and close. The functionality behind this function is the same as the SpcInitPCIBoards function.
30 | MC.31xx Manual |