summaryrefslogtreecommitdiff
path: root/documentation/pyparallel.rst
blob: 00c0b952cb137b12b4df652b4994c9c989d1b86f (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
161
162
163
164
165
============
 pyParallel
============

.. note:: This module is in development (since years ;-)

Overview
========
This module encapsulates the access for the parallel port. It provides backends
for Python running on Windows and Linux. Other platforms are possible too but
not yet integrated.

This module is still under development. But it may be useful for developers.

Copyright (C) 2001-2003 Chris Liechti <cliechti(at)gmx.net>

Here is the `project page on SourceForge`_ and here is the `SVN repository`_.

.. _`project page on SourceForge`: http://sourceforge.net/projects/pyserial/
.. _`SVN repository`: http://sourceforge.net/svn/?group_id=46487


Features
--------
* same class based interface on all supported platforms
* port numbering starts at zero, no need to know the port name in the user program
* port string (device name) can be specified if access through numbering is inappropriate


Requirements
------------
* Python 2.2 or newer
* "Java Communications" (JavaComm) extension for Java/Jython


Installation
------------
Extract files from the archive, open a shell/console in that directory and let
Distutils do the rest: ``python setup.py install``

The files get installed in the "Lib/site-packages" directory in newer Python versions.

The windows version needs a compiled extension and the giveio.sys driver for
Windows NT/2k/XP. The extension module can be compiled with Distutils with
either MSVC or GCC/mingw32.

It is released under a free software license, see LICENSE.txt for more details.


Short introduction
==================
::

    >>> import parallel
    >>> p = parallel.Parallel()     # open LPT1
    >>> p.setData(0x55)


Examples
--------
Please look in the SVN Repository. There is an example directory where you can
find a simple terminal and more.
http://pyserial.svn.sourceforge.net/viewvc/pyserial/trunk/pyparallel/examples/


API
===

.. module:: parallel

.. class:: Parallel

    .. method:: __init__(port)

        Open given parallel port.

    .. method:: setData(value)

        Apply the given byte to the data pins of the parallel port.

    .. method:: setDataStrobe(level)

        Set the "data strobe" line to the given state.

    .. method:: setAutoFeed(level)

        Set "auto feed" line to given state.

    .. method:: setInitOut(level)

        Set "initialize" line to given state.

    .. method: setSelect(level)

        Set "select" line to given state.

    .. method:getInError()

        Set "Error" line to given state.

    .. method:: getInSelected()

        Read level of "select" line.

    .. method:: getInPaperOut()

        Read level of "paper out" line.

    .. method:: getInAcknowledge()

        Read level of "Acknowledge" line.

    .. method: getInBusy()

        Read level of "busy" line.


.. module:: parallel.parallelutil

.. class:: BitaccessMeta

    This mix-in class adds a few properties that allow easier bit access to the
    data lines. (D0 .. D7) e.g. p.D0 refers to the first bit of the data
    lines.

.. class:: VirtualParallelPort

    This class provides a virtual parallel port implementation, useful
    for tests and simulations without real hardware.


Notes
=====

Linux
-----
1. The :manpage:`lp(4)` module must be unloaded, ``rmmod lp``. ``lp`` claims
   exclusive access to the port and other programs won't be able to use it.

2. The :manpage:`ppdev(4)` module needs to be loaded, ``modprobe ppdev``. When
   ``udev`` is in use, (default with 2.6 kernels) this will create a
   ``/dev/parport0``.

3. The user needs to have write permissions to ``/dev/parport0``. Many
   distributions have an ``lp`` group that owns the device; the simplest is to
   add the user account to this group. Simply changing permissions on the
   device is not the best strategy as they will be reverted to their defaults
   next time the driver is loaded.


Windows
-------
The giveio driver must be installed as the module needs direct access to the
hardware. This also means that USB parallel port adapters won't be supported.


Misc
====
References
----------
* Python: http://www.python.org/
* Jython: http://www.jython.org/
* Java@IBM: http://www-106.ibm.com/developerworks/java/jdk/ (JavaComm links are
  on the download page for the respective platform JDK)
* Java@SUN: http://java.sun.com/products/