Author Topic: Parallel Port in "kamikaze" mode : another problem  (Read 3792 times)

alberich

  • Member
  • ***
  • Posts: 16
Parallel Port in "kamikaze" mode : another problem
« on: November 06, 2013, 02:39:04 pm »
Hello everybody (again)

As I wrote in a former topic, I access the parallel port (only in output mode) via the Win API using Delphi 6, i.e. via CreateFile, WriteFile and CloseHandle. I made the connections described by "John Sawyer" directly on the DB25 male connector in order to simulate the handshaking of a printer, it works fine under W2K and XP.

Now I want to detect if the device is plugged in, otherwise there is a popup after about 1mn 45s, indicating a Write Error to the printer (which does not exist really, even if the device is plugged in). Testing the handle's value does not give the expected result ; GetLastError and IOResult after a Write operation seem to crash (freeze) the program if the device is not plugged in.

I believe that there is an API call to test if the printer is busy, not selected or out of paper (the corresponding pins are tied to GND via the connector), without reading the registers (that operation should need a driver like InpOut32.dll) , just after the CreateFile, so I could close the handle without any write operation , beep and quit the application. Does anyone have an idea ?

Thanks for any information
« Last Edit: November 06, 2013, 02:48:29 pm by alberich »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2597
    • Lakeview Research
Re: Parallel Port in "kamikaze" mode : another problem
« Reply #1 on: November 06, 2013, 05:49:07 pm »
If the operating system doesn't identify the attached device as a printer, I don't think a function that returns printer status will work.

alberich

  • Member
  • ***
  • Posts: 16
Re: Parallel Port in "kamikaze" mode : another problem
« Reply #2 on: November 06, 2013, 11:03:05 pm »
Thank You for the answer ... I think I will do like most people, i.e. build a new interface with a USB to parallel adaptor ... I used an "IOWarrior" with another interface and it worked fine.
Alberich

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2597
    • Lakeview Research
Re: Parallel Port in "kamikaze" mode : another problem
« Reply #3 on: November 06, 2013, 11:19:58 pm »
That would be my suggestion.