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?
LPT Communication
BlitzPlus Forums/BlitzPlus Programming/LPT Communication Search PortIO DLL. Allows you to toggle pins via byte and so forth.
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.
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.
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.
Scratch that. It writes to the printer buffer, which made the printer freak. Back to square 1.
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.
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)
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)
Option Explicit
Private Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
ByVal pDefault As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _
"StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
pDocInfo As DOCINFO) As Long
Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _
pcWritten As Long) As Long
Private Sub Command1_Click()
Dim lhPrinter As Long
Dim lReturn As Long
Dim lpcWritten As Long
Dim lDoc As Long
Dim sWrittenData As String
Dim MyDocInfo As DOCINFO
lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
If lReturn = 0 Then
MsgBox "The Printer Name you typed wasn't recognized."
Exit Sub
End If
MyDocInfo.pDocName = "AAAAAA"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)
sWrittenData = "How's that for Magic !!!!" & vbFormFeed
lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
End Sub