parallel port access? 
Author Message
 parallel port access?

I would like to be able to control the individual
lines of the parallel port using Python.

Anyone know of any Class packages to do this or
do I need to write one myself?

Thanks for any help.

DOC



Mon, 19 May 2003 03:00:00 GMT  
 parallel port access?

Quote:

> I would like to be able to control the individual
> lines of the parallel port using Python.

> Anyone know of any Class packages to do this or
> do I need to write one myself?

What platform?


Mon, 19 May 2003 03:00:00 GMT  
 parallel port access?

Quote:


> > I would like to be able to control the individual
> > lines of the parallel port using Python.

> > Anyone know of any Class packages to do this or
> > do I need to write one myself?

> What platform?

There has been so many questiona about sieral and parallel port access
throuhg Python.  How come it hasn't been put into the distrabution?  I
realize that it is platform specific, but so are other things that are
in Python.  Or even put it in as a platform specific module like the gl
module.

--
Curtis Jensen

http://www-bioeng.ucsd.edu/~cjensen/
FAX (425) 740-1451



Sat, 24 May 2003 03:00:00 GMT  
 parallel port access?
Hello there
    I have only been glancing at c.l.python occasionally, and haven't
seen any of the previous discussions on this topic. I have also been
thinking about accessing the printer port (and I/O ports in general).
Alhough none of this is tested (or even tried out in reality!), the
original poster might find it useful. Or not. I solicit further
details...

I'm assuming that you are using some flavour of Windows. In order to
access the LPT port _directly_, you want to be able to do a form of I/O
port access. This is a rough equivalent to the BASIC code

PEEK(inport)
and
POKE(outport, value)

in 80X86 assembly language these take the form

in reg, (port)   ; and
out (port), val

It is not advisable to be able to do this on a platform such as the PC,
since you can crash your machine etc. very easily like this. Depending
on the Operating System you are running, you might not even be allowed
to do this even in Assembly language - it involves a change in
operating system privileges which you may not be allowed to do.

The way that you _are_ allowed to write directly to ports is via some
form of 'driver'. Again, depending of the OS you are using, this might
be a VxD, or a DLL. A Search on Altavista etc. for the 'Parallel Port
FAQ' will give you lots of information on this.

FWIW, my intention is to use python to access a simple ISA I/O card
containing 2x 8255 PIOs and a 8254 counter/timer. I'm probably going to
write, or modify, a VxD written by Karen(?) Hazzah, and downloadable
from the Windows Developer's Journal, which is designed to 'grant'
access to the ports in a range (eg the printer port, exactly what the
original poster wants). I'll then use either Mark Hammond's Win32
extensions, or Sam Rushing's 'CallDLL' methods, to access the VxD from
Python via the CreateFile(...) etc. functions.

This might be rather more detail than you require, and I may be making
things too complicated, but at least I've exposed my plans to the
world...

    Regards
    Jon Nicoll



Quote:

> > I would like to be able to control the individual
> > lines of the parallel port using Python.

> > Anyone know of any Class packages to do this or
> > do I need to write one myself?

> What platform?

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 25 May 2003 03:00:00 GMT  
 parallel port access?

Quote:

>There has been so many questiona about sieral and parallel port access
>throuhg Python.  How come it hasn't been put into the distrabution?  I
>realize that it is platform specific, but so are other things that are
>in Python.  Or even put it in as a platform specific module like the gl
>module.

    The parallel port and serial port controls are really platform specific.
Windows has a standard serial interface but for the parallel interface,
windows 98 allows direct access but nt requires a kernel driver.  Unix systems
probably have there own oddities ranging from non-pc machines which may not
have a parallel or serial port to whatever access mechanisms linux/*BSD/HURD
have.  The task would probably come fairly close to writing a new driver
for each platform.

--
------------------------------------------------------------------
                            |
Suchandra Thapa             | "There are only two kinds of math books.

                            | sentence, and those you cannot read
                            | beyond the first page."
                            |                       -C.N. Yang
------------------------------------------------------------------



Mon, 26 May 2003 03:00:00 GMT  
 parallel port access?

Quote:

>It is not advisable to be able to do this on a platform such as the PC,
>since you can crash your machine etc. very easily like this. Depending
>on the Operating System you are running, you might not even be allowed
>to do this even in Assembly language - it involves a change in
>operating system privileges which you may not be allowed to do.

    You can directly read and write ports on windows 95/98/me(?) but
you need to create a vxd to access ports on NT and 2000.  From my experience
it is relatively safely to directly modify the parallel port as long as
nothing else is trying to access it.  If you have control over the workstation,
you can insure the latter condition by not printing and/or only running
one program that interfaces with the parallel port.  
    This approach has worked well in trying to control some
electronics (a laser and some PMTs to be exact) over the parallel port.
The parallel port faq has some code samples and some pointers.  There is
also a DLL floating around but that is only a wrapper around inport and
outport calls.  You can probably use SWIG to get a python interface for
that.

--
------------------------------------------------------------------
                            |
Suchandra Thapa             | "There are only two kinds of math books.

                            | sentence, and those you cannot read
                            | beyond the first page."
                            |                       -C.N. Yang
------------------------------------------------------------------



Mon, 26 May 2003 03:00:00 GMT  
 parallel port access?

Quote:
>>>>> Suchandra Thapa wrote on Thu, 07 Dec 2000 08:26:19 GMT:

Suchandra> The parallel port and serial port controls are really
Suchandra> platform specific.  Windows has a standard serial interface
Suchandra> but for the parallel interface, windows 98 allows direct
Suchandra> access but nt requires a kernel driver.  Unix systems
Suchandra> probably have there own oddities ranging from non-pc
Suchandra> machines which may not have a parallel or serial port to
Suchandra> whatever access mechanisms linux/*BSD/HURD have.  The task
Suchandra> would probably come fairly close to writing a new driver
Suchandra> for each platform.

Well, on many unices there is the common idea of a printer beeing a
file:-) This means you have a driver sitting behind it, and simply
writing to that file sends your data to the port.
Direct access to the ports in general requires kernel-level priorities
or root-access and going through ioperm or such...

I don't see a need to write a driver for each platform, only DOS
probably, which doesn't bring one by itself [1].

So I would say you'll need a generic wrapper function for sending data
to the OS, that's it. On Unix I'd say all the problem reduces to find
out wether there is a printer-file and what it is called.

Greetings,
Jochen

[1] Then a parport is such a simple device, for most applications you
really don't need a real driver...
--
Einigkeit und Recht und Freiheit                 http://www.*-*-*.com/
    Libert, galit, Fraternit                GnuPG key: 44BCCD8E
        Sex, {*filter*} and rock-n-roll



Mon, 26 May 2003 03:00:00 GMT  
 parallel port access?

Quote:

> Well, on many unices there is the common idea of a printer beeing a
> file:-) This means you have a driver sitting behind it, and simply
> writing to that file sends your data to the port.
> Direct access to the ports in general requires kernel-level priorities
> or root-access and going through ioperm or such...

> So I would say you'll need a generic wrapper function for sending data
> to the OS, that's it. On Unix I'd say all the problem reduces to find
> out wether there is a printer-file and what it is called.

I'm guessing that many of the people interested in this kind of thing
(direct control of parallel port) want to use it to directly twiddle the
bits, in order to gain quick-n-dirty control of some external
equipment.  I doubt treating the parallel port as a file would provide
the necessary control other than maybe leaving the data bits set to the
last bit pattern written.  The handshake lines would be hopeless, and
bidirectional control (reading individual bits) would likely be lost as
well.


Tue, 27 May 2003 00:56:56 GMT  
 parallel port access?

Quote:

>>>>>> Suchandra Thapa wrote on Thu, 07 Dec 2000 08:26:19 GMT:

>Suchandra> The parallel port and serial port controls are really
>Suchandra> platform specific.  Windows has a standard serial interface
>Suchandra> but for the parallel interface, windows 98 allows direct
>Suchandra> access but nt requires a kernel driver.  Unix systems
>Suchandra> probably have there own oddities ranging from non-pc
>Suchandra> machines which may not have a parallel or serial port to
>Suchandra> whatever access mechanisms linux/*BSD/HURD have.  The task
>Suchandra> would probably come fairly close to writing a new driver
>Suchandra> for each platform.

>Well, on many unices there is the common idea of a printer beeing a
>file:-)

It could be that the questioner doesnt care about printers, and
just wants to mess with the parallel port in order to
manipulate some non-printer HW connected to it.  But I just
guessing.

--
Grant Edwards                   grante             Yow!  I'm EMOTIONAL
                                  at               now because I have
                               visi.com            MERCHANDISING CLOUT!!



Tue, 27 May 2003 01:18:06 GMT  
 parallel port access?

Quote:

>>>>>> Suchandra Thapa wrote on Thu, 07 Dec 2000 08:26:19 GMT:

>Well, on many unices there is the common idea of a printer beeing a
>file:-) This means you have a driver sitting behind it, and simply
>writing to that file sends your data to the port.
>Direct access to the ports in general requires kernel-level priorities
>or root-access and going through ioperm or such...

    Although, the printer may be  just a file on unices,
I see generic access to the parallel port as being more than just printing.
I take generic access to the parallel port to mean that you are able to
change the status of individual lines so you can interface with
various devices that don't follow the standard printer methods (I'm not
sure this exists witht the variety of printers out there).  If I were
to use the parallel interface from the python library, I would certainly
hope for this type of functionality since printing to files can be done
without the interface by opening a connection to lptx on windows/nt or
opening a pipe to lpr on unix.
    Also a printer does not correspond to a parallel port.  The printer
may in actuallity be a networked printer down the hall or something
in another location entirely.  

Quote:
>I don't see a need to write a driver for each platform, only DOS
>probably, which doesn't bring one by itself [1].

>So I would say you'll need a generic wrapper function for sending data
>to the OS, that's it. On Unix I'd say all the problem reduces to find
>out wether there is a printer-file and what it is called.

>[1] Then a parport is such a simple device, for most applications you
>really don't need a real driver...

    It depends on what mode you are using and what device you are communicating
with.  If you look at timing diagrams for ECP or EPP operations, there
are fairly strigent requirements on the how quickly certain lines have to
change.  E.g. if you raise line 1 (ACK) to +5 V to indicate a data transfer
then you must raise lines 2-9 (data) to the values being transfered
within x milisecs or the device will raise one or more of the control lines
to indicate an error and you need to deal with that then.  Also devices
like scanners and zip drives have more complex protocols than printers.

    For windows nt a kernel driver must be written since the os doesn't
provide the required functionality and you can't go around the os and
access the port directly.  With windows 98, you can access the hardware but
it's probably better to write a driver and use that. I'm not sure what the
requirements are for various unixes, but I suspect a driver would be required
to get the level of control I've indicated.

--
------------------------------------------------------------------
                            |
Suchandra Thapa             | "There are only two kinds of math books.

                            | sentence, and those you cannot read
                            | beyond the first page."
                            |                       -C.N. Yang
------------------------------------------------------------------



Wed, 28 May 2003 00:51:02 GMT  
 parallel port access?

Quote:
>>>>> Peter Hansen wrote on Thu, 07 Dec 2000 11:56:56 -0500:

>> So I would say you'll need a generic wrapper function for sending data
>> to the OS, that's it. On Unix I'd say all the problem reduces to find
>> out wether there is a printer-file and what it is called.

Peter> I'm guessing that many of the people interested in this kind of thing
Peter> (direct control of parallel port) want to use it to directly twiddle the
Peter> bits, in order to gain quick-n-dirty control of some external
Peter> equipment.
[...]

Oh, sure. But in that situation (q-a-d, hack, ...) there needn't be a
generic nor clean solution, IMHO:) And "hacking" a parallel port isn't
really that hard, I'd say it's more than easy compared to some unusual
equipment you're going to access.
Moreover such stuff usually doesn't need to be widely portable...

I'd actually suggest the original poster to write a driver for that (a
kernel module on Linux, e.g.). This should provide a abstraction-layer
at the highest possible layer and as such simplify the application!

To my mind low-level hardware-support shouldn't go into a "language"!
Abstraction from the different philosophies of generic parport access
would make sense, though.

Greetings,
Jochen
--
Einigkeit und Recht und Freiheit                 http://www.*-*-*.com/
    Libert, galit, Fraternit                GnuPG key: 44BCCD8E
        Sex, {*filter*} and rock-n-roll



Tue, 27 May 2003 18:49:52 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Parallel Port access

2. Parallel port access in VW

3. Parallel Port Access

4. Parallel Port Access from DOS Debug

5. (PythonWin) parallel port access?

6. Parallel Port access from TCL

7. VisualAge - accessing the parallel port

8. Accessing parallel port from clarion

9. problems accessing the parallel port

10. Accessing parallel port in Win32forth

11. Direct access to parallel port

12. How to access parallel ports using LabVIEW?

 

 
Powered by phpBB® Forum Software