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.

https://github.com/yan9a/cecpp/tree/master/parallelport


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;
  p.WrD(1,3);
  unsigned char r=p.RdS(7);


References

[Lin15a] LinuxGeek. Parallel port control in Linux. 2015.
url: https://www.htlinux.com/parallel_port_control_in_linux.

[Coo08a] Cool Emerald. Parallel Port as IO. 2008.
url: http://cool-emerald.blogspot.com/2008/03/parallel-port-as-io.html.

No comments:

Post a Comment

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