Friday, November 23, 2018

Using Parallel Port on Linux with C++

Example programs for using parallel port on Linux [Lin15a,Coo08a], and a C++ class library can be found at the following link.

Figure 1. wxWidgets example using paraller port as digital output and input.

To use cePPort class, you need to include its header and declare namespace ce as follows.

#include "cePPort.h"
using namespace ce;

To write data register and control register, WrD and WrC methods can be used. To read status register, you can use RdS method. As an example, declaring an instance for cePPort, writing 1 at bit 3 of data register, reading bit 7 of status register (busy pin) is shown below.

  cePPort p;
  unsigned char r=p.RdS(7);


[Lin15a] LinuxGeek. Parallel port control in Linux. 2015.

[Coo08a] Cool Emerald. Parallel Port as IO. 2008.

No comments:

Post a Comment

Comments are moderated and don't be surprised if your comment does not appear promptly.