Announcement

Collapse
No announcement yet.

Writing to Parallel Printer Port with PB/DLL V6.0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Writing to Parallel Printer Port with PB/DLL V6.0

    Hi,
    I Have PB/DLL Version 6.0.
    It seems that INP and OUT instructions have been removed from this
    version.
    In commonly asked questions (I have looked) there is a workaround
    I do not know how to implement this.
    Does any one have a fully working example of say writing to address
    &H378 (Usually LPT1).
    Thanks.



    ------------------

  • #2
    Phil,

    The problem is that the access is not properly legal under win 32. Win95
    would allow the DOS interrupts for printer access but NT and win2k will not.

    If its not a time critical port application, you can open LPT1 as a file
    and write to it that way but it is not a high precision way to do it.

    [email protected]

    ------------------
    hutch at movsd dot com
    The MASM Forum

    www.masm32.com

    Comment


    • #3
      Mr W...

      1. Your question of how to perform port reading/writing is answered in the FAQ forum, however, for more specific information on programming the parallel port, you may wish to visit www.lvr.com

      2. The rules of this BBS require that you use a real name (first AND especially your last name) - handles and alias's are not permitted. Please reregister correctly before posting any further messages.

      Thank you!




      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Below code are work in Win95 98, not for Win 2000 and NT, may work in ME,
        but not try.


        Code:
        #COMPILE EXE
        #INCLUDE "Win32Api.Inc"
        
        %IDsend         = 1
        %IDExit         = 2
        %IDreceive      = 3
        
        %BS_DEFAULT     = 1      'Set the button appearance
        
        '------------------------------------------------------------------------------
        ' Global variable to recieve the user input and variable
        
        OPTION EXPLICIT
        GLOBAL Value AS INTEGER
        GLOBAL PortAddress AS INTEGER
        GLOBAL F AS INTEGER
        
        '------------------------------------------------------------------------
        
        SUB pbOut(BYVAL oport AS INTEGER, BYVAL value AS INTEGER)
        
          ! mov DX, oport
          ! mov AL, value
          ! out DX, AL
        
        END SUB
        
        
        '------------------------------------------------------------------------
        
        FUNCTION pbInp(BYVAL iport AS INTEGER) AS INTEGER
          ! mov DX, iport
          ! in  AL, DX
          ! mov FUNCTION[0], AL
        END FUNCTION
        
        '-----------------------------------------------------------------------
        
        CALLBACK FUNCTION sendport()
        
        IF CBMSG = %WM_COMMAND AND CBCTLMSG = %BN_CLICKED THEN
        
          pbOut PortAddress,Value     'Write to a port.
          F = pbInp(PortAddress)      'Read back and display the result.
          Value = Value + 1
          IF Value = 255 THEN Value = 0
          CONTROL SET TEXT CBHNDL,%IDreceive, STR$(F%)' Put the Loop Back
                                                      ' value at text box
        ELSE
             DIALOG END CBHNDL, 0
        
        END IF
        
        END FUNCTION
        '--------------------------------------------------------
        
        CALLBACK FUNCTION Exit_prog()
        
          DIALOG END CBHNDL, 0
        
        END FUNCTION
        
        '------------------------------------------------------------------------------
        
        FUNCTION PBMAIN () AS LONG
        
          $REGISTER NONE
        
          LOCAL hDlg   AS LONG
        
             PortAddress = &h378
             Value = 0
            'Change PortAddress to match the port address to write to:
            '(Usual parallel-port addresses are &h378, &h278, &h3BC)
        
        ' ** Create a new dialog template
          DIALOG NEW 0, "Port IO Test ", ,, 200, 130, 0, 0 TO hDlg
        
        ' ** Add controls to it
        '--------------------------------------------------------------------------
        CONTROL ADD LABEL, hDlg,-1,"Loop Back Value ",40,25,70,8,
        
        '--------------------------------------------------------------------------
        
        CONTROL ADD TEXTBOX,hDlg,%IDreceive, "",100,25,50,12,
        
        '--------------------------------------------------------------------------
        
        CONTROL ADD BUTTON, hDlg, %IDsend, "outport",_
        50, 75, 40, 30, %BS_DEFAULT CALL sendport
        
        CONTROL ADD BUTTON, hDlg, %IDEXIT, "Exit", _
        110, 75, 40, 30, 0 CALL exit_prog
        
        '--------------------------------------------------------------------------
        
        ' ** Display the dialog
          DIALOG SHOW MODAL hDlg
        
        END FUNCTION

        ------------------

        Comment


        • #5
          Thanks to everybody who replied, and thanks to Aisin Geuru Suen Yue.

          Yes the software does work in ME.

          I had earlier on today worked out how to do it for myself.
          (Not as explicit as Aisins version though, just needed some starter points.)
          Firstly without passing parameters.
          Then working out how to pass variables from one Sub to another.
          It was this that i was having difficulty with.
          I was not interested in the software working for NT - only W95 etc.

          Thanks again - Phil.




          ------------------

          Comment

          Working...
          X