更新系統
$ sudo apt-get update
$ sudo apt-get upgrade
安裝rpi-source
$ sudo apt-get install -y git bc bison flex libssl-dev libncurses5-dev
$ sudo apt install raspberrypi-kernel-headers
$ sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
$ sudo rpi-source
安裝Linux-gpib
$ sudo apt-get install -y tk-dev build-essential texinfo texi2html libcwidget-dev libncurses5-dev libx11-dev binutils-dev bison flex libusb-1.0-0 libusb-dev libmpfr-dev libexpat1-dev tofrodos subversion autoconf automake libtool
$ sudo mkdir linux-gpib
$ cd linux-gpib/
$ sudo svn checkout svn://svn.code.sf.net/p/linux-gpib/code/trunk linux-gpib-code
下圖為目錄結構,有兩個資料夾linux-gpib-kernel與linux-gpib-user
$ cd linux-gpib-kernel
$ sudo make
$ sudo make install
$ cd /home/pi/linux-gpib/linux-gpib-code/linux-gpib-user
$ sudo ./bootstrap
$ sudo ./configure
$ sudo make
$ sudo make install
GPIB設定
$ sudo apt-get install -y vim
尋找gpib.conf
$ sudo find / -name gpib.conf
根據尋找的gpib.conf位置去修改檔案
$ sudo vim /usr/local/etc/gpib.conf
- 按I進入修改。
- 將ni_pic改為ni_usb_b或raspi_gpib
- 按下Esc
- 鍵入:wq按下Enter退出Vim
修改前:
修改後:
$ sudo modprobe ni_usb_gpib
$ sudo ldconfig
$ sudo gpib_config
$ lsmod
用Python測試GPIB
Testing GPIB operation
Python-application to talk GPIB from Raspberry Pi
Python-application to talk VISA from Raspberry Pi
$sudo pip3 install pyvisa pyvisa-py gpib-ctypes