SendScpi
Send a SCPI command string to a device that is defined in the configuration file.
The section name of the device is used as the alias to the device.
Parameters:
alias
The name of the SCPI device as defined in the configuration file.
command
The SCPI command string to send to the device.
timeoutSec
The amount of time in seconds to wait for a response.
buffer
The buffer that will contain the response.
bufferLen
The size of the buffer (used to prevent an overrun).
Return Value:
The number of characters that were copied into the buffer (including the termination character).
Note: while ATE Systems cal devices always respond with at least an "Ack", the PNA does not. Therefore calling this function using the name of a PNA will prefix the call with "*WAI" and suffix the call with "*OPC?" in order to force a response from the PNA if the command does not end in a '?'.
Prototype Signature:
int SendScpi(char* alias, char* command, int timeoutSec, char * buffer, int bufferLength);
An example of how this function is used is shown below.
#include <malloc.h>
#include <string.h>
#include "api.h"
int main()
{
success successful;
int bufferLen = 1024;
char* responseBuffer = malloc(bufferLen);
int bytesCopied;
//Initialize the library with a specific configuration file
successful = Initialize("C:\\Temp\\MyConfig.ini");
if(successful)
{
//Get the PNA's identity string
bytesCopied = SendScpi("PNA-X","*IDN?", 60, responseBuffer, bufferLen);
if(bytesCopied > 0)
printf("PNA's identity is: %s" ,responseBuffer);
else
{
bytesCopied = GetErrorMessage(responseBuffer, bufferLen);
if(bytesCopied > 0)
printf("SCPI send returned error: %s" ,responseBuffer);
else
printf("An unidentified error occurred");
}
}
}