Rubidium™ MG362x1A SeriesLow-Noise RF/Microwave SignalGenerators : Native Programming : Self Test Command
 
Self Test Command
Table: Self Test Command lists the self test command mnemonic code. This command provides for executing a signal generator self test.
When a TST command is received, the signal generator performs a self test, then returns a single byte, unterminated. A "P" (for pass) or an "F" (for fail). It also generates six self test results bytes.
Self Test Command
Mnemonic Code
Function
TST
Executes a signal generator self test. Extended Status Byte 1 bit 0 is set if self test fails; bit 2 is set when self test is complete.
OSR
Returns the six self test results bytes to the controller.
Refer to Self-Test Messages for the self.test error and messages descriptions. The “P or “F” character placed on the bus by the signal generator self test must be cleared from the output buffer (read by the controller) before another output command, such as OSR, is sent. If it is not cleared, the first character of the next output will be missing.
Self Test Results
The six self test results bytes that identify the reporting function of each bit is shown below.
Self Test Results Byte 1
Not Used
Not Used
Power Supply Voltage(s) are Out of Reg
Not Used
Not Used
Not Used
Not Used
Not Used
Bit 7 (128)
Bit 6 (64)
Bit 5 (32)
Bit 4 (16)
Bit 3 (8)
Bit 2 (4)
Bit 1 (2)
Bit 0 (1)
Self Test Results Byte 2
Not Used
Not Used
Not Used
Not Used
Not Used
Not Used
Not Used
Not Used
Bit 7 (128)
Bit 6 (64)
Bit 5 (32)
Bit 4 (16)
Bit 3 (8)
Bit 2 (4)
Bit 1 (2)
Bit 0 (1)
Self Test Results Byte 3
Not Used
Not Used
Not Used
Not Used
Not Used
Not Used
Not Used
Not Used
Bit 7 (128)
Bit 6 (64)
Bit 5 (32)
Bit 4 (16)
Bit 3 (8)
Bit 2 (4)
Bit 1 (2)
Bit 0 (1)
Self Test Results Byte 4
Not Used
Not Used
Switch Filter Failed
Not Used
Not Used
Not Used
Not Used
Not Used
Bit 7 (128)
Bit 6 (64)
Bit 5 (32)
Bit 4 (16)
Bit 3 (8)
Bit 2 (4)
Bit 1 (2)
Bit 0 (1)
Self Test Results Byte 5
Not Used
Frequency Extension Module (FEM) Failed
Not Used
Not Used
Mod Processor
Failed
Not Used
Not Used
Not Used
Bit 7 (128)
Bit 6 (64)
Bit 5 (32)
Bit 4 (16)
Bit 3 (8)
Bit 2 (4)
Bit 1 (2)
Bit 0 (1)
Self Test Results Byte 6
Self Test is Complete
Not Used
Not Used
RF Was Off When Self Test Started
Not Used
Not Used
Not Used
Not Used
Bit 7 (128)
Bit 6 (64)
Bit 5 (32)
Bit 4 (16)
Bit 3 (8)
Bit 2 (4)
Bit 1 (2)
Bit 0 (1)
Self Test Example
This code demonstrates synchronous read and write commands to a Socket instrument using VISA to perform and return self test results.
/********************************************************************/
/* Read and Write to an Instrument Example */
/* */
/* This code demonstrates synchronous read and write commands to a */
/* Socket instrument using VISA. */
/* */
/* The general flow of the code is */
/* Open Resource Manager */
/* Open VISA Session to an Instrument */
/* Write the Identification Query Using viWrite */
/* Try to Read a Response With viRead */
/* Close the VISA Session */
/********************************************************************/
 
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
/* Functions like strcpy are technically not secure because they do */
/* not contain a 'length'. But we disable this warning for the VISA */
/* examples since we never copy more than the actual buffer size. */
#define _CRT_SECURE_NO_DEPRECATE
#endif
 
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
 
#include "visa.h"
 
static ViSession defaultRM;
static ViSession instr;
static ViStatus status;
static ViUInt32 retCount;
static ViUInt32 writeCount;
static unsigned char buffer[100];
static char stringinput[512];
 
/*
* In every source code or header file that you use it is necessary to prototype
* your VISA variables at the beginning of the file. You need to declare the VISA
* session, VISA integers, VISA strings, VISA pointers, and VISA floating variables.
* Remember that if you are prototyping variables that are to be used as part of the
* VISA session that need this prototyping. As an example, above retCount has been
* prototyped as a static variable to this particular module. It is an integer of
* bit length 32. If you are uncertain how to declare your VISA prototypes refer
* to the VISA help under the Section titled Type Assignments Table. The VISA
* help is located in your NI-VISA directory or folder.
*/
 
int main(void)
{
/*
* First we must call viOpenDefaultRM to get the resource manager
* handle. We will store this handle in defaultRM.
*/
status=viOpenDefaultRM (&defaultRM);
if (status < VI_SUCCESS)
{
printf("Could not open a session to the VISA Resource Manager!\n");
exit (EXIT_FAILURE);
}
/*
* Now we will open a VISA session to a Socket device.
* There are two examples, one using a TCP-IP address (commented out),
* and one using an mDNS hostname. Your address and hostname will be different.
*
* We must use the handle from viOpenDefaultRM and we must
* also use a string that indicates which instrument to open. This
* is called the instrument descriptor. The format for this string
* can be found in the NI-VISA User Manual.
* After opening a session to the device, we will get a handle to
* the instrument which we will use in later VISA functions.
* The two parameters in this function which are left blank are
* reserved for future functionality. These two parameters are
* given the value VI_NULL.
*
*/
status = viOpen(defaultRM, "TCPIP0::172.26.201.114::9001::SOCKET", VI_NULL, VI_NULL, &instr);
if (status < VI_SUCCESS)
{
printf ("Cannot open a session to the device.\n");
goto Close;
}
/*
* Set timeout value to 10000 milliseconds (10 seconds).
*/
status = viSetAttribute (instr, VI_ATTR_TMO_VALUE, 10000);
 
/*
* Set the termination character to '\n' for reads, and enable the termination character.
* This is needed for raw socket devices as there is no other way to determine termination.
*/
status = viSetAttribute(instr, VI_ATTR_TERMCHAR, '\n');
status = viSetAttribute(instr, VI_ATTR_TERMCHAR_EN, VI_STATE_ASSERTED);
 
/*
* For Native selftest and results, we don't use the termination character during reads.
* We must unassert termination enabled in case any of the binary result data happens to be 0x0A.
* Native TST returns exactly 1 byte, no termination.
* Native OSR returns exactly 6 bytes, no termination.
*/
status = viSetAttribute(instr, VI_ATTR_TERMCHAR_EN, VI_STATE_UNASSERTED);
/*
* At this point we now have a session open to the instrument
* We can use this session handle to write
* an ASCII command to the instrument. We will use the viWrite function
* to send the string "TST", asking the device to perform selftest and return a result.
*/
/*
* This program assumes Native language mode is already selected on the instrument.
* Native selftest, TST.
*/
strcpy(stringinput,"TST\n");
status = viWrite (instr, (ViBuf)stringinput, (ViUInt32)strlen(stringinput), &writeCount);
if (status < VI_SUCCESS)
{
printf("Error writing to the device\n");
goto Close;
}
/*
* Now we will attempt to read back a response from the device to
* the selftest query that was sent. We will use the viRead
* function to acquire the data. We will try to read back exactly 1 byte.
* After the data has been read the response is displayed.
*/
status = viRead (instr, buffer, 1, &retCount);
if (status < VI_SUCCESS)
{
printf("Error reading a response from the device\n");
}
else
{
printf("Data read: %*s\n",retCount,buffer);
}
 
/*
* This program assumes Native language mode is already selected on the instrument.
* Native selftest results, OSR.
*/
strcpy(stringinput, "OSR\n");
status = viWrite(instr, (ViBuf)stringinput, (ViUInt32)strlen(stringinput), &writeCount);
if (status < VI_SUCCESS)
{
printf("Error writing to the device\n");
goto Close;
}
 
/*
* Now we will attempt to read back a response from the device to
* the selftest results query that was sent. We will use the viRead
* function to acquire the data. We will try to read back exactly 6 bytes.
* After the data has been read the binary response is displayed.
*/
status = viRead(instr, buffer, 6, &retCount);
if (status < VI_SUCCESS)
{
printf("Error reading a response from the device\n");
}
else
{
printf("Data read: 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X \n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
}
 
 
/*
* Now we will close the session to the instrument using
* viClose. This operation frees all system resources.
*/
Close:
printf("Closing Sessions\nHit enter to continue.");
fflush(stdin);
getchar();
status = viClose(instr);
status = viClose(defaultRM);
 
return 0;
}