Announcement

Collapse
No announcement yet.

How to read status of LPT-Device?

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

  • How to read status of LPT-Device?

    How to recognize - is the device really connected or not?

    I know the solution,
    OK -> bit7 = 1, bit5 = 0
    NOK -> bit7 = 0, bit5 = 1

    but how to read a bit7 and bit5 from status register (output from LPT1 adress 378 or LPT2 ...)?

    Thanks
    Last edited by Alexander Holzer; 13 Mar 2008, 05:13 PM.
    Yours sincerely

  • #2
    If using a standart port the LPRINT ATTACH may be the answer
    From the pbwin 8.04 help
    Code:
    ERRCLEAR
    LPRINT ATTACH "LPT3"
    IF ERR OR LPRINT$ = "" THEN PRINT "Connection failed"
    of course you could substitute MSGBOX for print to get the error message
    in pbwin
    Client Writeup for the CPA

    buffs.proboards2.com

    Links Page

    Comment


    • #3
      Originally posted by Fred Buffington View Post
      If using a standart port the LPRINT ATTACH may be the answer
      From the pbwin 8.04 help
      Code:
      ERRCLEAR
      LPRINT ATTACH "LPT3"
      IF ERR OR LPRINT$ = "" THEN PRINT "Connection failed"
      of course you could substitute MSGBOX for print to get the error message
      in pbwin
      No, it does not go :nono:
      if LPT3 available - no error comes! although is device to LPT3 not attached!
      You can try it..
      Yours sincerely

      Comment


      • #4
        here is code for test...

        Code:
        #COMPILE EXE
        #INCLUDE "WIN32API.INC"
        
        
        FUNCTION PBMAIN () AS LONG
        
        LOCAL sLptName  AS STRING
        
        sLptName = "LPT1"
        
        ERRCLEAR
        
        LPRINT ATTACH sLptName
        IF ISFALSE ERR AND ISTRUE LEN(LPRINT$) THEN
          LPRINT CHR$(16);       ' this is not printer
        '  LPRINT FORMFEED      ' does not use, because it is not printer!
        '  LPRINT FLUSH         ' does not use, because it is not printer!
          LPRINT CLOSE          ' detach the device
        ELSE
          MSGBOX sLptName + " - connection failed"
        END IF
        
        END FUNCTION
        Yours sincerely

        Comment


        • #5
          STATUS REGISTER:

          Bit 5 This bit represents the current state of the printer paper
          end signal (PE pin 12). The printer sets this bit Hi when it
          detects the end of paper. This bit follows the state of the
          PE pin.

          Bit 7 This bit represents the current state of the printer busy signal
          (/BUSY pin 11). The printer sets this bit Lo when it is busy and
          cannot accept another character. This bit is the inverse of of the
          BUSY pin.
          Thanks John Hutchins:
          http://www.powerbasic.com/support/pb...ght=LPT+status

          Unfortunately this code doesn't run with WinXP, program falls/crashes.

          Has anybody others ideas? :shhh:

          Thanks
          Yours sincerely

          Comment


          • #6
            MeThinks its all a part of the OS based on the 95 branch of the tree, or the NT branch of the tree.

            Although I think M$ got their concepts bass-Ackwards, the 95 Branch allowed for direct access to the device, but the NT branch you have to user Kernel mode drivers to be able to access
            (Why would a "Hobbyist" be allowed to mess the system up? And a "Programmer" be denied this access?)

            Unless you are already using something to get around that, then most likely that is your problem.
            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment


            • #7
              I wish to know, whether it is possible to realize now it in PBWin? (status register of LPT-port read)
              Last edited by Alexander Holzer; 14 Mar 2008, 08:51 AM.
              Yours sincerely

              Comment


              • #8
                Alexander,
                have a look here:
                http://www.powerbasic.com/support/pb...ighlight=winio

                It shows one way to get access to I/O ports on a WinXP computer.

                Paul.

                Comment


                • #9
                  Originally posted by Paul Dixon View Post
                  Alexander,
                  have a look here:
                  http://www.powerbasic.com/support/pb...ighlight=winio

                  It shows one way to get access to I/O ports on a WinXP computer.

                  Paul.
                  Thanks Paul,
                  it is clear, but I want this make only with PBWin.
                  Last edited by Alexander Holzer; 14 Mar 2008, 08:52 AM.
                  Yours sincerely

                  Comment

                  Working...
                  X