ParallelPort Class Reference

#include <port.h>

Inheritance diagram for ParallelPort:

Inheritance graph
[legend]
Collaboration diagram for ParallelPort:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Pin {
  PIN02 = 1 << 0, PIN03 = 1 << 1, PIN04 = 1 << 2, PIN05 = 1 << 3,
  PIN06 = 1 << 4, PIN07 = 1 << 5, PIN08 = 1 << 6, PIN09 = 1 << 7,
  DATA_PINS, PIN15 = 1 << 11, PIN13 = 1 << 12, PIN12 = 1 << 13,
  PIN10 = 1 << 14, PIN11 = 1 << 15, STATUS_PINS = PIN15 | PIN13 | PIN12 | PIN10 | PIN11, PIN01 = 1 << 16,
  PIN14 = 1 << 17, PIN16 = 1 << 18, PIN17 = 1 << 19, CONTROL_PINS = PIN01 | PIN14 | PIN16 | PIN17
}
enum  Register { Data = 0, Status = 1, Control = 2 }
enum  Direction { Input = 0, Output = 1 }

Public Member Functions

 ParallelPort ()
 ~ParallelPort ()
bool openPort (const QString &port)
void closePort ()
void setPinState (int pins, bool state)
int pinState (int pins)
void setDataState (uchar pins, bool state)
void setControlState (uchar pins, bool state)
uchar readFromRegister (Register reg)
void writeToData (uchar value)
void writeToControl (uchar value)
void setDataDirection (Direction dir)
void setControlDirection (int pins, Direction dir)

Static Public Member Functions

static ProbeResult probe (const QString &port)
static QStringList ports (unsigned probeResult)

Protected Member Functions

void writeToRegister (Register reg, uchar value)
void reset ()

Protected Attributes

uchar m_reg [3]
int m_inputPins
 Mask of the pins that are currently set as input.
int m_outputPins
 Mask of the pins that are currently set as output.
int m_file
 File descriptor for the port.

Detailed Description

Abstraction for a parallel port, allowing control over individual pins. Based loosely on code in the parapin project; see http://parapin.sf.net

Author:
David Saxton

Definition at line 104 of file port.h.


Member Enumeration Documentation

enum ParallelPort::Direction

For setting the direction of the Data register or the Control pins.

Definition at line 156 of file port.h.


Member Function Documentation

bool ParallelPort::openPort ( const QString &  port  ) 

Opens the given port.

Returns:
if the port could be opened.

Definition at line 473 of file port.cpp.

References m_file.

Referenced by ParallelPortComponent::initPort().

void ParallelPort::closePort (  ) 

Closes any currently open port.

Definition at line 501 of file port.cpp.

References m_file.

Referenced by ParallelPortComponent::initPort().

void ParallelPort::setPinState ( int  pins,
bool  state 
)

Parameters:
pins A list of ParallelPort::Pin OR'd together.

Definition at line 289 of file port.cpp.

References m_outputPins, setControlState(), and setDataState().

Referenced by setDataDirection().

int ParallelPort::pinState ( int  pins  ) 

Returns:
the pin states for the given list of pins.

Definition at line 302 of file port.cpp.

References m_inputPins, and readFromRegister().

void ParallelPort::setDataState ( uchar  pins,
bool  state 
)

Sets the given pins to the given state in the Data register.

Definition at line 322 of file port.cpp.

References readFromRegister(), and writeToData().

Referenced by setPinState().

void ParallelPort::setControlState ( uchar  pins,
bool  state 
)

Sets the given pins to the given state in the Control register.

Definition at line 335 of file port.cpp.

References readFromRegister(), and writeToControl().

Referenced by setControlDirection(), and setPinState().

uchar ParallelPort::readFromRegister ( Register  reg  ) 

Reads and stores the value in the given reigsters, and returns it.

Definition at line 351 of file port.cpp.

References m_file, and m_reg.

Referenced by pinState(), setControlState(), setDataState(), and ParallelPortComponent::stepNonLogic().

void ParallelPort::writeToData ( uchar  value  ) 

Write the given value to the Data register.

Definition at line 379 of file port.cpp.

References writeToRegister().

Referenced by ParallelPortComponent::dataCallback(), and setDataState().

void ParallelPort::writeToControl ( uchar  value  ) 

Write the given value to the Control register (any input pins will be set to one).

Definition at line 385 of file port.cpp.

References m_inputPins, and writeToRegister().

Referenced by ParallelPortComponent::controlCallback(), and setControlState().

void ParallelPort::setDataDirection ( Direction  dir  ) 

Sets the (input / ouput) direction of the data pins.

Definition at line 396 of file port.cpp.

References m_inputPins, m_outputPins, and setPinState().

void ParallelPort::setControlDirection ( int  pins,
Direction  dir 
)

Sets the given pins to the given direction.

Definition at line 413 of file port.cpp.

References m_inputPins, m_outputPins, and setControlState().

QStringList ParallelPort::ports ( unsigned  probeResult  )  [static]

See also:
Port::ports

Reimplemented from Port.

Definition at line 451 of file port.cpp.

References probe().

Referenced by ParallelPortComponent::ParallelPortComponent(), and Port::ports().

void ParallelPort::writeToRegister ( Register  reg,
uchar  value 
) [protected]

Writes the value to the given register.

Definition at line 366 of file port.cpp.

References m_file, and m_reg.

Referenced by writeToControl(), and writeToData().


The documentation for this class was generated from the following files:
Generated on Tue May 8 17:05:51 2007 for KTechLab by  doxygen 1.5.1