• 0

[C++] Parallel I/O


Question

Hi, I have been searching for a good tutorial on how to perform I/O to the Parallel Port (LPT1), but had no luck :(, can any one recomend one?

Thanks in Advance :D

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

What OS? If you use windows, you should be able to use CreateFile and specify file = "LPT1". From MSDN:

hCom = CreateFile("LPT1",

GENERIC_READ | GENERIC_WRITE,

0, // must be opened with exclusive-access

NULL, // no security attributes

OPEN_EXISTING, // must use OPEN_EXISTING

0, // not overlapped I/O

NULL // hTemplate must be NULL for comm devices

);

You can then use ReadFile and WriteFile and treat LPT1 just like a file.

Link to comment
Share on other sites

  • 0

Thanks I am using Windows, basically I want to send a high bit to certain pins, this is for a hardware thing, and I wan't to simulate a button press on the Board, via the LPT1 device.

Thanks :cool:

Link to comment
Share on other sites

  • 0

Shouldn't ReadFile/WriteFile work? Those IOCTL's seem only relavent when dealing with ecp or epp mode. In any case, you'll need to use DeviceIoControl with the IOCTL's mentioned by weenur.

Link to comment
Share on other sites

  • 0

No idea either ;) Parport.sys source (or something useful) might be included in some windows ddk though. You could check this for a definative answer.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.