Building libpixyusb as a Python module on Linux

Version 1 (John Leimon, 11/02/2014 08:03 pm)

1 1 John Leimon
h1. Building libpixyusb as a Python module on Linux
2 1 John Leimon
3 1 John Leimon
h1. Introduction
4 1 John Leimon
5 1 John Leimon
The libpixyusb library provides a software application programming interface (API) for communicating
6 1 John Leimon
with Pixy over USB. The following procedure will outline the steps to build libpixyusb as a Python module.
7 1 John Leimon
8 1 John Leimon
This procedure assumes the following:
9 1 John Leimon
10 1 John Leimon
* Your system is Linux (with Debian package manager)
11 1 John Leimon
* Pixy firmware has been update to 1.0.2
12 1 John Leimon
* Your system is connected to the internet
13 1 John Leimon
14 1 John Leimon
Instructions for updating the Pixy firmware are here: [[Uploading New Firmware]]
15 1 John Leimon
16 1 John Leimon
h1. 2. Procedure
17 1 John Leimon
18 1 John Leimon
h2. 2.1. Install dependencies for building Python SWIG module
19 1 John Leimon
20 1 John Leimon
Start a terminal application.
21 1 John Leimon
22 1 John Leimon
h3. 2.1.1. Install SWIG
23 1 John Leimon
24 1 John Leimon
In a terminal window type:
25 1 John Leimon
26 1 John Leimon
@# sudo apt-get install swig@
27 1 John Leimon
28 1 John Leimon
h3. 2.1.2. Install libusb-1.0-0-dev
29 1 John Leimon
30 1 John Leimon
In the terminal window type:
31 1 John Leimon
32 1 John Leimon
@sudo apt-get install libusb-1.0-0-dev@
33 1 John Leimon
34 1 John Leimon
h3. 2.1.3. Install g++ (compiler)
35 1 John Leimon
36 1 John Leimon
In the terminal window type:
37 1 John Leimon
38 1 John Leimon
@sudo apt-get install g++@
39 1 John Leimon
40 1 John Leimon
h3. 2.1.4. Install libboost
41 1 John Leimon
42 1 John Leimon
In the terminal window type:
43 1 John Leimon
44 1 John Leimon
@sudo apt-get install libboost-all-dev@
45 1 John Leimon
46 1 John Leimon
h2. 2.2. Build the libpixyusb Python module
47 1 John Leimon
48 1 John Leimon
h3. 2.2.1 Download Pixy source code
49 1 John Leimon
50 1 John Leimon
In the terminal window type:
51 1 John Leimon
52 1 John Leimon
@git clone https://github.com/charmedlabs/pixy.git@
53 1 John Leimon
54 1 John Leimon
h3. 2.2.2. Build the Python module
55 1 John Leimon
56 1 John Leimon
In the terminal window type:
57 1 John Leimon
58 1 John Leimon
@cd pixy/scripts@
59 1 John Leimon
@./build_libpixyusb_swig.sh@
60 1 John Leimon
61 1 John Leimon
h2. 2.3. Try it out!
62 1 John Leimon
63 1 John Leimon
Make sure your Pixy is connected to a USB port on your computer. Then in the terminal window type:
64 1 John Leimon
65 1 John Leimon
@cd ../build/libpixyusb_swig@
66 1 John Leimon
@python get_blocks.py@
67 1 John Leimon
68 1 John Leimon
If all goes well, you should see blocks:
69 1 John Leimon
70 1 John Leimon
@Pixy Python SWIG Example -- Get Blocks@
71 1 John Leimon
@[BLOCK_TYPE=0 SIG=1 X=220 Y= 17 WIDTH= 43 HEIGHT= 35]@
72 1 John Leimon
@[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 42 HEIGHT= 47]@
73 1 John Leimon
@[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 42 HEIGHT= 47]@
74 1 John Leimon
@[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 42 HEIGHT= 47]@
75 1 John Leimon
@[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 42 HEIGHT= 46]@
76 1 John Leimon
@[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 45 HEIGHT= 46]@
77 1 John Leimon
@[BLOCK_TYPE=0 SIG=1 X=219 Y= 23 WIDTH= 43 HEIGHT= 46]@