blob: fc87e90d86c72b321b84bc20286bc357835bcf91 [file] [log] [blame]
cliechti619e4562002-07-31 00:53:06 +00001#!/usr/bin/env python
cliechti7d2b78a2002-08-07 22:39:54 +00002# parallel port access using the ppdev driver
cliechti619e4562002-07-31 00:53:06 +00003
4import struct
5import fcntl
6import os
7
8#----
9# Generated by h2py 0.1.1 from <linux/ppdev.h>,
10# then cleaned up a bit by Michael P. Ashton and then a gain by chris ;-)
11
12def sizeof(type): return struct.calcsize(type)
13def _IOC(dir, type, nr, size): return (dir << _IOC_DIRSHIFT ) | (type << _IOC_TYPESHIFT ) |\
14 (nr << _IOC_NRSHIFT ) | (size << _IOC_SIZESHIFT)
cliechti7d2b78a2002-08-07 22:39:54 +000015def _IO(type, nr): return _IOC(_IOC_NONE, type, nr, 0)
16def _IOR(type,nr,size): return _IOC(_IOC_READ, type, nr, sizeof(size))
17def _IOW(type,nr,size): return _IOC(_IOC_WRITE, type, nr, sizeof(size))
cliechti619e4562002-07-31 00:53:06 +000018
19_IOC_SIZEBITS = 14
20_IOC_SIZEMASK = (1 << _IOC_SIZEBITS ) - 1
21_IOC_NRSHIFT = 0
22_IOC_NRBITS = 8
23_IOC_TYPESHIFT = _IOC_NRSHIFT + _IOC_NRBITS
24_IOC_TYPEBITS = 8
25_IOC_SIZESHIFT = _IOC_TYPESHIFT + _IOC_TYPEBITS
26IOCSIZE_MASK = _IOC_SIZEMASK << _IOC_SIZESHIFT
27IOCSIZE_SHIFT = _IOC_SIZESHIFT
28_IOC_WRITE = 1
29_IOC_DIRSHIFT = _IOC_SIZESHIFT + _IOC_SIZEBITS
30IOC_IN = _IOC_WRITE << _IOC_DIRSHIFT
31_IOC_READ = 2
32IOC_INOUT = (_IOC_WRITE | _IOC_READ) << _IOC_DIRSHIFT
33IOC_OUT = _IOC_READ << _IOC_DIRSHIFT
34
35_IOC_NONE = 0
36PP_IOCTL = ord('p')
cliechti7d2b78a2002-08-07 22:39:54 +000037PPCLAIM = _IO(PP_IOCTL, 0x8b)
cliechti619e4562002-07-31 00:53:06 +000038PPCLRIRQ = _IOR(PP_IOCTL, 0x93, 'i')
39
40PPDATADIR = _IOW(PP_IOCTL, 0x90, 'i')
cliechti7d2b78a2002-08-07 22:39:54 +000041PPEXCL = _IO(PP_IOCTL, 0x8f)
cliechti619e4562002-07-31 00:53:06 +000042PPFCONTROL = _IOW(PP_IOCTL, 0x8e, 'BB')
43PPGETFLAGS = _IOR(PP_IOCTL, 0x9a, 'i')
44PPGETMODE = _IOR(PP_IOCTL, 0x98, 'i')
45PPGETMODES = _IOR(PP_IOCTL, 0x97, 'I')
46PPGETPHASE = _IOR(PP_IOCTL, 0x99, 'i')
47PPGETTIME = _IOR(PP_IOCTL, 0x95, 'll')
48PPNEGOT = _IOW(PP_IOCTL, 0x91, 'i')
49PPRCONTROL = _IOR(PP_IOCTL, 0x83, 'B')
50PPRDATA = _IOR(PP_IOCTL, 0x85, 'B')
51#'OBSOLETE__IOR' undefined in 'PPRECONTROL'
cliechti7d2b78a2002-08-07 22:39:54 +000052PPRELEASE = _IO(PP_IOCTL, 0x8c)
cliechti619e4562002-07-31 00:53:06 +000053#'OBSOLETE__IOR' undefined in 'PPRFIFO'
54PPRSTATUS = _IOR(PP_IOCTL, 0x81, 'B')
55PPSETFLAGS = _IOW(PP_IOCTL, 0x9b, 'i')
56PPSETMODE = _IOW(PP_IOCTL, 0x80, 'i')
57PPSETPHASE = _IOW(PP_IOCTL, 0x94, 'i')
58PPSETTIME = _IOW(PP_IOCTL, 0x96, 'll')
59PPWCONTROL = _IOW(PP_IOCTL, 0x84, 'B')
60PPWCTLONIRQ = _IOW(PP_IOCTL, 0x92, 'B')
61PPWDATA = _IOW(PP_IOCTL, 0x86, 'B')
62#'OBSOLETE__IOW' undefined in 'PPWECONTROL'
63#'OBSOLETE__IOW' undefined in 'PPWFIFO'
64#'OBSOLETE__IOW' undefined in 'PPWSTATUS'
65PPYIELD = _IO(PP_IOCTL, 0x8d)
66PP_FASTREAD = 1 << 3
67PP_FASTWRITE = 1 << 2
68PP_W91284PIC = 1 << 4
69PP_FLAGMASK = PP_FASTWRITE | PP_FASTREAD | PP_W91284PIC
70PP_MAJOR = 99
71_ASMI386_IOCTL_H= None
72_IOC_DIRBITS = 2
73_IOC_DIRMASK = (1 << _IOC_DIRBITS) - 1
74_IOC_NRMASK = (1 << _IOC_NRBITS) - 1
75_IOC_TYPEMASK = (1 << _IOC_TYPEBITS ) - 1
76
77def _IOC_DIR(nr): return (nr >> _IOC_DIRSHIFT) & _IOC_DIRMASK
78def _IOC_NR(nr): return (nr >> _IOC_NRSHIFT) & _IOC_NRMASK
79def _IOC_SIZE(nr): return (nr >> _IOC_SIZESHIFT) & _IOC_SIZEMASK
80def _IOC_TYPE(nr): return (nr >> _IOC_TYPESHIFT) & _IOC_TYPEMASK
81def _IOWR(type, nr, size): return _IOC(_IOC_READ | _IOC_WRITE, type, nr , sizeof(size))
82
83__ELF__ = 1
84__i386 = 1
85__i386__ = 1
86__linux = 1
87__linux__ = 1
88__unix = 1
89__unix__ = 1
90i386 = 1
91linux = 1
92unix = 1
93
94#-------- Constants from <linux/parport.h>
95
96PARPORT_CONTROL_STROBE = 0x1
97PARPORT_CONTROL_AUTOFD = 0x2
98PARPORT_CONTROL_INIT = 0x4
99PARPORT_CONTROL_SELECT = 0x8
100PARPORT_STATUS_ERROR = 8
101PARPORT_STATUS_SELECT = 0x10
102PARPORT_STATUS_PAPEROUT = 0x20
103PARPORT_STATUS_ACK = 0x40
104PARPORT_STATUS_BUSY = 0x80
105
106IEEE1284_MODE_NIBBLE = 0
107IEEE1284_MODE_BYTE = 1
108IEEE1284_MODE_COMPAT = 1<<8
109IEEE1284_MODE_BECP = 1<<9
110IEEE1284_MODE_ECP = 1<<4
111IEEE1284_MODE_ECPRLE = IEEE1284_MODE_ECP | (1<<5)
112IEEE1284_MODE_ECPSWE = 1<<10
113IEEE1284_MODE_EPP = 1<<6
114IEEE1284_MODE_EPPSL = 1<<11
115IEEE1284_MODE_EPPSWE = 1<<12
116IEEE1284_DEVICEID = 1<<2
117IEEE1284_EXT_LINK = 1<<14
118
119IEEE1284_ADDR = 1<<13
120IEEE1284_DATA = 0
121
122PARPORT_EPP_FAST = 1
123PARPORT_W91284PIC = 2
124#----
125
126class Parallel:
127 """Class for controlling the pins on a parallel port
128
129 This class provides bit-level access to the pins on a PC parallel
130 port. It is primarily designed for programs which must control
131 special circuitry - most often non-IEEE-1284-compliant devices
132 other than printers - using 'bit-banging' techniques.
133
134 The current implementation makes ioctl() calls to the Linux ppdev
135 driver, using the Python fcntl library. It might be rewritten in
136 C for extra speed. This particular implementation is written for
137 Linux; all of the upper-level calls can be ported to Windows as
138 well.
139
140 On Linux, the ppdev device driver, from the Linux 2.4 parallel
141 port subsystem, is used to control the parallel port hardware.
142 This driver must be made available from a kernel compile. The
143 option is called "Support user-space parallel-port drivers". When
144 using the module, be sure to unload the lp module first: usually
145 the lp module claims exclusive access to the parallel port, and if
146 it is loaded, this class will fail to open the parallel port file,
147 and throw an exception.
148
149 The primary source of information about the Linux 2.4 parallel
150 port subsystem is Tim Waugh's documentation, the source for which
151 is available in the kernel tree. This document (called,
152 appropriately enough, "The Linux 2.4 Parallel Port Subsystem"),
153 thoroughly describes the parallel port drivers and how to use
154 them.
155
156 This class provides a method for each of the ioctls supported by
157 the ppdev module. The ioctl methods are named, in uppercase, the
158 same as the ioctls they invoke. The documentation for these
159 methods was taken directly from the documentation for their
160 corresponding ioctl, and modified only where necessary.
161
162 Unless you have special reason to use the Linux ioctls, you should
163 use instead the upper-level functions, which are named in
164 lowerCase fashion and should be portable between Linux and
165 Windows. This way, any code you write for this class will (or
166 should) also work with the Windows version of this class.
167
168 """
169 def __init__(self, port = 0):
170 if type(port) == type(""):
171 self.device = port
172 else:
cliechti7d2b78a2002-08-07 22:39:54 +0000173 self.device = "/dev/parport%d" % port
cliechti619e4562002-07-31 00:53:06 +0000174 self._fd = os.open(self.device, os.O_RDWR)
175 self.PPEXCL()
176 self.PPCLAIM()
177 self.setDataDir(1)
178 self.setData(0)
179
180 def __del__(self):
181 self.PPRELEASE()
cliechti7d2b78a2002-08-07 22:39:54 +0000182 if self._fd is not None:
183 os.close(self._fd)
cliechti619e4562002-07-31 00:53:06 +0000184
185 def timevalToFloat(self, timeval):
186 t=struct.unpack('ll', timeval)
187 return t[0] + (t[1]/1000000.0)
188
189 def floatToTimeval(self, time):
190 sec = int(time)
191 usec = int(time*1000000.0)
192 return struct.pack('ll', sec, usec)
193
194 def PPCLAIM(self):
195 """
196 Claims access to the port. As a user-land device driver
197 writer, you will need to do this before you are able to
198 actually change the state of the parallel port in any
199 way. Note that some operations only affect the ppdev driver
200 and not the port, such as PPSETMODE; they can be performed
201 while access to the port is not claimed.
202 """
cliechti7d2b78a2002-08-07 22:39:54 +0000203 fcntl.ioctl(self._fd, PPCLAIM)
cliechti619e4562002-07-31 00:53:06 +0000204
205 def PPEXCL(self):
206 """
207 Instructs the kernel driver to forbid any sharing of the port
208 with other drivers, i.e. it requests exclusivity. The PPEXCL
209 command is only valid when the port is not already claimed for
210 use, and it may mean that the next PPCLAIM ioctl will fail:
211 some other driver may already have registered itself on that
212 port.
213
214 Most device drivers don't need exclusive access to the
215 port. It's only provided in case it is really needed, for
216 example for devices where access to the port is required for
217 extensive periods of time (many seconds).
218
219 Note that the PPEXCL ioctl doesn't actually claim the port
220 there and then---action is deferred until the PPCLAIM ioctl is
221 performed.
222 """
cliechti7d2b78a2002-08-07 22:39:54 +0000223 fcntl.ioctl(self._fd, PPEXCL)
cliechti619e4562002-07-31 00:53:06 +0000224
225 def PPRELEASE(self):
226 """
227 Releases the port. Releasing the port undoes the effect of
228 claiming the port. It allows other device drivers to talk to
229 their devices (assuming that there are any).
230 """
231 fcntl.ioctl(self._fd, PPRELEASE)
232
233 def PPYIELD(self):
234 """
235 Yields the port to another driver. This ioctl is a kind of
236 short-hand for releasing the port and immediately reclaiming
237 it. It gives other drivers a chance to talk to their devices,
238 but afterwards claims the port back. An example of using this
239 would be in a user-land printer driver: once a few characters
240 have been written we could give the port to another device
241 driver for a while, but if we still have characters to send to
242 the printer we would want the port back as soon as possible.
243
244 It is important not to claim the parallel port for too long,
245 as other device drivers will have no time to service their
246 devices. If your device does not allow for parallel port
247 sharing at all, it is better to claim the parallel port
248 exclusively (see PPEXCL).
249 """
250 fcntl.ioctl(self._fd, PPYIELD)
251
252 def PPNEGOT(self, mode):
253 """
254 Performs IEEE 1284 negotiation into a particular
255 mode. Briefly, negotiation is the method by which the host and
256 the peripheral decide on a protocol to use when transferring
257 data.
258
259 An IEEE 1284 compliant device will start out in compatibility
260 mode, and then the host can negotiate to another mode (such as
261 ECP).
262
263 The 'mode' parameter should be one of the following constants
264 from PPDEV:
265
266 - IEEE1284_MODE_COMPAT
267 - IEEE1284_MODE_NIBBLE
268 - IEEE1284_MODE_BYTE
269 - IEEE1284_MODE_EPP
270 - IEEE1284_MODE_ECP
271
272 The PPNEGOT ioctl actually does two things: it performs the
273 on-the-wire negotiation, and it sets the behaviour of
274 subsequent read/write calls so that they use that mode (but
275 see PPSETMODE).
276 """
277 fcntl.ioctl(self._fd, PPNEGOT, struct.pack('i', mode))
278
279 def PPSETMODE(self, mode):
280 """
281 Sets which IEEE 1284 protocol to use for the read and write
282 calls.
283
284 The 'mode' parameter should be one of the following constants
285 from PPDEV:
286
287 - IEEE1284_MODE_COMPAT
288 - IEEE1284_MODE_NIBBLE
289 - IEEE1284_MODE_BYTE
290 - IEEE1284_MODE_EPP
291 - IEEE1284_MODE_ECP
292 """
293 fcntl.ioctl(self._fd, PPSETMODE, struct.pack('i', mode))
294
295 def PPGETMODE(self):
296 """
297 Retrieves the IEEE 1284 mode being used for read and
298 write. The return value is one of the following constants
299 from PPDEV:
300
301 - IEEE1284_MODE_COMPAT
302 - IEEE1284_MODE_NIBBLE
303 - IEEE1284_MODE_BYTE
304 - IEEE1284_MODE_EPP
305 - IEEE1284_MODE_ECP
306 """
307 ret = struct.pack('i', 0)
308 ret = fcntl.ioctl(self._fd, PPGETMODE, ret)
309 return struct.unpack('i', ret)[0]
310
311 def PPGETTIME(self):
312 """
313 Retrieves the time-out value. The read and write calls will
314 time out if the peripheral doesn't respond quickly enough. The
315 PPGETTIME ioctl retrieves the length of time that the
316 peripheral is allowed to have before giving up.
317
318 Returns the timeout value in seconds as a floating-point value.
319 """
320 ret = struct.pack('ll', 0, 0)
321 ret = fcntl.ioctl(self._fd, PPGETTIME, ret)
322 return timevalToFloat(ret)
323
324 def PPSETTIME(self, time):
325 """
326 Sets the time-out (see PPGETTIME for more information).
327 'time' is the new time-out in seconds; floating-point values
328 are acceptable.
329 """
330 fcntl.ioctl(self._fd, PPSETTIME, floatToTimeval(time))
331
332 def PPGETMODES(self):
333 """
334 Retrieves the capabilities of the hardware (i.e. the modes
335 field of the parport structure).
336 """
337 raise NotImplementedError
338
339 def PPSETFLAGS(self):
340 """
341 Sets flags on the ppdev device which can affect future I/O
342 operations. Available flags are:
343
344 - PP_FASTWRITE
345 - PP_FASTREAD
346 - PP_W91284PIC
347 """
348 raise NotImplementedError
349
350 def PPWCONTROL(self, lines):
351 """
352 Sets the control lines. The 'lines' parameter is a bitwise OR
353 of the following constants from PPDEV:
354
355 - PARPORT_CONTROL_STROBE
356 - PARPORT_CONTROL_AUTOFD
357 - PARPORT_CONTROL_INIT
358 - PARPORT_CONTROL_SELECT
359 """
360 fcntl.ioctl(self._fd, PPWCONTROL, struct.pack('B', lines))
361
362 def PPRCONTROL(self):
363 """
364 Returns the last value written to the control register, in the
365 form of an integer, for which each bit corresponds to a control
366 line (although some are unused).
367
368 This doesn't actually touch the hardware; the last value
369 written is remembered in software. This is because some
370 parallel port hardware does not offer read access to the
371 control register.
372
373 The control lines bits are defined by the following constants
374 from PPDEV:
375
376 - PARPORT_CONTROL_STROBE
377 - PARPORT_CONTROL_AUTOFD
378 - PARPORT_CONTROL_SELECT
379 - PARPORT_CONTROL_INIT
380 """
381 ret = struct.pack('B',0)
382 ret = fcntl.ioctl(self._fd, PPRCONTROL, ret)
383 return struct.unpack('B', ret)[0]
384
385 def PPFCONTROL(self, mask, val):
386 """
387 Frobs the control lines. Since a common operation is to change
388 one of the control signals while leaving the others alone, it
389 would be quite inefficient for the user-land driver to have to
390 use PPRCONTROL, make the change, and then use PPWCONTROL. Of
391 course, each driver could remember what state the control
392 lines are supposed to be in (they are never changed by
393 anything else), but in order to provide PPRCONTROL, ppdev must
394 remember the state of the control lines anyway.
395
396 The PPFCONTROL ioctl is for "frobbing" control lines, and is
397 like PPWCONTROL but acts on a restricted set of control
398 lines. The ioctl parameter is a pointer to a struct
399 ppdev_frob_struct:
400
401 struct ppdev_frob_struct {
402 unsigned char mask;
403 unsigned char val;
404 };
405
406 The mask and val fields are bitwise ORs of control line names
407 (such as in PPWCONTROL). The operation performed by PPFCONTROL
408 is:
409
410 new_ctr = (old_ctr & ~mask) | val
411
412 In other words, the signals named in mask are set to the
413 values in val.
414 """
415 fcntl.ioctl(self._fd, PPFCONTROL, struct.pack('BB', mask, val))
416
417 def PPRSTATUS(self):
418 """
419 Returns an unsigned char containing bits set for each status
420 line that is set (for instance, PARPORT_STATUS_BUSY). The
421 ioctl parameter should be a pointer to an unsigned char.
422 """
423 ret = struct.pack('B',0)
424 ret = fcntl.ioctl(self._fd, PPRSTATUS, ret)
425 return struct.unpack('B', ret)[0]
426
427 def PPDATADIR(self, out):
428 """
429 Controls the data line drivers. Normally the computer's
430 parallel port will drive the data lines, but for byte-wide
431 transfers from the peripheral to the host it is useful to turn
432 off those drivers and let the peripheral drive the
433 signals. (If the drivers on the computer's parallel port are
434 left on when this happens, the port might be damaged.)
435 This is only needed in conjunction with PPWDATA or PPRDATA.
436
437 The 'out' parameter indicates the desired port direction. If
438 'out' is true or non-zero, the drivers are turned on (forward
439 direction); otherwise, the drivers are turned off (reverse
440 direction).
441 """
442 if out:
443 msg=struct.pack('i',0)
444 else:
445 msg=struct.pack('i',1)
446 fcntl.ioctl(self._fd, PPDATADIR, msg)
447
448 def PPWDATA(self, byte):
449 """
450 Sets the data lines (if in forward mode). The ioctl parameter
451 is a pointer to an unsigned char.
452 """
453 fcntl.ioctl(self._fd, PPWDATA,struct.pack('B',byte))
454
455 def PPRDATA(self):
456 """
457 Reads the data lines (if in reverse mode). The ioctl parameter
458 is a pointer to an unsigned char.
459 """
460 ret=struct.pack('B',0)
461 ret=fcntl.ioctl(self._fd, PPRDATA,ret)
462 return struct.unpack('B',ret)[0]
463
464 def PPCLRIRQ(self):
465 """
466 Returns the current interrupt count, and clears it. The ppdev
467 driver keeps a count of interrupts as they are triggered.
468 """
469 ret=struct.pack('i',0)
470 ret=fcntl.ioctl(self._fd, PPCLRIRQ,ret)
471 return struct.unpack('i',ret)[0]
472
473 def PPWCTLONIRQ(self, lines):
474 """
475 Set a trigger response. Afterwards when an interrupt is
476 triggered, the interrupt handler will set the control lines as
477 requested. The ioctl parameter is a pointer to an unsigned
478 char, which is interpreted in the same way as for PPWCONTROL.
479
480 The reason for this ioctl is simply speed. Without this ioctl,
481 responding to an interrupt would start in the interrupt
482 handler, switch context to the user-land driver via poll or
483 select, and then switch context back to the kernel in order to
484 handle PPWCONTROL. Doing the whole lot in the interrupt
485 handler is a lot faster.
486 """
487 fcntl.ioctl(self._fd, PPWCTLONIRQ,struct.pack('B',lines))
488
489 #data lines
490## def data(self):
491## """Returns the states of the data bus line drivers (pins 2-9)"""
492## return self._data
493
494 def setDataDir(self,out):
495 """Activates or deactivates the data bus line drivers (pins 2-9)"""
496 self._dataDir = out
497 self.PPDATADIR(out)
498
499 def dataDir(self):
500 """Returns true if the data bus line drivers are on (pins 2-9)"""
501 return self._dataDir
502
503 #control lines
504## def strobe(self):
505## """Returns the state of the nStrobe output (pin 1)"""
506## return (self.PPRCONTROL()&PARPORT_CONTROL_STROBE)==0
507
508 def setDataStrobe(self, level):
509 """Sets the state of the nStrobe output (pin 1)"""
510 if level:
511 self.PPFCONTROL(PARPORT_CONTROL_STROBE, 0)
512 else:
513 self.PPFCONTROL(PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE)
514
515## def autoFd(self):
516## """Returns the state of the nAutoFd output (pin 14)"""
517## return (self.PPRCONTROL()&PARPORT_CONTROL_AUTOFD)==0
518
519 def setAutoFeed(self, level):
520 """Sets the state of the nAutoFd output (pin 14)"""
521 if level:
522 self.PPFCONTROL(PARPORT_CONTROL_AUTOFD, 0)
523 else:
524 self.PPFCONTROL(PARPORT_CONTROL_AUTOFD, PARPORT_CONTROL_AUTOFD)
525
526## def init(self):
527## """Returns the state of the nInit output (pin 16)"""
528## return (self.PPRCONTROL()&PARPORT_CONTROL_INIT)!=0
529
530 def setInitOut(self, level):
531 """Sets the state of the nInit output (pin 16)"""
532 if level:
533 self.PPFCONTROL(PARPORT_CONTROL_INIT, PARPORT_CONTROL_INIT)
534 else:
535 self.PPFCONTROL(PARPORT_CONTROL_INIT, 0)
536
537## def selectIn(self):
538## """Returns the state of the nSelectIn output (pin 17)"""
539## return (self.PPRCONTROL()&PARPORT_CONTROL_SELECT)==0
540
541 def setSelect(self,level):
542 """Sets the state of the nSelectIn output (pin 17)"""
543 if level:
544 self.PPFCONTROL(PARPORT_CONTROL_SELECT, 0)
545 else:
546 self.PPFCONTROL(PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT)
547
548 def setData(self,d):
549 """Sets the states of the data bus line drivers (pins 2-9)"""
550 self._data=d
551 return self.PPWDATA(d)
552
553 #status lines
554 def getInError(self):
555 """Returns the level on the nFault pin (15)"""
556 return (self.PPRSTATUS() & PARPORT_STATUS_ERROR) != 0
557
cliechtie7d23fe2003-05-26 19:42:23 +0000558 def getInSelected(self):
cliechti619e4562002-07-31 00:53:06 +0000559 """Returns the level on the Select pin (13)"""
560 return (self.PPRSTATUS() & PARPORT_STATUS_SELECT) != 0
561
562 def getInPaperOut(self):
563 """Returns the level on the paperOut pin (12)"""
564 return (self.PPRSTATUS() & PARPORT_STATUS_PAPEROUT) != 0
565
566 def getInAcknowledge(self):
567 """Returns the level on the nAck pin (10)"""
568 return (self.PPRSTATUS() & PARPORT_STATUS_ACK) != 0
569
570 def getInBusy(self):
571 """Returns the level on the Busy pin (11)"""
572 return (self.PPRSTATUS() & PARPORT_STATUS_BUSY) == 0
573