INST_SEND()
NAME
INST_SEND − Compiled SCPI Commands
SYNOPSIS
INST_SEND (id, cmd_string [,c_expr] );
DESCRIPTION
The instrument send command arranges to have the SCPI information in the cmd_string parameter sent to the instrument defined by the id parameter.
PARAMETERS
id
The user variable name for the instrument. This is the variable name that you assign to the instrument in the INST_DECL or INST_EXTERN command. For example,
INST_DECL (vm, "E1411B", REGISTER);
assigns vm as an instrument data pointer to the E1411B. Now when you use vm as the id in INST_SEND, the instrument send command content will be sent to the HP E1411B.
cmd_string
The string constant containing the SCPI commands. See the instrument’s VXI user manual for information on the SCPI commands.
Any SCPI parameters in the string can be expressed with a format specifier. If a format specifier is used, each [c_expr] parameter that follows contains the C expression that corresponds to the format specifier. This is similar to the C printf function.
NOTE: The format specifier must be the same type that the instrument expects. If, for example, the instrument expects a float number, you must use the %f format specifier. See the instrument’s user’s manual for information on what the SCPI command expects.
NOTE: For MESSAGE configurations, C-SCPI uses the HP SICL iprintf function. See the HP SICL documentation for additional information.
The following are the available format specifiers for register-based cards.
%d : The %d for indicates that an int is used for the numeric expression for the [c_expr] parameter. For example,
int numb1=5;
INST_SEND(vm, "CONF:VOLT:DC %d", numb1);
If a comma is present in the format specifier (comma operator only valid with HP-UX 9.0 or later), the [c_expr] is a pointer to an array of integers instead of a numeric expression. The comma operator is immediately followed by a number indicating the size of the array. The comma can be useful when you have a list of channels to close. For example,
int list[5]={101,102,103,104,105};
INST_SEND (sw, "CLOSE (@%,5d)", list);
NOTE: C-SCPI requires that the comma operator’s corresponding array contain the complete channel list. In the C-SCPI command above, for example, you cannot add another comma operator to specify more channels to be closed.
%f : The %f format indicates that a float is used for the numeric expression for the [c_expr] parameter. For example,
float numb1 = 5.2;
INST_SEND(vm, "CONF:VOLT:DC %f", numb1);
If a comma is present in the format specifier (comma operator only valid for HP-UX 9.0 or later), the [c_expr] is a pointer an an array of floats instead of a numeric expression. The comma operator is immediately followed by a number indicating the size of the array. The comma can be useful to define a waveform for the HP E1340A Arbitrary Function Generator. For example,
float list [5]={.5,1.0,.5,0,-0.5};
INST_SEND (arb, "LIST:VOLT %,5f", list);
NOTE: C-SCPI requires that the comma operator’s corresponding array contain the complete list. In the C-SCPI command above, for example, you cannot add another comma operator to specify more points in the waveform.
%s : The %s format indicates that a string expression without quotations will be used in [c_expr]. For example, char count [5] = "MAX";
INST_SEND(vm, "SAMP: COUNT %s", count) ;
%S : The %S format indicates a string expression with quotations is used for [c_expr]. The preprocessor will add the quotes. For example,
char function[22] = "VOLT:AC";
INST_SEND(vm, "FUNC %S", function);
where the preprocessor will put VOLT:AC in the %S location with quotes around it, resulting in FUNC "VOLT:AC".
%r : The %r format indicates an expression will be used for [c_expr] . For example,
char con[]="Q4 or Q5 or Q6";
INST_SEND(d20, "DIG:TIM:COND:DEF %r",cond);
where cond is enclosed in parentheses: (Q4 or Q5 or Q6).
%<size>b : The %b format indicates that a char array will be used for [c_expr] . <size> is either a number or an asterisk (*). The number indicates the size of the array or the * indicates that the size will be taken from the next parameter (for example, %1024b or %*b).
%<size>a : The %a format indicates that a binary FILE* will be used for [c_expr].<size> is either a number or an asterisk (*). The number indicates the size of the array or the *indicates that the size will be taken from the next parameter (for example, %1024a or %*a).
[c_expr]
The expression that will be used if a format specifier is used in the cmd_string parameter. Any valid C expression can be used. The preprocessor does not check to make sure it is the same type as the format specifier.
COMMENTS
Multiple SCPI commands can be combined in the cmd_string parameter. As with SCPI, these commands are separated by semicolons (;). For example, *RST;SENS:FUNC:VOLT:AC is a common command linked with a SCPI command separated by semicolons.
The cmd_string parameter must be a quoted string. The SCPI command cannot be a variable. If you want to use a string variable, use the cscpi_exe function call.
For MESSAGE configurations, C-SCPI uses the HP SICL iprintf function. See the HP SICL documentation for additional information.
If you send a SCPI command to a message-based card, you may have to include a terminator if the instrument expects one.
On-Line documentation is provided in the form of manual pages. The manual pages contain a SCPI quick reference, list of commands not supported, commands changed, the SCPI command query response types, a list of overlapping commands, and ONSRQ restrictions.
See also INST_QUERY.
EXAMPLE
This example sends the select measurement function to the HP E1411B Multimeter. The %S format specifier indicates that type is declared as a quoted string.
INST_DECL (vm, "E1411B", REGISTER);
main()
{
char type[10]="FRES";
INST_STARTUP();
INST_OPEN (vm, "VXI,24");
INST_SEND (vm, "SENSE:FUNCTION %S", type);
}
— December 08, 1992