LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

programming Agilent N5242A throgh VISA command using LAN

hi,

 

I'm trying to program Agilent N5242A throgh VISA command using LAN with no success.

 

The connection to the N5242a is working but when I'm using the visaWrite command it doesn't response.

 

I used Agilent "connection Expert tool" and it worked.

 

I tried to use Measurment & automation but there is no LAN option there, I have version 4.5.

 

This is what I tried to do:

 

 

 

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 session via TCP/IP to ni.com */
   //status = viOpen (defaultRM, "TCPIP0::ftp.ni.com::21::SOCKET", VI_NULL, VI_NULL, &instr);
   status = viOpen (defaultRM, "TCPIP0::169.254.73.18::5025::SOCKET", VI_NULL, VI_NULL, &instr);
   if (status < VI_SUCCESS)
   {
      printf ("An error occurred opening the session to TCPIP0::ftp.ni.com::21::SOCKET\n");
      viClose(defaultRM);
      exit (EXIT_FAILURE);
   }
  
   viSetAttribute (instr, VI_ATTR_TCPIP_NODELAY, VI_TRUE);
  
  // status = viWrite (instr, "INIT:CONT ON", 13, &count);
      status = viWrite (instr, "*RST",4 , &count);
      status = viWrite (instr, "SENSe1:FREQuency:STARt 4000000000", 33, &count);
      status = viWrite (instr, "SENSe1:FREQuency:STOP 7000000000", 32, &count);

  
 

 

Best Regards

Israel

Best Regards
Boris
0 Kudos
Message 1 of 3
(3,935 Views)

In MAX did you try under Devices and Interface (right-click) to Create New VISA TCP/IP Resource?

http://zone.ni.com/devzone/cda/tut/p/id/10108

0 Kudos
Message 2 of 3
(3,905 Views)

TCPIP SOCKET (or SCPI-Raw) connection normally requires termination code (Line Feed, 0x0A) being sent, but not found in your viWrite() call.

 

Write as like:

status = viWrite (instr, "*RST\n", 5, &count);

 

Also I think viPrintf() will be easier than viWrite() for ASCII write, because you dont have to specify the byte-length to send. Once you set buffer operation attributes like below:

 

status = viSetAttribute( instr, VI_ATTR_WR_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS);
status = viSetAttribute( instr, VI_ATTR_RD_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS);

 

then you can now use viPrintf() like below:

status = viPrintf( instr, "SENSe1:FREQuency:STOP %ld\n", (ViInt32)7000000000);

 

 

0 Kudos
Message 3 of 3
(3,894 Views)