Announcement

Collapse
No announcement yet.

PB for DOS - using IOCTL to access Porttalk

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

  • PB for DOS - using IOCTL to access Porttalk

    I'm running PowerBasic for DOS on a Windows XP computer. I'd like to control the parallel port directly. I have already installed the Porttalk driver, but need to start each of my programs by using the allowio.exe file so that my program will use the Porttalk driver.

    I would like to use IOCTL in my program to access the Porttalk driver directly, but don't know how to set this up in PowerBasic. From everything I've read on the web, I understand that I need to use the Open command to define the driver, then use IOCTL to send the parameters to it.

    What is the syntax for this?

  • #2
    Klaus,
    I'd like to control the parallel port directly
    Try WinIO, it allows direct access to hardware ports under WinXP.
    See here for details:
    http://www.powerbasic.com/support/pb...ad.php?t=11194

    Paul.

    Comment


    • #3
      Thank you for the reply. However, WinIO appears to be for 32 bit Windows applications as defined in their introduction. I am running a DOS version of PowerBasic.

      None of their examples show how to access their drivers in a DOS-based BASIC program.

      Am I missing something?

      Comment


      • #4
        http://www.beyondlogic.org/porttalk/porttalk.htm

        Contains instructions for running allowio and a program.

        Your PB/DOS help file shows how to use OPEN to open a device, and the help for IOCTRL syntax is there, too.

        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Klaus,
          I posted before I thought. The method is for Windows applications.

          Paul.

          Comment


          • #6
            Michael

            Thank you for your response. I've read that article, but I would like to bypass using allowio, if at all possible, and acess the PortTalk driver directly from within my BASIC program using the IOCTL command.

            Is that even possible?

            Comment


            • #7
              but I would like to bypass using allowio, if at all possible, and acess the PortTalk driver directly from within my BASIC program using the IOCTL command.
              I don't do hacks.

              I only know how to RTFM.

              Besides, are you sure that driver even accepts string commands? When I did RTFM it sure looked like all that driver did was make it possible for you to access ports directly. (PB/DOS: INP and OUT)
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                I can't say I really know how that driver is supposed to work. I was looking for a way to play around with it to find out more.

                What does RTFM stand for?

                Comment


                • #9
                  >I can't say I really know how that driver is supposed to work

                  Then how can you know you want to use the IOCTL function?

                  RTFM stands for "Read the Friendly Manual" and acronymically accurate variations thereon.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    From MS docs for GW-Basic:

                    IOCTL Statement

                    Purpose:
                    To allow GW-BASIC to send a "control data" string to a character device driver anytime after the driver has been opened.
                    Syntax:
                    IOCTL[#]file number,string
                    Comments:
                    file number is the file number open to the device driver.

                    string is a valid string expression containing characters that control the device.

                    IOCTL commands are generally 2 to 3 characters followed by an optional alphanumeric argument. An IOCTL string may be up to 255 bytes long, with commands within the string separated by semicolons.
                    Examples:

                    If a user had installed a driver to replace lpt1, and that driver was able to set page length (the number of lines to print on a page before issuing a form feed), then the following lines would open the new lpt1 driver and set the page length to 66 lines:
                    Code:
                    10 OPEN "LPT1:" FOR OUTPUT AS #1
                    20 IOCTL #1, "PL66"
                    The following statements open lpt1 with an initial page length of 56 lines:
                    Code:
                    10 OPEN "\DEV\LPT1" FOR OUTPUT AS #1
                    20 IOCTL #1, "PL56"

                    IOCTL$ Function

                    Purpose:
                    To allow GW-BASIC to read a "control data" string from an open character device driver.
                    Syntax:
                    IOCTL$([#]file number)
                    Comments:
                    file number is the file number open to the device.

                    The IOCTL$ function is generally used to get acknowledgement that an IOCTL statement succeeded or failed. It is also used to get device information, such as device width after an IOCTL statement requests it.
                    Examples:
                    Code:
                    10 'GW is a possible command
                    20 'for get device width
                    30 OPEN "\DEV\MYLPT" AS #1
                    40 IOCTL #1, "GW"
                    50 'Save it in WID
                    60 WID=VAL(IOCTL$(#1))
                    "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

                    Comment


                    • #11
                      An alternative to IOCTL

                      I use Allowio.exe for a legacy DOS application where I need I/O port access in Windows XP.
                      I install PortTalk and place a batch file in the Startup folder,

                      "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\GoUnited.bat"

                      This batch file enables the port addresses noted in the environment variable 'IOPorts'

                      Code:
                      @echo off
                      
                      Set IODir=%Programfiles%
                      Set IOPorts=0x100 0x108 0x110 0x118 0x120 0x128 0x130 0x138 0x180 0x188 0x190 0x198 0x1A0 0x1A8 0x1B0 0x1B8
                      
                      Echo Username:%UserName%                  > "%IODir%\PortTalk\allowio.log"
                      
                      "%IODir%\PortTalk\allowio.exe" %IOPorts% >> "%IODir%\PortTalk\allowio.log"
                      
                      Copy "%IODir%\PortTalk\allowio.log" con

                      The batch file runs just once for each login session. That's all I have to do.
                      Allowio.exe magically enables any and all I/O port addresses I've included. Then INP and OUT to your port addresses.

                      There is one caveat: You must run your DOS application in FULL SCREEN MODE, like SCREEN 8 and SCREEN 12.

                      You are welcome to try the setup file I've created: http://www.tensiletest.com/info_down...ds/ptsetup.exe

                      Be sure to edit the IOPorts environment variable with your own address range after installation:

                      Code:
                      Set IOPorts=0x278 0x378

                      Comment


                      • #12
                        Thanks to all who helped I now have a solution. Case Closed.

                        Klaus

                        Comment

                        Working...
                        X