Announcement

Collapse
No announcement yet.

Help Testing LPT Port

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

    Help Testing LPT Port

    I am writing a program that uses a Cash Drawer attached to an LPT port
    and am wondering is there any way to test the LPT port to see if it
    is ready before writing to it. I am opening the port with the OPEN
    statement as follows;

    Code:
    Open "LPT1:" For Output As 1
    Print# 1, "Hello"
    Close 1
    In the above code if the device on LPT1 were not turned on, the program
    hangs on the PRINT# 1, "Hello" line forever. Does anyone know how to
    check the status before sending to the Port? Thanks in advance!


    Scott Slater


    ------------------
    Scott Slater
    Summit Computer Networks, Inc.
    www.summitcn.com

    #2
    Scott,

    I know Lance would know more about this then I would. But using
    the open "LPT1:" etc is not a reliable method. I would recommend
    getting a driver to communicate to the LPT port directly. I
    don't know of a website off the top of my head but maybe someone
    else has a website? Lance?

    Hope that helps.

    ------------------
    -Greg
    -Greg
    [email protected]
    MCP,MCSA,MCSE,MCSD

    Comment


      #3
      http://www.lvr.com/

      ------------------
      Peter.
      mailto[email protected][email protected]</A>
      Regards,
      Peter

      "Simplicity is a prerequisite for reliability"

      Comment


        #4
        Yep that's the site

        ------------------
        -Greg
        -Greg
        [email protected]
        MCP,MCSA,MCSE,MCSD

        Comment


          #5
          I was looking for maybe a small ASM routine or a Windows API Call
          that would show me the status of a port. I only need to send 3
          characters to the port so I didn't want to use a driver. I tried
          going through the "Generic / Text Only" Printer Driver, but it filters
          out escape sequenses...


          Scott

          ------------------
          Scott Slater
          Summit Computer Networks, Inc.
          www.summitcn.com

          Comment


            #6
            Ring3 applications can't access ports directly with in NT. You
            will need a driver for this. You can output directory with
            ports in the Win9x kernal. With OUT and IN asm opcodes.

            Here is something that will work for direct access to ports:

            Code:
            SUB pbOut(BYVAL iPORT AS INTEGER, BYVAL value AS INTEGER)
                #REGISTER NONE
                ! mov AX, value
                ! mov DX, iport
                ! out DX, AL
            END SUB
            
            FUNCTION pbInp(BYVAL iPORT AS INTEGER) AS INTEGER
                #REGISTER NONE
                ! mov DX, iport
                ! in AL, DX
                ! mov FUNCTION[0], AL
            END FUNCTION
            ------------------
            -Greg
            -Greg
            [email protected]
            MCP,MCSA,MCSE,MCSD

            Comment


              #7
              I just tried PBINP and it works great! Thanks. I just checked to
              see if it was running under NT or not before making the call. Under
              NT the OS will spool the job in a print queue if the device is not
              online. So it works on both platforms. Thanks again...


              Scott


              ------------------
              Scott Slater
              Summit Computer Networks, Inc.
              www.summitcn.com

              Comment


                #8
                The details of using !IN and !OUT along with the link to the LVR site are in the FAQ forum.

                However, as you found, you can open the port directly with OPEN "LPT1" FOR OUTPUT AS #1 - the key here is to *omit* the colon from "LPT1:". However, since windows does not signal an off-line state, the code that sends data will block until the port becomes "ready".

                Therefore, using an I/O driver is a more effective solution.

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

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎