AnsweredAssumed Answered

Can't trace data from n9340

Question asked by wenyijin on Jul 29, 2010
Latest reply on Jun 19, 2011 by petersk
Dear Forums:
The code is written by C.I have tested my code many times, but I can't get data from n9340.The error msg is time out, I don't why it happen.
Someone help me? Thanks very much.
This is my first use English submit a post.
#include <visa.h>
#include <stdio.h>
void err_handler(ViSession vi, ViStatus err)
     char err_msg&#91;1024&#93;={0};
     viStatusDesc (vi, err, err_msg);
     printf ("ERROR = %s\n", err_msg);
int main () {

  ViSession defaultRM, viN9340B;
  char buf &#91;256&#93; = {0};
  //double datastring&#91;10000&#93;;//dataArray&#91;800&#93;
  ViStatus viStatus = 0,err=0;
  float buffer&#91;800&#93;={0};

  /* Open session to LAN device at address  */
  viStatus=viOpenDefaultRM (&defaultRM);
  viStatus=viOpen(defaultRM, "TCPIP0::", VI_NULL,VI_NULL, &viN9340B);
  viSetAttribute(viN9340B, VI_ATTR_TMO_VALUE, 5000);
       printf("Could not open a session to LAN device\n");

  /* Initialize device */
  viPrintf (viN9340B, "*RST\n");

  /* Send an *IDN? string to the device */
  viPrintf (viN9340B, "*IDN?\n");

  /* Read results */
  viScanf (viN9340B, "%t", &buf);

  /* Print results */
  printf ("Instrument identification string:\n%s\n", buf);

  /*Set the analyzer center frequency to 698MHZ*/
  viPrintf(viN9340B,"SENS:FREQ:CENT 800e6\n");
  /*Set the analyzer span to 8MHZ*/
  viPrintf(viN9340B,"SENS:FREQ:SPAN 8e6\n");

  /*Set IF Bandwidth to 20kHz */
  viPrintf(viN9340B,"SENSe:BANDwidth 20e3");

  /*Set number of points to 801*/
  viPrintf(viN9340B,"SENSe:SWEep:POINts 801");

  /*Turn continuous sweep off*/
  viPrintf(viN9340B, "INITiate:CONTinuous ON\n");
  /* Set the data trace format to REAL 32 bits */
  err=viPrintf(viN9340B,"TRAC:FORM REAL 32\n");
  if (err < VI_SUCCESS)
       err_handler(viN9340B, err);

  err=viPrintf(viN9340B,"TRAC1:MODE WRIT\n");
  if (err < VI_SUCCESS)
       err_handler(viN9340B, err);

  /*Ask for the Data*/
  if (err < VI_SUCCESS)
       err_handler(viN9340B, err);

  if (err < VI_SUCCESS)

  /* Close session */
  viClose (viN9340B);
  viClose (defaultRM);