Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA + Linux: can not read data from serial port

Hi:
I am using Debian/Gnu Linux 2.2 (kernel version 2.4.10) to read data from an instrument serial port using one of the motherboard serial ports.
The visa library version is 2.6. and the instrument is an Agilent 34970A.
The fact is that I can not read anything form the instrument from the
serial port: I tried the example for the serial from included in the visa libraries package. I checked every serial setting both in the instrument and the C program but there is no answer to the simple
question *IDN? (there is no error in the writting).
I make a program with the standart C library calls for the serial port
and it works fine. It also works with VISA + linux + GPIB, and it also works por VISA + Windows + Serial
port.
Has anybody worked with VISA+Linux+ Standart Serial port?
Any advice is wellcomed.

Thanks
0 Kudos
Message 1 of 5
(4,110 Views)
Hello:

Thank you for contacting National Instruments!

Do you have the bindings for the VISA resource name right? i.e. ASRL1::INSTR => dev/tty# you can set this through the visaconf utiliy.

Also have you tried a loopback test? refer http://zone.ni.com/devzone/devzoneweb.nsf/opendoc?openagent&93FD9F2AD3D0641E8625682100067F39&cat=1485C1F3A7F1EF8D862567EC00577686#1

Hope this helps. If you have any questions, please let us know.

Pavan B.
0 Kudos
Message 2 of 5
(4,110 Views)
Ramiro:

We have tested NI-VISA 2.6 with an Agilent 34401A but not a 34970A. We get a valid response from "*IDN?\n". We were using RedHat 6.2 not Debian, but there are no serial differences that I am aware of. Do you have a 34401A to try? Or can you try your 34970A from a RedHat Linux system?

If not, do you have a second PC running Hyperterminal, or perhaps a dumb terminal that you could connect to? I'd like to see if sending an arbitrary string from VISAIC on your Linux machine ("*IDN?\n" or even "Hello World") gets across to the other side successfully.

Interestingly, we came across 1 non-software problem. One serial cable that worked from a Win32 machine did not make sufficient physical contact to the pins on the Linux serial port. Using a d
ifferent cable solved that problem (and that cable also worked on our Win32 PC). Just something you might want to check.

Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments
0 Kudos
Message 3 of 5
(4,110 Views)
Dear Mondrik:

My name is Gustavo Raush. I am working together with Mr. Ramiro Alba to solve our Linux+Visa+Serial communication problem. Even there is an NI's incident problem opened which has the 111863 number from ni.spain, Madrid, we wish to comment the current state of the matter.

We have achived the communication between the linux box and the A34970A instrument, although, surprisely the communication is not possible with a standard null-modem cable (at Windows it is). The cable configuration able to communicate is the next pin out:

2 RD - 3 TD
3 TD - 2 RD
4 DTR - 8 CTS
5 GND - 5 GND
6 DSR - 7 RTS
7 RTS - 6 DSR
8 CTS - 4 DTR
9 RI (Not-Connected)
1 DCD (Not-Connected)

We got the communication by accident. An non-standard cable with th
is configuration was the only able to work. What we want to know is, if this is fortuitous fact or it is an imposition for the serial NI-VISA Linux to work.

Thanks in advance.

G.Raush
0 Kudos
Message 4 of 5
(4,110 Views)
Gustavo:

I talked with a Serial hardware engineer here at NI and we are confused by the pin wiring of your cable. Typically one would wire RTS and CTS together, and wire DTR and DSR together. Yours seems to mix and match these signals rather differently.

Truthfully, none of these 4 wires should matter at all as long as the device is not using hardware handshaking. NI-VISA asserts the RTS and DTR lines during viOpen. On Linux this calls ioctl first with TIOCMGET, then does a bit-OR with TIOCM_RTS and TIOCM_DTR, then calls ioctl with TIOCMSET.

On your computer, can you please verify that after calling viOpen, that pins 4 and 7 are asserted at the PC? The 34970 documentation does call for a standard null-modem cable, which as you
say works fine from a Windows box. Have you tried this from more than 1 Linux machine, or more than 1 version of a Linux distribution such as RedHat (which is what we test with)?

Since you have both a Linux machine and a Windows machine, can they communicate with each other using a standard null-modem cable? Can they communicate with your cable? Just use NIvisaic to open a session and try sending data interactively.

Finally, if things still aren't working, please send me any information you have available about the low-level serial driver, including anything you can get from the setserial command.

As I indicated in a previous email, we have tested Linux VISA with Serial on a RedHat system. I know of other customers who have gotten this to work. In particular, Ed Hill posted an unrelated question about VISA with Serial on Linux but got his system to work. I don't know how to contact Ed directly, but Ed if you're listening, please let us know whether a standard null-modem
cable worked for you.

Gustavo, if you'd like to reach me directly, send me email to dan.mondrik@ni.com

Dan Mondrik
0 Kudos
Message 5 of 5
(4,110 Views)