Announcement

Collapse
No announcement yet.

Why is OPEN "COM1.." not working as it did with QBasic?

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

  • Why is OPEN "COM1.." not working as it did with QBasic?

    Hi. I have written a QBasic program which captures the input of my
    touch screen through COM1 and it works well. The touch screen driver
    is loaded prior to starting QBasic and then running the basic program.
    The data INPUTS through COM1 gives me the relative location of where I
    touched the screen.

    When I run the basic program with PowerBASIC the data INPUT$ through
    COM1 is no longer represented of where I touch the screen.

    Here is what the code looks like for QBasic, and the data from this
    corresponds to where I touched the screen.

    COM(1) ON
    ON COM(1) GOSUB ReadCom
    OPEN "COM1:9600,N,8,1,CS0,DS0,CD0,OP0,RS,RB4" FOR INPUT AS #1


    Here is what the code looks like for PowerBASIC.
    $COM 4
    ON COM(1) GOSUB ReadCom
    COM(1) ON
    OPEN "COM1:9600,N,8,1,CS0,DS0,CD0,RS" AS #1


    I have tried using the SHELL feature to load the touch screen
    driver while in the PowerBASIC program, which it does successfully, but
    still the results are not there. If I load the driver after
    executing OPEN "COM1..." then there is no recognized input on
    COM1. If I load it before OPEN "COM1..." I get the same response
    as though I loaded the driver before starting PowerBASIC.

    What do I need to consider under PowerBASIC that is different
    QBasic? No errors are detected.

    Thank you,
    Gary

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

  • #2
    Try opening the comm port before the ON COM... statement(s)

    Oops! Looks like you already tried that. Sorry.


    Try changing:
    OPEN "COM1:9600,N,8,1,CS0,DS0,CD0,RS" AS #1
    to
    Open "com1:9600,n,8,1,rs,cs,ds,cd" as #1

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


    [This message has been edited by Mel Bishop (edited December 01, 2004).]
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      Mel, I tried your suggestion and it did not work. I also did futher
      testing and found out the following:
      1. Shelling to a drawing program prior to the OPEN COM1 command worked fine.
      2. Shelling to the same program after the OPEN COM1 command did not show
      any input from the touch screen.
      3. A shell to the drawing program would continue to work when I reran the
      program (F9) as long as I did not encounter the OPEN COM1 in the program.
      4. Once I encountered the OPEN COM1, rerunning (F9) the program prevented
      the drawing program from seeing any input from COM1. A computer reboot
      was necessary.
      5. I shelled to install the touch screen driver after OPEN COM1. The drawing
      program still would not see any input.

      Questions:
      1. Why would the OPEN COM1 in PowerBASIC have this affect when QBasic did not?

      2. Why doesn't pressing F9 to rerun the program remove what ever affect the
      OPEN COM1 had?



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

      Comment


      • #4
        Gary,
        <<$COM 4>>

        That sets the buffer size to 4 bytes, which is on the small side. Are you sure you want to do that?
        The $COM size parameter must be multiples of 16 anyway, you're probably allocating a zero byte buffer size!

        Paul.

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

        Comment


        • #5
          Load the driver before starting the program instead of trying to load it from within the program?

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

          Comment


          • #6
            Guys,

            I appreciate your help. Your input has been very helpful,
            and the problem is now solved.

            Thank you very much.

            Gary

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

            Comment


            • #7
              Gary, I'm glad the problem was solved but what did you do to
              solve it? Your solution may be useful to others who have similar
              problem(s).


              ------------------
              There are no atheists in a fox hole or the morning of a math test.
              If my flag offends you, I'll help you pack.

              Comment


              • #8
                Loading the driver outside or inside the program works both ways.
                They key factor I was in the OPEN statement. The comment about
                $COM rounding the bytes to groups of 16 was a key factor. In QBasic,
                the receive buffer length was defined with the "COM..." section. What
                I learned was that the $COM itself would not limit the value to four
                bytes as I desired, but by placing LEN=4 at the end of the OPEN COM
                command did limit the number of bytes.

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

                Comment


                • #9
                  Limiting the amount of data recieved is necessary sometimes because
                  some devices send a fixed amount of data and that's it. Other
                  devices use RTS (Ready To Send) to mark when there is data ready,
                  and when that signal goes away, the input is through. A part of
                  the OPEN dialog defines which signals to monitor and which to
                  ignore, and the LEN = appendage takes the concept a bit further.

                  Sometimes posting code alone does not help, because it shows us
                  what you did or tried to do, and does not answer the question of
                  what you intended to do.



                  ------------------
                  Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                  Comment

                  Working...
                  X