Page 1 of 1

Write to the parallelport control register

Posted: Mon Jan 10, 2005 10:10 am
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

Posted: Mon Jan 10, 2005 12:49 pm
by PolyVector
maybe the calling convention is cdecl?... you could try CallCFunction()...
just throwing out ideas :)