Specifications
Chapter 18 301
PSA Programming Examples
Using C with the CALCulate:DATA:COMPress? RMS Command
PSA Programming Examples
/* get number of bytes in length of postceeding data
 and put this in sBuffer*/
viRead (viPSA,(ViBuf)sBuffer,2,&lBytesRetrieved); 
/* Put the returned data into sBuffer */
viRead (viPSA,(ViBuf)sBuffer,sBuffer[1] - ’0’,&lBytesRetrieved);
/* append a null to sBuffer */
sBuffer[lBytesRetrieved] = 0;
/* convert sBuffer from ASCII to integer */
lNumberBytes = atoi(sBuffer); 
/*calculate the number of returned values given the number of bytes.
 REAL 64 binary data means each number is represented by 8 bytes */
 lNumberPoints = lNumberBytes/sizeof(ViReal64);
/*get and save returned data into an array */
viRead (viPSA,(ViBuf)adDataArray,lNumberBytes,&lBytesRetrieved);
/* read the terminator character and discard */
viRead (viPSA,(ViBuf)sBuffer,1, <hrowaway); 
/*print message to the standard output*/
printf("Querying instrument to see if any errors in Queue.\n");
/* loop until all errors read */
do 
{
 viPrintf (viPSA,"SYST:ERR?\n");  /* check for errors */
 viRead (viPSA,(ViBuf)sBuffer,80,&lLength);/* read back last error message */
 sBuffer[lLength] = 0;  /* append a null to byte count */
 printf("%s\n",sBuffer); /* print error buffer to display */
} while (sBuffer[1] != ’0’);










