reading/writing to the parallel printer port

For issues with communication ports, protocols, etc.
keven
Posts: 3
Joined: Jul 20, 2021 11:47

reading/writing to the parallel printer port

Postby keven » Jul 20, 2021 13:14

Hi...
I'm new here but I'm old Qbasic hacker...
I have written a program in Qbasic that reads and writes data to LPT1:

'Identify the LPT1 Address
DEF SEG = 0
pdata% = PEEK(&H408) + PEEK(&H409) * 256
IF pdata% = 0 THEN
PRINT " LPT1 not found"
SHELL "pause"
END
ELSE
PRINT " LPT1 found at &H"; HEX$(pdata%)
pstatus% = pdata% + 1
END IF
that worked with a line printer cable connected to a PC with a printer port running in a DOS environment.

Now I have a "newer" PC and a USB cable which has a parallel printer connector to an old dot matrix printer.
prints great with this Freebasic Code:

' Send some text to the Windows printer on LPT1:, using driver text imaging.
Open Lpt "LPT1:EMU=TTY" For Output As #1
Print #1, "Testing!"
Close

if freebasic can send data to LPT1(via the printer driver), is it also possible to send/read data from LPT1 at the connector pin level?

like this in Qbasic?:
' write a hex F8 to output port 378 to set pins 5,6,7 & 8 &(9)to hi
OUT pdata%, &HF8
MrSwiss
Posts: 3842
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: reading/writing to the parallel printer port

Postby MrSwiss » Jul 20, 2021 14:53

Simply put: only DOS allowes "direct HW (hardware) access".

All the other more modern OS's (operating systems) don't do that, in fact they "protect against direct HW access".
You'll have to use something like: in "Try to use inpout32.dll" thread to achieve that (on windows).
Read from there to the current tread-end (it's otherwise far too long ...).
keven
Posts: 3
Joined: Jul 20, 2021 11:47

Re: reading/writing to the parallel printer port

Postby keven » Jul 23, 2021 15:21

keven wrote:
like this in FreeBasic?:

Dim pdata as integer
Lib inpout32.dll
pdata=888 ‘hex 378
‘ write a hex F8 to output port 378 to set pins 5,6,7 & 8 to hi
OUT pdata, &HF8
MrSwiss
Posts: 3842
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: reading/writing to the parallel printer port

Postby MrSwiss » Jul 23, 2021 16:56

You'll need both, the driver and the .dll ...
the .dll alone is not changing anything (it comunicates with the driver).

Q: How to use it? A: Read the documentation driver/.dll ...
keven
Posts: 3
Joined: Jul 20, 2021 11:47

Re: reading/writing to the parallel printer port

Postby keven » Jul 23, 2021 20:25

Henrik Haftmann has written a version of inpout32.dll that can be used to replace the existing windows version. The interface to the parallel port is seamless as a driver is included in the dll. I guess I wouldn’t need to reference the dll, just execute the inp and out commands to parallel port address (defaulted to hex 378).
I be trying it out tomorrow... mite have to use the 64 bit version.

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 2 guests