LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Hyperterminal and TCP/IP

Please can anyone help?
 
We have a device with which we can communicate very easily using TCP/IP in Hyperterminal.  We can type in commands, the device executes the commands, and we get instant responses with no problems at all.  The device is using a standard IP address (192.168.0.221)  and a port (14001).
 
However, when we send the same commands using the Visa 'viPrintf' function, and read the response using 'viScanf', we get very erratic responses, and sometimes, no response at all.
 
The actual commands we are using are: to send data (example command)  'viPrintf(app_ip,"A PR P\n") and to read, 'viScanf(app_ip,"%t",databuf).   The 'app_ip' is the handle for the opened device, and as we sometimes get responses to our commands, and replies from it, it must be opened correctly.  We are using the standard 0x0A termination character for the read command.  The responses are only a few bytes, and are only sent in response to a request command.
 
The biggest puzzle is that it works without a problem in Hyperterminal - so what is the difference, and how can we emulate whatever Hypertermnal is doing?
 
All help is very much appreciated,
 
Many thanks,
Allen Cherry
0 Kudos
Message 1 of 9
(8,955 Views)
viPrintf() is a "buffered" IO function, therefore the function may not always send the given command immediately.  Plus, the default buffered IO behaviour for WRITE operation is "flush when full", which means the WRITE operation will be performed when the buffer gets full.  I think you can change this behaviour using the code below, to "fulsh on access" which will enforce to send the given command immediately.

vs = viSetAttribute( app_ip, VI_ATTR_WR_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS);


0 Kudos
Message 2 of 9
(8,919 Views)
Makoto,
 
Many thanks for your response - I appreciate your help.
Unfortunatley, we have already tried changing the buffer modes as you have suggested, but without any success.
 
Do you have any other ideas?
 
Many thanks,
 
Allen
0 Kudos
Message 3 of 9
(8,916 Views)

Alan,

What version of Visa are you using?

Have you run NI-Spy to see if you are actually reading the data correctly and Visa is returning an error?

Not sure what you mean by: " We are using the standard 0x0A termination character for the read command". Do you mean that you have enabled termchar?

 

0 Kudos
Message 4 of 9
(8,898 Views)

Cymrieg,

Thanks for the input - we are using the Agilent Visa version 14.1 - this is being used as we have to also talk to the Agilent E5801A LAN - IEEE488 converter box, and we are control several items on the GPIB bus through this, as well as other items directly on the LAN - and also items on RS232!!  It is a complex system!

Yes - we have enbaled the temination character 0x0A for the piece of equipment that is being reluctant to talk.

We have chacked the data using 'Ethereal' as a LAN port sniffer, and compared it with the Hyperterminal and the visa.  The Hyperterminal apears to send each character individually, but even breaking the viPrintf statemen down so it sends each character as a separate statement still does not give a predictable response as does Hyperterminal.

All ideas greatfully received!

Many thanks,

Allen Cherry

0 Kudos
Message 5 of 9
(8,896 Views)

Allen,

Arrh you nean E5810. We happen to have several of those on our network

Can you access the web page on the E5810. Select "Find and Query Instruments". You will see the sicl names.

I just used NI VISA with a resource string of "tcpip0::10.99.12.102::hpiblan,7::instr"

The 10.99.12.102 is an ip address on our network. The hpiblan,7 is the sicl name for a gpib instrument on address 7 attached to the E5810a. I connected and managed to do a *idn? successfully.

You should be able to do the same with Agilent Visa also.

 

 

0 Kudos
Message 6 of 9
(8,880 Views)

Hi Cymrieg,

Yes - thanks for correcting my typo -it is the E5810.  But it is not an item connected through the E5810 that is causing the problem - it is a piece of equipment that has a LAN - Serial convertor connected to it, not an IEEE488 bus.  We can communicate with all the GPIB items throught the E5810 without any problems (and to the RS232 connection on the E5810).

There must be something that Hyperterminal is doing that we are missing .... but what??

 

Many thanks

 

Allen

0 Kudos
Message 7 of 9
(8,875 Views)
Hi Allen,
 
If you have compared the byte contents of the data sent through Hyperterminal and Visa, and they are exactly the same, the problem may well lie in the timing of the bytes being sent.  Your custom hardware may be expecting a specific timing of the data being sent, and the Hyperterminal just happens to meet those requirements while the visa functions do not (maybe its sending the data too fast?).
 
Regards,
Way S.
NI UK Applications Engineer 
0 Kudos
Message 8 of 9
(8,861 Views)
When you replace all the viPrintf() calls with viWrite(), do you still have the same symptom?  If the problem is concerning to VISA's internal I/O buffering, viWrite() may fix the problem because it bypasses buffering.
0 Kudos
Message 9 of 9
(8,858 Views)