KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q37306: "Device I/O Error" If Keyboard Buffer Filled During "COM1"

Article: Q37306
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | B_BasicCom buglist4.00 buglist4.00b buglist4.50 | mspl13_basic
Last Modified: 20-SEP-1990

When the keyboard buffer becomes full while serial communications are
executing, a "Device I/O error" (error 57) may occur.

Microsoft has confirmed this to be a problem in QuickBASIC versions
4.00, 4.00b, and 4.50, in Microsoft BASIC Compiler versions 6.00 and
6.00b for MS-DOS and MS OS/2 (buglist6.00, buglist6.00b), and in
Microsoft BASIC Professional Development System (PDS) version 7.00 for
MS-DOS and MS OS/2 (buglist7.00). This problem was corrected in BASIC
PDS version 7.10 (fixlist7.10).

To work around this problem, use the INKEY$ function to poll the
keyboard so that any keyboard input will be flushed. This process is
shown below.

When the program code example below is run without any keyboard
interference, the program runs to completion. However, if you type
enough to fill the keyboard buffer, a "Device I/O error" occurs.

The following is a code example:

   DEFINT A-Z
   OPEN "COM1:1200,n,8,1,cs0,ds0" FOR RANDOM AS #1
   ON COM(1) GOSUB emptycom
   COM(1) ON
   FOR i = 1 TO 10000
     '  WHILE INKEY$<>"": WEND   ' Used to Empty the Keyboard buffer
     PRINT #1, "a"
   NEXT i
   CLOSE
   END

   emptycom:
     '  WHILE INKEY$<>"": WEND  '  Used to Empty the Keyboard buffer
     INPUT #1, s$
     PRINT s$,
     RETURN

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.