From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Linux Users

cancel
Showing results for 
Search instead for 
Did you mean: 

INSTALLATION of PyVISA and NI-VISA on UBUNTU 10.04 Lucid LTS (addendum Scientific Linux 6.0)

Hello,

This is my log file to install NI-VISA and Py-VISA on Ubuntu 10.04. This log is the compilation of one day of frustration!!

Although it is not very difficult... I am not a specialist and it always takes me some effort to go back to this level of details.

Installation of NI software will always be a pain and Linux users should really think twice about the choice of their distirbution

(see the end of this message where I recently switched to Scientific Linux for peace of mind).

I do it mainly for back compatibility purpose but thankfully I am not in a critical situation as those who are running labview.

I only need it as an abstraction layer in python (great way to interface work).

Installation of NI-GPIB 488 and VISA on Ubuntu 10.04
STEP 1: PREPARATION
#########  Download the software #################
get NI-VISA-5.0.0.iso
NOTE: The NI-488 gpib driver is useless (only compile w/ Kernel 2.2)
NI-488.2 2.3 - Linux - 32 Bit
Download the iso
extract the files inside the iso using archive software
nivisa-5.0.0f1.tar.gz
############# install the linux source ###########
sudo apt-get install linux-source-2.6.32
############## usefull doc #####################
STEP 2: GPIB and PyVISA
######### install linux gpib driver ############
!! Attention it might not install w/ recent kernel version: tested w/ 2.6.32-21, does not work w/ 2.6.32-27
get the Kernel 2.6 source version (linux-headers)
(read the INSTALL)
sudo apt-get install linux-headers-$(uname -r)
tar zxvf linux-gpib-3.2.11.tar.gz2
./configure
make
sudo make install
################# install pyvisa ###############
PyVISA-1.3
sudo apt-get install ipython
sudo ./setup.py install
#### DO NOT TRY to INSTALL the binary of PyVISA #####
STEP 3: NI-VISA
tar zxvf nivisa-5.0.0f1.tar.gz
################ install nikal ##################
cd rpms
sudo alien -k --scripts nikali-2.0.0-f0.noarch.rpm
sudo dpkg -i nikali_2.0.0-f0_all.deb
cd /usr/local/natinst/nikal/bin/
#check that: cat /etc/natinst/nikal/nikal.dir -> /usr/local/natinst/nikal
sudo echo '/usr/local/natinst/nikal' > /etc/natinst/nikal/nikal.dir
# NI-shell files require modifications to work w/ bash. $1 must be append at the end
# Here is a simple bash file to modify it:
# create a shell file w/ your favorite editor (in my case emacs). The new file name will be modshell.sh
emacs -nw /usr/local/nikal/bin/modshell.sh
# insert in modshell.sh  the following 3 lines (diregard the > chraracter at the beginning of each line, its purpose is
to indicate that you are working inside a file):
>#!/bin/bash
>cat $1 | sed '$a$1' > tmp; mv tmp $1
>sudo chmod u+x $1
# the file should have executable privilege chmod u+x /usr/local/nikal/bin/modshell.sh
sudo ./modshell.sh nikaliInstallerUtility.sh
# The file nikalKernelInstaller.sh seems also to need a modification
> replace the line parseArguments $* by  parseArguments $@
sudo ln -s /bin/bash /bin/sh
sudo ./nikaliInstallerUtility.sh nikaliPostInstall
sudo ./updateNIDrivers
sudo modprobe nikal
# force the nikal module to load at boot. Add
# "nikal" to the file in /etc/modules
sudo depmod -a
################ install nipal ##################
sudo dpkg -i nipalki_2.5.4-f0_i386.deb
sudo dpkg -i nipali_2.5.4-f0_i386.deb
NB: make sure /etc/natinst/nipal/nipal.dir: /usr/local/natinst/nipal
sudo echo '/usr/local/natinst/nipal' > /etc/natinst/nipal/nipal.dir
cd /usr/local/natinst/nipal/bin
# modify the shell file (see above)
# The file palModuleMgr.sh seems also to need a modification
> replace the line parseArguments $* by  parseArguments $@
sudo /usr/local/nikal/bin/./modshell.sh nipalkiInstallerUtility.sh
sudo ./nipalkiInstallerUtility.sh nipalkiPostInstall
# alternative you can run directly
sudo ./palModuleMgr.sh -i -o linux:dir=nipal -t kernelDriver -s demand -c -f /usr/local/natinst/nipal/src/objects/nipalk-unversioned.o
sudo modprobe nipalk
sudo depmod -a
sudo /etc/init.d/nipal restart
################ check modules ##################
Ensure that the nipal kernel module is created in /lib/modules/<kernel-headers>/kernel/natinst/nipal/nipal.ko
Start the application bum (System -> Administration -> Bootup Manager). Search for nipal and click on the checkbox to activate it at boot. Right click on nipal and select the "Start Now" option.
######################### NI-VISA #############
sudo dpkg -i nivisak_5.0.0-b5_i386.deb  nivisa_5.0.0-b5_i386.deb
cat /etc/natinst/vxipnp/nivisa.dir -> /usr/local/vxipnp
cat /etc/natinst/vxipnp/vxipnp.dir -> /usr/local/vxipnp
# run the post install software; either modify the shell file as above
# for some reason the following 2 lines needs also to be added to the shell files on top of the above modifications
>nipalDir="`cat /etc/natinst/nipal/nipal.dir`"
>palModuleMgr="$nipalDir"/bin/palModuleMgr.sh
sudo usr/local/nikal/bin/modshell.sh nivisakInstallerUtility.sh
sudo usr/local/nikal/bin/modshell.sh nivisaInstallerUtility.sh
sudo ./nivisakInstallerUtility.sh nivisakPostInstall
sudo ./nivisaInstallerUtility.sh nivisaPostInstal
# or run directly the postinstall command inside the file
sudo /usr/local/natinst/nipal/bin/palModuleMgr.sh -i -o linux:dir=vxipnp -t kernelDriver -s demand -c -f /usr/local/vxipnp/src/objects/NiViPciK-unversioned.o
sudo /usr/local/natinst/nipal/bin/palModuleMgr.sh -i -o linux:dir=vxipnp -t kernelDriver -s demand -c -f /usr/local/vxipnp/src/objects/NiViPxiK-unversioned.o
sudo updateNIDrivers
################# complement modules  #############
# generic procedure
sudo alien -k xxx-version.rpm
sudo dpkg -i --force-overwrite xxx_version_i386.deb
cd /usr/local/natinst/xxx/
# modify the shell xxxInstallerUtility.sh
sudo /usr/local/nikal/bin/modshell.sh xxxInstallerUtility.sh
sudo ./xxxInstallerUtility.sh xxxPostInstall
#
sudo alien -k niorbi-1.9.3-f0.i386.rpm
sudo alien -k nidimi-1.10.0-f0.i386.rpm
sudo alien -k nirpci-4.2.0-f0.i386.rpm
sudo alien -k nimdnsresponder-1.1.0-f3.i386.rpm
sudo dpkg -i --force-overwrite niorbi_1.9.3-f0_i386.deb
sudo dpkg -i --force-overwrite nidimi_1.10.0-f0_i386.deb
sudo dpkg -i --force-overwrite nirpci_4.2.0-f0_i386.deb
sudo dpkg -i --force-overwrite nimdnsresponder_1.1.0-f3_i386.deb
sudo updateNIdrivers
sudi reboot
visaconf

NOTE: My PyVISA seems broken!

>>> import visa

>>> visa.get_instruments_list()

['ASRL1']
### No gpib devices!!!!

>>> keithley = visa.instrument("GPIB::12")

It could not find the proper library VI_ERROR_LIBRARY_NFOUND: A code library required by VISA could not be located or loaded. I tried both to compile PyVISA w/ pyhton2.5 or python2.6: same problem! If someone has a feedback experience about it, comments are welcome!

Update of the problem (Jan 12 2011): after extensive search I am convinced that there is a bug in the module NiViPciK inside nivisa 5.0. It does not recognize PCI gpib device !!! Seems like there is some miscommunication w/ the Kernel.

Update  (Jan 17 2011): after a long search around the problem, I decided to give up on Ubuntu and I gave it a try to Scientific Linux latest release 6.0. Amazing: it works right out of the box! What a change with the Ubuntu ordeal. Could even succeed to put my latest python package. Well I think that I am going to stick to SL environment for data acquistion. This is for me a rediscovery of Red Hat (my first Linux environement ... back in 94) after some infidelities w/ Slackware, then Debian, a little passage through Libranet and a rather long fidelity to Ubuntu, well it is a pleasant surprise. I discovered the famous yum, which did not exist half a decade ago back when rpms could be scarry: you could send your system to oblivion w/ rpms. First impression, it seems now on par with apt-get. At least with SL6.0 I get a pretty decent environment w/ python 2.6. High five to the SL 6.0 team! Morality, it is way easier to change distribution then try to force the NiVISA encapsulation in Linux.

0 Kudos
Message 1 of 7
(22,052 Views)

Hi,

I'm trying to install NI-VISA following your advices. I encounter several issues with it. I precise that I have installed ubuntu last week so I am a very new user of it.

I got then the 10.10 version.

So, first I got the "unknown tag error" when executing the alien conversion of the nikali.rpm but it seems it doesn't care according to what I saw on others tutorials.

More troubling, I can't find any 'modshell.sh' file and there is no repertory "nikal" at the '/usr/local' location.

Also, when I try to modify the 'nikalKernelInstaller.sh', I get the information : 'modul nikal not found'.

Could you help me about these issues?

Sorry if my questions appear to be very basic.

Bye

0 Kudos
Message 2 of 7
(5,932 Views)

It did not work for me. There were several errors and missing steps.

"unknown tag error"  - this can be ignored if the .deb file is created

0 Kudos
Message 3 of 7
(5,932 Views)

thanks for posting this, it is helpful. However, would it be possible to expand it to include instructions on how to install the c api as well?    

0 Kudos
Message 4 of 7
(5,932 Views)

I am hoping this will work for me on my Ubuntu system. I just need GPIB to work as i understand it .

I plan to use matlab/GPIB to send commands to an Agilent Microwave network analzyer.

I am not sure where the NI-KAL comes in. NI web site says that NI-KAL is unsed in every Linux driver.

wbg

0 Kudos
Message 5 of 7
(5,932 Views)

nikal is the glue to all NI closed-source driver. This is necessary to isolate our binary against changes in the Linux kernel.

0 Kudos
Message 6 of 7
(5,932 Views)

@irwan wrote:

nikal is the glue to all NI closed-source driver. This is necessary to isolate our binary against changes in the Linux kernel.


That's the idea behind. In practise, it never works well - there're just so many things that can change in subtle ways on binary level, between versions as well as build configurations, that a proper isolation takes something like an own VM (which always have to be kept up to date for each kernel version).

 

The whole thing is economically ridiculous: properly mainting something like nikal (what NI doesn't really do) is a full time job for several people. OTOH, writing a proper IIO driver for a DAQ device takes about 6 weeks (yes: been there, done that).

Linux Embedded / Kernel Hacker / BSP / Driver development / Systems engineering
0 Kudos
Message 7 of 7
(3,930 Views)