Write to the parallelport control register

Share your advanced PureBasic knowledge/code with the community.
martin66119
User
User
Posts: 46
Joined: Sat Jan 08, 2005 7:46 pm

Write to the parallelport control register

Post by martin66119 »

Code updated For 5.20+

I try to write to the parallelport controlregister. I use the following code.

Code: Select all

;---------------Deklaration der Variabeln ---------------------------------------

 PortNumD.l = $378                ; PortNummer des Datenregisters (LPT1)
 PortNumS.l = $379                ; PortNummer des Statusregisters (LPT1)
 PortNumC.l = $37A                ; PortNummer des Controlregisters (LPT1)
 Samples = 0                       
                           
 j = 1
;----------------------------------check library file open)----------------------
 LibOpen.l = OpenLibrary(1,"io.dll")
 If LibOpen = 0
      End
 EndIf
 ;---------------------------------open function io.dll--------------------------
 CallFunction(1,"PortOut", PortNumC,%0000)   ; write to port 37ah
 
 Text$ = InputRequester("Number of samples!", "Integerzahl", "")    
 Samples =Val(Text$)
 
 Repeat
   CallFunction(1,"PortOut", PortNumC,%0000)   ; write 0 to 37ah "Strobe" 
   Ergebnis.b= CallFunction(1,"PortIn", PortNumC)  
   INC j
 Until j >= Samples 

 Zahl$ = StrF(Ergebnis.b) 
 Ergebnis.b = MessageRequester("Info", Zahl$, 0)

If I write %0001 to the controregister the result is 3. If I write %0000 to the controregister the result is 0. When I write %0011 to the register the result is 3. I do not understand the reason. What is my mistake?

You can find the io.dll here: http://www.geekhideout.com/iodll.shtml
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

maybe the calling convention is cdecl?... you could try CallCFunction()...
just throwing out ideas :)
Post Reply