Software | C/C++ Driver Interface |
|
|
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.
Using the Driver under Linux:
hDrv = open ("/dev/spc0", O_RDWR);
...
close (hDrv);
(c) Spectrum GmbH | 29 |