OS - Linux
Getting Started with Linux
Welcome to using Phidgets with Linux!
Install
The first step to using Phidgets with Linux is installing the Phidget22 libraries.
We provide prebuilt packages for Debian, Ubuntu, and their derivatives.
If you're running a supported distros, we recommend using the Package Install. For other systems, you can use the Source Install.
We recommend installing with our Install Script. If you prefer not to run a script, or the script cannot detect your distro, use the Manual Install.
To run the install script and install phidget22, enter the following command in the terminal:
curl -fsSL https://www.phidgets.com/downloads/setup_linux | bash -
apt install -y libphidget22
If the curl command is not found: apt install curl
and try again.
Additional Packages
You may also want to apt install the following optional packages:
- libphidget22-dev: The C development libraries for Phidget22
- libphidget22extra: Extra runtime library required for the Network Server and Admin tools
- phidget22networkserver: The Phidget Network Server, which enables use of Phidgets over your network
- libphidget22java: The Java libraries for Phidget22
- phidget22admin: An administrator utility for listing Phidgets and upgrading firmware
- phidget22wwwjs: The JavaScript libraries for Phidget22. This package also installs the HTML examples which can be accessed through the web interface
The libraries are now installed on your machine. Next, set up the UDev rules below.
Setting udev Rules
By default, Linux restricts regular users from accessing physical hardware for security reasons. As a result, you typically need root privileges to access Phidgets. For example:
sudo ./HelloWorld
To avoid using sudo every time, you can set up a udev rules file that automatically grants access based on Phidget's USB vendor ID. Create a file named 99-libphidget22.rules with the following content:
# All current and future Phidgets - Vendor = 0x06c2, Product = 0x0030 - 0x00af
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="06c2", ATTRS{idProduct}=="00[3-a][0-f]", MODE="666"
The MODE="666" grants read/write access to the matching device for all users. Save this file to "/etc/udev/rules.d". Once in place, you'll be able to run Phidget programs as a regular user without permission issues.
Verify
The best way to verify that your libraries are working properly is to compile and run an example program.
First, download and unpack this C example:
Note: If using the Debian intallation methods, you will need to install the libphidget22-dev package to use the C libraries for Phidget22
Next, open the terminal at the example location. Compile the example by entering the following command:
gcc HelloWorld.c -o HelloWorld -lphidget22
Run the HelloWorld example:
./HelloWorld
Your terminal should look something like this:
The HelloWorld program will simply communicate when a Phidget has been attached or detached, as can be seen in the image above.
Your Phidget is now able to communicate with your development machine. The next step is selecting a programming language so you can start to write some code!
Programming
Ready to write some code? Select one of the programming languages below:
Older Versions
If you need older versions of the Phidget22 Linux libraries, click here.
If you need Phidget21 Linux Libraries, click here.
Software License
By downloading Linux Source you agree to adhere to the terms of the The 3-Clause BSD License.