Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Serial-to-USB devices via NI-Visa, PyVisa in a Virtual Machine

Hi everyone,

 

I'm having problems controlling an instrument with an RS232 port using a serial-to-USB adapter. To give some background. I'm trying to set up a virtual machine using PyVisa and the NI-VISA & NI488.2 drivers for instrumentation control/testing in our lab so that we can replicate our setup easily. Here is my setup (in VirtualBox):

 

OS: Scientific Linux 6 (RHEL derivative)

Drivers: NI-Visa 5.1.2, NI488.2 2.9.0

PyVisa 1.3

 

I have no problems controlling ethernet connected instruments this way. I also have no problems with either the ethernet connected instruments or the serial-to-usb devices when I use the same setup in Windows (win 7).

 

However, in Scientific Linux, I can't seem to address the serial port correctly. Since there is no auto assignment of serial ports in linux (like "COMx" ports in windows), I believe I need to set up a static route between the USB port (/dev/ttyUSBx) that the device is connected to and the serial port (/dev/ttySx) using visaconf but I don't seem to have the ability to access/write the configuration. Instead I get this error when running visaconf:

 

***********************************************************************************

Error 13 occurred at Call Library Function Node in IniconfWrapper.lvclass:OpenIni.vi->VisaconfModel.lvclass:OpenVisaconfModel.vi->InitializeVisaconf.vi->main.vi->Startup.vi

 

Possible reason(s):

LabVIEW:  File is not a resource file.
=========================
NI-488:  Shareable board exclusively owned.

***********************************************************************************

 

Everything in visaconf works except when I try to write/save the configuration. I have root privileges, etc... so I'm wondering if this is a problem because I'm in a virtual machine or if I have some other setup problem with the drivers (which seems unlikely given that I can control the ethernet devices).

 

(btw, I should probably mention that I'd prefer to use linux instead of windows so that our lab enviroment & authentication is like the rest of our network).

 

 

Message 1 of 9
(8,930 Views)

Hi,

 

This is a known issue and R&D has been informed about this (CAR# 351912). I do also want to let you know that NI-VISA 5.1.2 does not support Scientific Linux 6.

Rohama K.
0 Kudos
Message 2 of 9
(8,907 Views)

Hi Rohama,

 

Thanks for the quick reply.

Just so I'm clear, is the issue you describe a problem with:

 

1. NI-VISA configuration in any virtual machine?

or

2. NI-VISA with SL6 and similar linux distributions?

or

3. NI-VISA configuration in SL6 inside a virtual machine?

 

Thanks again,

Fred

0 Kudos
Message 3 of 9
(8,905 Views)

Hi Fred,

 

It has to do with NI-VISA with linux distributions. In general though, SL6 is not supported by the current version of NI-VISA. 

Rohama K.
0 Kudos
Message 4 of 9
(8,903 Views)

Understood. Thanks.

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

Hi all,

 

FYI, I actually got this to work... and (perhaps by accident) using a virtual machine may be the only way to circumvent the problem with visaconf on linux installations. Perhaps this will prove useful to others so here's what I did (I should mention the host operating system is CentOS 5.x):

 

1. In the Virtualbox settings:

Enable one of the serial ports in the "Serial Ports" option of your virtual machine:

    Port Number: COM1

    Port Mode: Host Device

    Port/File Path: /dev/ttyUSB0 (this might be different depending on if you have other USB devices attached)

 

2. On the host machine:

make sure you have write access to the USB port.

For example:  "sudo chmod 777 /dev/ttyUSB0" should work

 

3. On the guest machine:

Make sure you have write access to the serial port, in my case I just fired up python with sudo privileges... or you could do the same thing as on the host

 

Now I can control both ethernet & serial (via USB) devices w/ pyvisa from python :).

 

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

Thanks for letting us know!

Rohama K.
0 Kudos
Message 7 of 9
(8,883 Views)

I know this is an old topic, but I'm interested in knowing more.

 

What I've gathered form this thread and the NI Linux driver support page is that NI-VISA is confirmed to work on RHEL6, but not SL6/CentOS6 (without massive fiddling anyways). However, these two distributions are supposed to be binary compatible clones of RHEL, so what are they missing that prevents them from working the exact same way?

 

Supposedly, USB support is limited in kernels newer than 2.6.24, but RHEL6 is using 2.6.32 and is fully supported. What are they doing special, and can their methods be applied to CentOS6 or SL6 in some way?

0 Kudos
Message 8 of 9
(8,695 Views)

It isn't that NI-VISA won't work on SL6/CentrOS6, we just have not tested it. Have you already seen this post? I don't know how much fiddling was requirement, but it looks like they were able to install NI-VISA on SL6.

 

GPIB-USB-HS it only support up to kernel 2.6.24. NI-488.2, the driver, is supported in RHEL6, but I don't think you will be able to use GPIB-USB-HS since is explicitly mentioned in system requirements to only be support up to kernel 2.6.24. 

Rohama K.
0 Kudos
Message 9 of 9
(8,674 Views)