LPT Communication

BlitzPlus Forums/BlitzPlus Programming/LPT Communication

Arem(Posted 2005) [#1]
Is it possible to communicate with the LPT port via the stream=openstream("LPT1") method? If so, what would the default baud rate be, and how can it be changed. Also, should I create a byte that determines whether each pin is on or off?


Yeshu777(Posted 2005) [#2]
Search PortIO DLL. Allows you to toggle pins via byte and so forth.


Beaker(Posted 2005) [#3]
deja vu:
http://blitzbasic.com/Community/posts.php?topic=46477


Arem(Posted 2005) [#4]
Unfortunately, this requires other software to be installed and running previously. I am a stickler for having nothing running in the background on my pc, so if there is any other way, it would be wonderful.

I have read that it is possible to open up communication with the serial port via file=openfile("COM1") but I was wondering if the same method works with LPT.


Arem(Posted 2005) [#5]
Well, I finally decided to go ahead and try writing data to LPT. I wrote a few random bytes (while forgetting to unplug the printer) and it freaked. But it works! If there are ways to set the baud rate etc. that would be great. Otherwise, I'm done.


Arem(Posted 2005) [#6]
Scratch that. It writes to the printer buffer, which made the printer freak. Back to square 1.


Seldon(Posted 2005) [#7]
You can access LPT or COM ports with Win32 API. You need some userlibs definitions for Blitz. Look for samples on this forum and on MSDN.


Wayne(Posted 2005) [#8]
Sorry this is for B3d, but it may be of help.

I posted some parallel port I/O stuff in the user libs. It's low level and should allow you to read and write status, control and data bit/bytes. I used it to control the position of Radio Control servos.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1487


It's been awhile since I've done low level output to printer, and it varies with hardware. In general write data, send strobe, watch status for ack, send next character. Also keep in mind printers have commands ie HPGL.

If it's application printing your looking for I think Kanati had a blitz3d printing dll, there maybe others out there.

Summary, Most OS's will require you use a DLL to allow access to hardware ports ( thats the law ). There is a winapi for printing as well, here is some vb6 code as example. Also don't use the word baud with parallel communications because there is no UART with parallel printing and thus no control register to set a rate.
8)