Software
Driver functions
(c) Spectrum GmbH
43
Under windows the only part of the device name that is used is the tailing number. The rest of the device name is ignored. Therefore to keep
the examples simple we use the Linux notation in all our examples. The tailing number gives the index of the device to open. The Windows
kernel driver numbers all devices that it finds on boot time starting with 0.
Example for local installed cards
Example for digitizerNETBOX and remote installed cards
IIf the function returns a NULL it is possible to read out the error description of the failed open function by simply passing this NULL to the
error function. The error function is described in one of the next topics.
Function spcm_vClose
This function closes the driver and releases all allocated resources. After closing the driver handle it is not possible to access this driver any
more. Be sure to close the driver if you don’t need it any more to allow other programs to get access to this device.
Function spcm_vClose:
Example:
Function spcm_dwSetParam
All hardware settings are based on software registers that can be set by one of the functions spcm_dwSetParam. These functions sets a register
to a defined value or executes a command. The board must first be initialized by the spcm_hOpen function. The parameter lRegister must
have a valid software register constant as defined in regs.h. The available software registers for the driver are listed in the board specific
part of the documentation below. The function returns a 32 bit error code if an error occurs. If no error occurs the function returns ERR_OK,
what is zero.
Function spcm_dwSetParam
Example:
This example sets the memory size to 16 kSamples (16384). If an error occurred the example will show a short error message
Function spcm_dwGetParam
All hardware settings are based on software registers that can be read by one of the functions spcm_dwGetParam. These functions reads an
internal register or status information. The board must first be initialized by the spcm_hOpen function. The parameter lRegister must have a
valid software register constant as defined in the regs.h file. The available software registers for the driver are listed in the board specific part
drv_handle hDrv; // returns the handle to the opended driver or NULL in case of error
hDrv = spcm_hOpen ("/dev/spcm0"); // string to the driver to open
if (!hDrv)
printf (“open of driver failed\n”);
drv_handle hDrv; // returns the handle to the opended driver or NULL in case of error
hDrv = spcm_hOpen ("TCPIP::192.168.169.14::INST0::INSTR");
if (!hDrv)
printf (“open of driver failed\n”);
void _stdcall spcm_vClose ( // closes the device
drv_handle hDevice); // handle to an already opened device
spcm_vClose (hDrv);
uint32 _stdcall spcm_dwSetParam_i32 ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be modified
int32 lValue); // the value to be set
uint32 _stdcall spcm_dwSetParam_i64m ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be modified
int32 lValueHigh, // upper 32 bit of the value. Containing the sign bit !
uint32 dwValueLow); // lower 32 bit of the value.
uint32 _stdcall spcm_dwSetParam_i64 ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be modified
int64 llValue); // the value to be set
if (spcm_dwSetParam_i32 (hDrv, SPC_MEMSIZE, 16384) != ERR_OK)
printf (“Error when setting memory size\n”);