Linux build instructions
This was created by Gabe Knuth (just so you don't direct questions at Gerry).
The following are instructions for building libpinproc and pypinproc on Linux. These instructions have been tested with various flavors of Debian, including various versions of Ubuntu (including 14.04) and Xubuntu, as well as Debian Wheezy. It has worked on many different types of hardware, including Raspberry Pi, Mini-ITX, and ODROID, as well as in Parallels Desktop and VMWare Fusion virtual machines.
If you want to take the more automated approach, you can download the debian toolkit here. Follow the instructions there to install (it's really easy).
If you use any other build, distro, or hardware platform your mileage may vary. Also, I’m no Linux guy, so if I don’t use the right terms or do something stupid, let me know so we can change the procedure. All of this work was done in the terminal. If you have a GUI, feel free to replace steps with their GUI equivalent.
Throughout this article you'll see references to <filename> and <directory>. Since the specific names of the files you'll download can change, I've left these in as placeholders. Essentially, whatever file you download, that's what you put in place of <filename> in the command line. Typically after extracting that file, a directory will be created that is very similar to the file name. You can see this by typing "ls" without the quotes at the command prompt. That new directory is the name that you use in place of <directory>. Forgive me if that's obvious, but I just wanted to make sure that everyone understands what I mean from the saltiest old Linux guy to the person who barely knows that it exists.
1 Prerequisite Packages
1. Upgrade your apt-get repositories:
sudo apt-get update
2. Install libudev-dev
sudo apt-get install libudev-dev
3. Download and compile libusbx-1.xxx.
Download the bits from: http://sourceforge.net/projects/libusbx/
tar -xjf <filename> cd <directory> ./configure make sudo make install
4. Install libusb-dev
sudo apt-get install libusb-dev
5. Download and compile libusb-1.x. (Note this is slightly different than Step 3, which is libusbX). In late April 2014, this file (version 1.0.18) could not be opened via the tar -xjf command due to an oddball problem. It had to be opened on a Mac or Windows machine, then transferred via thumb drive or network drive mapping.
Download bits from http://www.libusb.org/
tar -xjf <filename> cd <directory> ./configure make sudo make install
6. Install cmake
sudo apt-get install cmake
7. Download and compile libftdi1
Download bits from http://www.intra2net.com/en/developer/libftdi/download.php (There are many versions of ftdi. This is the one you want, so don’t just google for it.)
tar -xjf <filename> cd <directory> mkdir bin cd bin cmake .. make sudo make install
8. Install g++ (It’s probably installed already, but do this just to make sure)
sudo apt-get install g++
9. Install python-dev
sudo apt-get install python-dev
10. Install python-setuptools
sudo apt-get install python-setuptools
11. Download and compile yaml-cpp.
There are many versions of YAML. They switched the API after version 3.0, so you want to use 3.0 or under. Downloads bits from https://code.google.com/p/yaml-cpp/downloads/list. Installing YAML takes a long time, like 20 mins.
tar -xzf <filename> (note the parameter change - this is a gzip file, not a bz2 file) cd <directory> mkdir bin cd bin cmake .. make sudo make install
12. Set up Environment Variables
This step is more or less necessary. You could edit the CMakeLists.txt file and setup.py files for the next few packages, but setting the paths makes things much easier. Simply cutting and pasting the below commands should do everything you need.
export C_INCLUDE_PATH=$(find /usr/ -name ftdi.h -printf '%h\072') export CPLUS_INCLUDE_PATH=$(find /usr/ -name ftdi.h -printf '%h\072') export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH echo "export LD_LIBRARY_PATH="$LD_LIBRARY_PATH >> ~/.bashrc echo "export C_INCLUDE_PATH="$C_INCLUDE_PATH >> ~/.bashrc echo "export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH >> ~/.bashrc
What's happening here is that we have to build up some environment variables so that libpinproc and pypinproc know where to look for things. Specifically, it's looking for the usb and ftdi drivers that actually connect to the P-ROC. These commands find the ftdi.h file so you don't have to know where it is and add it to the C_INCLUDE_PATH and CPLUS_INCLUDE_PATH environment variables. As for LD_LIBRARY_PATH, this tells the linker (part of compiling process) where it can find the libpinproc libraries. We know this is in /usr/local/lib, so it's hardcoded.
Then, the "echo..." commands add those paths to your profile so that every time you log in or start a new terminal session those environment variables are there.
13. Give normal users rights to ftdi drivers
The last thing we have to do before moving on to the pinball-specific stuff is to give normal users access to the ftdi and usb drivers. You can do this step now, but you'll have to reboot at some point. You don't have to do it before continuing, but at some point you'll need to reboot before you can run your game.
You'll need to create a file somewhere called 50-P-ROC.rules. Inside this file, you'll want to enter the following lines:
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE:="0666", GROUP="users" SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE:="0666", GROUP="users"
Save the file, then copy the it to the /etc/udev/rules.d folder (you'll need root access to do this):
sudo cp 50-P-ROC.rules /etc/udev/rules.d
rules.d isn't processed until boot, so remember to reboot at some point.
2 Pinball-Specific Stuff
You've made it through the hard stuff! It's smooth sailing from here (probably).
2.1 libpinproc
This process was done with libpinproc-master, but you can also use libpinproc-dev. It’s available from https://github.com/preble/libpinproc. Make sure that you pick the proper branch (dev or master), then click “Download Zip” on the right side of the screen. The dev branch may have a few differences in this process as it relates to the CMakeList.txt file, but you should be able to figure it out. Run it first and see what happens.
Unzip your file using and switch into that directory:
unzip <filename> cd <directory>
When that’s done, it’s time to compile. Cross your fingers and run:
mkdir bin cd bin cmake -DBUILD_SHARED_LIBS=”ON” .. make sudo make install
If you succeed, congrats! Move on to the pypinproc section.
If not, check the error. If it says something isn’t found, see if you can find it. The errors are usually pretty cryptic, like “cannot find -lusb”. In that specific situation, make sure you installed libusb-dev above and have the environment variables set up properly (you can type "export" from the command line to check them). If you have other errors, see if it references a file (like ftdi.h). Then try to find that file. Here’s one way to search the filesystem for a file:
cd / sudo find . -name <filename>
It will respond with the path of any occurrences of that file. Usually, the one you want is somewhere in the /usr tree. Make a note of that path and add it to the the environment variables as described above. You could also add it to the CMakeLists.txt file's include_directories line, but if you do that you'll always have to edit that file if you ever want to update libpinproc.
From there, recompile libpinproc. You may not have to do this, but I did it just in case. From the libpinproc directory, do:
rm -r bin
...then follow the compile instructions above again (starting with “mkdir bin”). Again, this might not be necessary, but it worked for me.
2.2 pypinproc
Thankfully, this part is much easier. Download pypinproc from https://github.com/preble/pypinproc. Make sure that you pick the proper branch (dev or master), then click “Download Zip” on the right side of the screen.
Unzip your file using and switch into that directory:
unzip <filename> cd <directory>
After that, you’re ready to install:
sudo python setup.py install
Again, if you have errors, look for file names, find the files, and add the paths, just like in libpinproc.
2.3 pyprocgame
As long as you set up the environment variables (the last step before moving to the pinball-specific stuff), you're all set to install pyprocgame. Download it from https://github.com/preble/pyprocgame, again choosing the proper branch (dev or master). Unzip your file, switch into that directory, and install:
unzip <filename> cd <directory> sudo python setup.py install
2.4 PyYAML
Download PyYAML from http://pyyaml.org/download/pyyaml/. The version used for this document was 3.10, but 3.x should work just fine.
tar -xzf <filename> cd <directory> sudo python setup.py install
2.5 pygame
pygame is a more flexible alternative to pyglet that does not require OpenGL to do anything. The main benefit of using pygame on the Raspberry Pi is that since it doesn’t require OpenGL, you’ll be able to use the desktop DMD, albeit a less functional one. If you choose to use pyglet, see the instructions below.
Pygame is installed by default in Raspbian, but you may need to install SDL If you have a problem. Try your game without SDL, but if you require it, follow these instructions:
To install SDL (I used version 1.2), download it from http://www.libsdl.org/download-1.2.php
tar -xjf <filename> cd <directory> ./configure make sudo make install
2.6 PIL
You’ll know you need this if you try to run your game and get an error looking for a module called IMAGES.
Download the package from http://effbot.org/downloads/Imaging-1.1.7.tar.gz
tar -xzf <filename> cd <directory> sudo python setup.py install
3 Loose Ends
At this point, you can probably run your game, but if you do you’ll likely get errors looking for other modules. Here are some of the modules that people require. You may not require them, or you might require more. The basic process is the same–chase them down and install them.
3.1 OSC
You’ll know you need this if you try to run your game and get an error looking for a module called OSC or if you already know that your game is using the OSC capabilities that allow you to control your game through an OSC interface (like TouchOSC on iOS devices).
There are many OSC libraries for python. You want pyOSC, available from https://trac.v2.nl/wiki/pyOSC. The version used here is 0.3.5b.
tar -xzf <filename> cd <directory> sudo python setup.py install
3.2 GLU
You’ll know you need this if you try to run your game and get an error looking for a module called GLU. This is easy to get, just run:
sudo apt-get install freeglut3-dev
3.3 pyglet
pyglet is a python library which handles windows, graphics, and inputs that pyprocgame uses. You can download it from http://www.pyglet.org/download.html. You’ll need the tar.gz version (scroll down a bit). Games typically run on the pygame library, however there are some reasons to choose pyglet over pygame. What you actually do, though (and why), is outside the scope of this article. pyglet's presence overrides pygame, only install pyglet if you know you need it.
tar -xzf <filename> cd <directory> sudo python setup.py install
Unfortunately, pyglet uses OpenGL in X Window to show the desktop DMD, which isn’t supported on Raspberry Pi (or at least in Raspbian). If you want to use the desktop DMD, this is not the solution for you. You should use pygame instead.