open lpt[x]

For issues with communication ports, protocols, etc.
squibit
Posts: 16
Joined: Jan 16, 2006 19:44

open lpt[x]

Postby squibit » Dec 20, 2016 16:39

trouble with open lpt1 but not with open lpt
Have dot matrix printer attached to lpt1

The following works: open lpt....as #2 : print #2 "whatever" :close #2

But open lpt1 etc. returns a value of 2
Does this mean ( ?? no Printer at port ??)

Apparently FreeBasic will only work with spooler.

OS Windows 10
Under Printer Properties direct print to printer was chosen
MrSwiss
Posts: 2020
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: open lpt[x]

Postby MrSwiss » Dec 20, 2016 17:46

squibit wrote:... works: open lpt....as #2 : print #2 "whatever" :close #2
You've got a working solution.
Read the FB-Manual ... for detailed information.
squibit
Posts: 16
Joined: Jan 16, 2006 19:44

Re: open lpt[x]

Postby squibit » Dec 20, 2016 18:42

MrSwiss wrote:
squibit wrote:... works: open lpt....as #2 : print #2 "whatever" :close #2
You've got a working solution.
Read the FB-Manual ... for detailed information.

Have read that page perhaps 20 times over the last year-the point is to get direct printing to the device on
lpt1 with the ultimate goal of using the port to control hardware- SO indeed there is no solution.
MrSwiss
Posts: 2020
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: open lpt[x]

Postby MrSwiss » Dec 20, 2016 19:39

You are "heavily switching targets" here:
from: printing (got a serial Printer) to: HW-Device Control, on Parallel-Port.

However, the opening of the port, remains the same.
Writing to the Port must be done without using "print"-statement.

See the related threads on Serial communication, for that (using put).

In this day and age: no more direct HW-Control any longer (OS handles that).
Even serial runs over OS provided Buffers (send/receive).
Dinosaur
Posts: 975
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Re: open lpt[x]

Postby Dinosaur » Dec 21, 2016 3:41

Hi All

In this day and age: no more direct HW-Control any longer (OS handles that).


Wel that depends a bit on the hardware.
If the LPT port is a genuine port on the hardware (as in Desktop Plugin LPt board, or on board LPT chip), then you can address it.
If the port is emulated on some obscure piece of hardware and needs a special driver to get to it, then you are out of luck.
I use a Library called WinIO, and after initialising it, just as an example.
Have used this in various Win version.

Code: Select all

InitializeWinIO
Motor.LptAddr = &H378
Motor.Fwd = 1
Az = Inp(Motor.LptAddr)
Bz = Az or Motor.Fwd
Out Motor.LptAddr, Bz


Regards
squibit
Posts: 16
Joined: Jan 16, 2006 19:44

Re: open lpt[x]

Postby squibit » Dec 23, 2016 23:59

"If the LPT port is a genuine port on the hardware"

Before attaching the printer I have been trying to get direct output using OUT32
Monitoring the strobe socket with an oscilloscope while in an unending loop
with( out32(&h37A,1) ........out32(&h37A,0)........) No luck.

Also tried writing 0 and 255 to &H378 with equal lack of success.

[1]Do you think WINIO will succeed where inpoutx64 failed?
[2]In case you suspect as I do, that the port is not genuine, can you name
a board that contains a genuine port.

Best regards , a Happy New Year, and if you are up to it , a Merry Christmas
Dinosaur
Posts: 975
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Re: open lpt[x]

Postby Dinosaur » Dec 24, 2016 14:53

Hi All

squibit, you will need the WinIO library.

http://www.internals.com/utilities/utilities.htm

In this zip there are 64 bit dll and.sys, and also help .chm
I have not used the Out32 in FB only the Out instruction.

But rest assured it worked for me and and at this very moment is controlling motors
in a production environment.

Regards

Edit:
Depending on what your hardware bus is, just search for Parallel Port Adapters.(I was still using Industrial ISA bus backplanes 2 years ago)
squibit
Posts: 16
Joined: Jan 16, 2006 19:44

Re: open lpt[x]

Postby squibit » Jan 01, 2017 1:59

Code: Select all

extern "Windows-MS" lib   "WinIo64"
declare function _
 InstallWinIoDriver  stdcall ( DriverPath as zstring ptr, _
     Loaded  as Boolean) as Boolean
end extern
 dim fl as zstring ptr
 fl=allocate(32)
'fl= "C:\FreeBASIC64\WinIo64.sys"
*fl= "C:\Windows\System32\WinIo64.sys"
'fl= "C:\ SysWOW64\WinIo64.sys"
 dim as Boolean ld,dl
 ld=false
  dl=InstallWinIoDriver(fl, ld)
 print dl,ld,*fl
 
 sleep



First, Dinosaur, a Happy New Year
Cannot get WinIo64.sys to install: have tried "C" instead of "Windows-MS" in the extern declaration
Also, have tried the three locations indicated(a copy of the driver is in each)

Am logged in in a Windows account for which I'm the administrator.
Also FBIDE is being run as administrator.
In addition the executable is being run as an administrator
The bcdedit /set TESTING ON has been run and the computer says it's running in test mode
Do you have any suggestions, including that I've made a stupid mistake
Dinosaur
Posts: 975
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Re: open lpt[x]

Postby Dinosaur » Jan 01, 2017 3:38

Hi All

Will fire up my XP laptop and visit the old project and note the sequence of events.

Regards
Dinosaur
Posts: 975
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Re: open lpt[x]

Postby Dinosaur » Jan 01, 2017 15:07

Hi All

squibit , below what makes the system work on Windows XPe.

Files in Folders:
WinIO.dll in my applications folder
WinIO.sys " "
WinIO.vxd " "
WinIO.dll in /Windows/system32
In your Fbc compile statement: -l winio
In your declare statements:

Code: Select all

'Lib WinIO
Declare Function InstallWinIoDriver Alias "InstallWinIoDriver"(Byval WinIoDriverPath As Zstring Ptr,Byval IsDemandLoaded As Integer ) As Integer
Declare Function RemoveWinIoDriver alias "RemoveWinIoDriver"() as integer
Declare Function InitializeWinIo Alias "InitializeWinIo"() As Integer
Declare Function ShutdownWinIo Alias "ShutdownWinIo"() As Integer


At beginning of your code:

Code: Select all

Print InitializeWinIO


In your code:

Code: Select all

Out &h378,1

At end of code:

Code: Select all

Print ShutDownWinIo


It is very reliable and in one application I control about 240 IO bits on addresses from &h140 to &h1b0.
In another I use the LPT port to communicate with a Stepper Motor controller by giving it direction and start signals.

If you have an XP system available, try it there if you can't get the 64 bit version to work.

Good Luck.

Regards
squibit
Posts: 16
Joined: Jan 16, 2006 19:44

Re: open lpt[x]

Postby squibit » Jan 20, 2017 18:53

If you have an XP system available, try it there if you can't get the 64 bit version to work.

Hi Dinosaur

Took a Toshiba Protege Tablet with Windows XP in which was a card bus parallel port had been
inserted Got it to work, first in PowerBasic35( old standby) and then in FreeBASIC 0.4.6 without
winio simply using out instruction.

Will be happy to send you details on the card bus if you're interested.

A query

Only winio files I could find for 32 bit XP are winio32.dll and winio32.sys (no .vxd file)
Should these work?


Best regards and Thanks for your advice
Squibit

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 1 guest