
64
(c) Spectrum Instrumentation GmbH
Gathering information from the card
Programming the Board
The driver is then locked until the error is read out using the error function spcm_dwGetErrorInfo_i32. Any
calls to other functions will just return the error code ERR_LASTERR showing that there is an error to be read
out.
This error locking functionality will prevent the generation of unseen false commands and settings that may lead to totally unexpected behav
-
ior. For sure there are only errors locked that result on false commands or settings. Any error code that is generated to report a condition to
the user won’t lock the driver. As example the error code ERR_TIMEOUT showing that the a timeout in a wait function has occurred won’t
lock the driver and the user can simply react to this error code without reading the complete error function.
As a benefit from this error locking it is not necessary to check the error return of each function call but just checking the error function once
at the end of all calls to see where an error occurred. The enhanced error function returns a complete error description that will lead to the
call that produces the error.
Example for error checking at end using the error text from the driver:
This short program then would generate a printout as:
All error codes are described in detail in the appendix. Please refer to this error description and the descrip
-
tion of the software register to examine the cause for the error message.
Any of the parameters of the spcm_dwGetErrorInfo_i32 function can be used to obtain detailed information on the error. If one is not interested
in parts of this information it is possible to just pass a NULL (zero) to this variable like shown in the example. If one is not interested in the
error text but wants to install its own error handler it may be interesting to just read out the error generating register and value.
Example for error checking with own (simple) error handler:
Gathering information from the card
When opening the card the driver library internally reads out a lot of information from the on-board eeprom. The driver also offers additional
information on hardware details. All of this information can be read out and used for programming and documentation. This chapter will
show all general information that is offered by the driver. There is also some more information on certain parts of the card, like clock machine
or trigger machine, that is described in detail in the documentation of that part of the card.
All information can be read out using one of the spcm_dwGetParam functions. Please stick to the “Driver Functions” chapter for more details
on this function.
char szErrorText[ERRORTEXTLEN];
spcm_dwSetParam_i64 (hDrv, SPC_SAMPLERATE, 1000000); // correct command
spcm_dwSetParam_i64 (hDrv, SPC_MEMSIZE, -345); // faulty command
spcm_dwSetParam_i64 (hDrv, SPC_POSTTRIGGER, 1024); // correct command
if (spcm_dwGetErrorInfo_i32 (hDrv, NULL, NULL, szErrorText) != ERR_OK) // check for an error
{
printf (szErrorText); // print the error text
spcm_vClose (hDrv); // close the driver
exit (0); // and leave the program
}
Error ocurred at register SPC_MEMSIZE with value -345: value not allowed
uint32 dwErrorReg;
int32 lErrorValue;
uint32 dwErrorCode;
spcm_dwSetParam_i64 (hDrv, SPC_SAMPLERATE, 1000000); // correct command
spcm_dwSetParam_i64 (hDrv, SPC_MEMSIZE, -345); // faulty command
spcm_dwSetParam_i64 (hDrv, SPC_POSTTRIGGER, 1024); // correct command
dwErrorCode = spcm_dwGetErrorInfo_i32 (hDrv, &dwErrorReg, &lErrorValue, NULL);
if (dwErrorCode) // check for an error
{
printf (“Errorcode: %d in register %d at value %d\n”, lErrorCode, dwErrorReg, lErrorValue);
spcm_vClose (hDrv); // close the driver
exit (0); // and leave the program
}
Summary of Contents for M2p.59 Series
Page 190: ......