Can I Use LPT Ports as I/O with a Program or C++ Directory?

  • Thread starter Thread starter TuviaDaCat
  • Start date Start date
  • Tags Tags
    Controller
Click For Summary

Discussion Overview

The discussion revolves around the use of LPT (parallel) ports for input/output operations in programming, specifically in the context of controlling devices like relays and reading external signals. Participants explore potential software solutions and programming approaches for both Linux and Windows environments.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant seeks a program or C++ library to interface with LPT ports for controlling relays and reading input states.
  • Another participant mentions developing an interface called Linux Parallel Port+, which currently has limited functionality but aims to support individual pin control and PWM in future versions.
  • A participant expresses concern about compatibility, noting they are using Windows 64-bit and the proposed solution is for Linux.
  • Suggestions are made for porting the Linux solution to Windows or learning the Windows API for direct port programming.
  • References are provided to books and resources that may assist in learning about port programming, including Parallel Port Complete and a book by Katupitiya and Bentley.
  • A participant warns that direct access to ports is restricted in Windows versions newer than Windows 95, suggesting the use of kernel mode device drivers or existing libraries like Inpout32.

Areas of Agreement / Disagreement

Participants express differing views on the feasibility of using LPT ports in Windows environments, with some suggesting workarounds while others highlight limitations imposed by the operating system. No consensus is reached on a single solution.

Contextual Notes

Limitations include the dependency on operating system capabilities, the need for kernel mode access in newer Windows versions, and the varying levels of support for LPT port programming across different platforms.

TuviaDaCat
Messages
85
Reaction score
1
i want to use my lpt ports as I/O. for example to run a relay, or react to an outside contact.
i need a program which can check the state of ports, or output to ports, and make conditions according to the inputs...

is there some kind of program for this? or maybe a c++ directory?

thanks
 
Engineering news on Phys.org
I am currently working on such an interface. Its called Linux Parallel Port+.
https://sourceforge.net/projects/linuxparaport/

The current version is very limited and can currently output a byte of data and read form the port. Over the weekend I will upload a new version. This version will give the ability to have control of individual output pins and read the status of the input pins individually (hopefully I'll have PWM working).

You can read CVS for the most current version of the source code and the documents (there's probably typos, grammar, and a few technical mistakes). The documents have some help on the port architecture and how one should control relays and so on. It isn't that detailed; I will try my best to change that soon.

There are still other goodies that I'm working on such as PWM and networking for remote monitoring.
BTW, its written in C. The code is written for Linux and certain version of UNIX.
 
thanks, but I am using windows, and more worrying, I am using windows 64 bit...
 
Well if you're programming skills are good, you could port it to windows. It should be easier to port now considering that the network functions are not implemented.

Alternatively, you can learn the windows API for this and code on your own:
http://www.epanorama.net/circuits/parallel_output.html
Parallel Port Complete by Jan Axelson is a very good port. I highly recommend this book if you're getting started with port programming (they have source code for windows).

Also Katupitiya and Bentley (2006) is a very good book focusing on using C++ for port programming while making good use of the OOP nature of C++. There are many practical circuits in the book with fairly good explanations. The good thing is that the book comes with a circuit board so you can build all the circuits in the book. Both linux and windows source codes are available.
 
Under anything newer than win95 you can't talk to the port directly yourself. Only kernel mode device drivers are allowed to break your system!
There are a couple of direct to parrallel drivers around, see:
http://www.codeproject.com/useritems/Inpout32_read.asp

You can also write your own with the device driver devkit, it includes an exammple miniport driver ( or at least it did under NT4 last time I did it.)
 
Last edited by a moderator:

Similar threads

Replies
17
Views
3K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 5 ·
Replies
5
Views
967
  • · Replies 12 ·
Replies
12
Views
2K
Replies
3
Views
2K
Replies
14
Views
5K
  • · Replies 31 ·
2
Replies
31
Views
5K
  • · Replies 14 ·
Replies
14
Views
3K
Replies
37
Views
7K
  • · Replies 12 ·
Replies
12
Views
4K