aboutsummaryrefslogtreecommitdiffstats
path: root/README
blob: af610abed212e39d68b784ca448da427f8d81a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
                          Phidgets for Linux
                    Version 2.1.8, 22 February 2011

Installation
============

     ./configure; make; make install

   This installs the library libphidget21.so and the header phidget21.h.
Java support is compiled in by default, as well as support for Avahi
zeroconf if it is available.

   *Note: USB devices are by default only usable by root in Linux.
          Install udev/hotplug scripts to use Phidgets from a normal 
		  user account (see below).
	
Requirements
============

libusb 0.1

   This is generally already installed. The libusb dev files may need to
be installed - this is usually a package called libusb-dev.

   Some embedded systems / older distros may need to manually set up
the userspace USB device tree. Usually this is handled by udev and 
exists in /dev/bus/usb. This can also be handled by mounting usbfs in 
fstab, which shows up in /proc/bus/usb.

Options
=======

   Configure options:
   
   To disable Java support:

     ./configure --disable-jni
   
   To use mdnsresponder instead of avahi for zeroconf:
   
     ./configure --enable-zeroconf=bonjour
	 
   To disable zeroconf completely:
   
     ./configure --disable-zeroconf
	 
   To use built-ins for .local lookup:
   
     ./configure --enable-zeroconf-lookup

   To enable LabVIEW support:
   
     ./configure --enable-labview
     make LABVIEW_CINTOOLS_PATH=/usr/local/natinst/LabVIEW-2010/cintools
	 
   Note: replace 'LabVIEW-2010' with your version

Usage
=====

   Compile your projects with -lphidget21 and include phidget21.h in the
source file.

Java
====

   Java support is compiled in by default - 'make jni' is no longer
required. This support is provided via JNI extentions compiled into
libphidget21.so.

   To disable Java support, configure with the --disable-jni option.

   The libphidget21.so install path may need to be manually specified
in order for Java to find the library, there are two ways to do this;
either specify in an environment variable:

     LD_LIBRARY_PATH=/usr/lib

   Or specify on the Java command line:
   
     java -Djava.library.path=/usr/lib some_java_app
	 
   Note that the /usr install prefix can be changed during the configure
step by specifying --prefix.

   phidget21.jar is the java half of the Phidgets->Java interface. This
library can be downloaded from the website, or built from source:

     make phidget21.jar
	 
   You must use a phidget21.jar that was built from the same phidget21
library as you have installed or you will get errors.

Hotplug / udev
==============

   On linux, by default, USB devices are not writeable by anybody but 
root.

   On modern systems (kernel > 2.6.7), this is solved with a udev 
ruleset. This is the ideal solution.

   On older systems, this can be solved with a hotplug script.
   
udev
====

   The udev rules file will make all phidgets world writeable (mode 666)
as soon as they are attached. Note that some systems may already have 
generic USB rulesets defined.  The udev rules are run in order from 
smallest to largest number - the Phidgets rules, at number 99, should 
be high enough so that any USB rules will be overridden.

   To Install:

     cp udev/99-phidgets.rules /etc/udev/rules.d

Hotplug
=======

   A hotplug script has been included that will make phidgets writeable 
when the are plugged in.

   Because of this, there can sometimes be an issue accessing/opening a 
device as soon as it is plugged in, before the hotplug script has run to
make it accesible. In this case you will see an error 4: "A phidget 
matching the type and or serial number could not be found."

   Never rely on the hotplug scripts it you're using the phidget manager
to open or access devices as soon as they appear as this will sometimes 
fail.

   To Install:
   
     cp hotplug/* /etc/hotplug/usb
     chmod 755 /etc/hotplug/usb/phidgets
	 
Examples
========

   There are three examples in the examples directory. manager is just a
simple program that will list all phidgets attached to the system, as 
they are plugged in or removed. ifkit connects to an interface kit and 
displays changes, while setting outputs. phidgetsbclist lists all SBCs
on the network (requires seroconf support).

   There is also a seperate download avialable with C examples for most 
phidgets, on the phdigets.com website.

FreeBSD
=======

   The library has been tested with FreeBSD 8.1 and found to work.
The configure/make/make install can be run unmodified.

   When compiling binaries that include libphidget21, the -pthread
flag must be passed to the compiler, because the threading functions
are part of the C library, unlike on Linux.

     gcc example.c -lphidget21 -pthread -o example