==-SERIAL KILLER-(revisited)============================================ Often times, COM3 and COM4 will not open, and you will get a Device Unnavail- able error, even if you have a serial port at the address! This is not PowerBASIC's fault, however. PowerBASIC looks at the "BIOS Data Area" for the actual addresses of the ports. These addresses are 4 consecutive 2-byte integers beginning at segment &H40, offset 0 (absolute address &H400). Because the BIOS is responsible for putting these addresses here, and often times COM3 and COM4, the last two integers, are left at 0, PowerBASIC becomes under the impression that these ports do not exist. You simply need to Poke them into being: DEF SEG = &H40 : POKE$ 4, CHR$(&HE8, &H03, &HE8, &H02) These are the "standard" addresses for COM3 and COM4. Of course, you may stuff any address you like. If you read bytes 4 and 5, and stick them into the offsets 0 and 1, then suddenly COM3 becomes COM1 (This won't work with QB, since QB's port addresses seem to be hard coded). Typically, COM3 and COM4 use the same IRQ's as COM1 and COM2, that is IRQ 4 and IRQ 3 respectively, but most modems these days, like the little $50 internal 2400 from Boca Research, can be configured to use IRQ 2,3,4,5 or 7. Since PowerBASIC allows you to _select_ the IRQ in the OPEN COM statement (like no other language), and since PowerBASIC does not limit you to just one com port open at a time, you can easily use all four serial ports simultaneously, or, like me, have a PowerBASIC BBS running on COM3 and COM4, a mouse on COM1, and Little Big Lan running on COM2. Cool. Incidentally, here is a terrific little modem terminal routine: ' normal COM2 at 2400 baud OPEN "COM2:2400,N,8,1,RS,CS,CD,DS,ME,FE" FOR RANDOM AS #1 ' alternate COM4 on IRQ 5 at high speed 'OPEN "COM4:38400,N,8,1,ME,FE,IR5" FOR RANDOM AS #1 OPEN "CONS:" FOR OUTPUT AS #2 DO A$=INKEY$ IF A$=CHR$(27) THEN EXIT LOOP ' abort program on escape IF LEN(A$) THEN PRINT #1,A$; ' send keystroke to modem ELSE IF NOT EOF(1) THEN IF LOC(1) THEN A$=INPUT$(1,#1) IF A$=CHR$(10) THEN A$="" ' filter linefeeds IF A$=CHR$(13) THEN A$=CHR$(13)+CHR$(10) IF A$=CHR$(8) THEN A$=CHR$(8)+" "+CHR$(8) ' process backspace PRINT #2, A$; ' output to ANSI driver END IF LOOP CLOSE I have noticed that adding the "RS,CS,CD,DS" helps to avoid timeout problems with some serial ports in direct-connect situations, or with some older external modems, but it appears to prevent high-speed error-correcting modems from working. Any commercial package should have both OPEN COM formats available as options. RS and CS without arguments (disable RTS/CTS) affects modems which perform buffering, as in the case of modems which adjust to the caller's baud rate but maintain a fixed baud rate connection to the PC. ME (thank you Bob!) masks out framing and overrun errors, a very common occurance especially where modems are involved. These errors usually occur at the worst possible time and tend to blow apart even the most logically designed program. ME causes PowerBASIC to simply ignore these nit-picky little UART snits. FE is an option which flushes the byte currently in the UART holding register when an error occurs (ever see û û suddenly appear when line #2 rings, when a jet flies overhead, or when the A/C cuts on? FE fixes that!). Do not confuse framing and overrun errors with error 69, "buffer overflow". ME and FE deal with problems caused by a single byte entering the UART chip. Error 69 deals with where the data goes from there. Since your program cannot always be monitoring the com port and reading in characters as fast as they arrive, PowerBASIC buffers incoming characters up to 32K, so you can go off and do something, then come back and read in the data which arrived while your program was busy with other chores. When this 32K buffer is exceeded, there is nothing you can do to avoid getting this error. You must drain the buffer immediately by reading it (or closing and opening the port) and even in the split second it takes your program to do this, many characters will be lost, like people trying to pile into overfilled lifeboats on the titanic. Even though PowerBASIC supports multiple port I/O and baud rates up to 115200, there may be hardware limitations to your equipment that will prevent serial communications from operating properly. The early IBM PC, XT and probably most of the XT clones produced throughout the 80's used 8250 UART chips for their serial ports. I believe that this chip is also widely used in extremely cheap internal modems. According to the specs on this chip, it cannot run any faster than 57,600 baud, half of PowerBASIC's maximum speed. PowerBASIC will not give you any sort of error message (as far as I know) if you attempt to open an 8250 serial port at 115,200 baud. This type of port in a fast computer can also cause problems, as it would be possible to write to it's control registers faster than the chip itself can handle the instructions, which would seem likely to blow it apart (figuratively). Also, even with an advanced UART, PC and XT machines may run too slowly to process high baud rates in some cases, and characters may be lost. Later computers, modems and serial boards also use a sixteen bit version of what is essentially the same as the 8250 and 8250A, called the 16450. The maximum baud rate for this kind of serial port is also 57,600 and attempting to use it at 115,200 will likely cause serious errors as well. Most serial ports designed today use the 16550, but be careful. You should actually have a 16550A, AF or AFN. The regular 16550 was actually recalled by National Semiconductor. The 16550 series was designed to support some extended features, including a built in 16-byte buffer as well as a maximum baud rate of 256 kilobaud! The original 16550 (the one that was recalled) is said to work well as long as the 16 byte buffering is not invoked. Most current PC software does not support this extension, and the current version of PowerBASIC does not either, however PowerBASIC most definately will in the future, and many popular communications add-ons sport this feature. I have read that although the maximum baud rate for the 16550x is specified at 256kb, the maximum baud rate is fixed to 115kb in PC machines because of the hardware design, and higher speeds are not physically selectable. I have entreated Lloyd to attempt to rig a set of 256 kilobaud serial ports with a magnifying glass and a soldering iron, and perhaps we'll get some literature from him on that (pro or con). It is also said that 16550s manufactured by Western Digital do not operate correctly at or below 2400 baud. I have not been able to discover any other reference as to the nature of this malfuction. PowerBASIC will open up to four serial ports at a time. If all of the ports occupy the same IRQ, they must be on the same physical board (except on a PS/2). Interrupt configurable modems and serial cards can usually be found, and are generally less expensive than a single 8-port board. Multitasking environments like Desqview or PC-MIX (available on our BBS) will allow you to open as many ports as you can install with PowerBASIC, provided you understand a few minor limitations. Although PowerBASIC can interact with up to four ports on the same IRQ, you may not open two ports on the same IRQ inside different windows (or tasks). If many ports occupy the same IRQ, they can only be utilized by a single program running alone or in a Desqview window (I sure wish someone had told me that years ago!). In order to use many ports on the same IRQ, you must use a "Fossil Driver". Such an animal exists on our BBS as X00124.ZIP, and a discussion of it is better left out of this text or we'll never get to the end. An alternative to normal serial ports is "intelligent coprocessing", which is simpler than it sounds. An intelligent coprocessing serial board is one which contains its own memory and CPU. The 80186 seems to have found a home here. To interact with this board, you need no communications software, no interrupt handler, and IRQs don't even enter into it. All you have to do is (via CALL INTERRUPT or with INP and OUT) ask the card "Is there any data on channel 1?". If the card says "yes", then you say "Give it to me", otherwise, you go on to channel 2, then 3, and keep going like that. Parts of Cakes. For serial co-processing, an 8-channel intelligent serial board is available from GTEK, inc in Bay St. Louis, MS (601-467-8048). A complete set of PowerBASIC drivers (written by Yours Truly) is available from GTEK or from the PowerBASIC tech support BBS. Boca Research, in Boca Raton, FL, offers an 8 port 16550 board for around $129. I have not been able to verify this. Decision Computer of Taipei, (011 886 2 766-5753 voice, or 011 886 2 766-5702 fax) as a 4 port board for (reportedly) around $36 and an 8 port board for roughly $100. At the time of this writing I am awaiting further information from this company. Although there are a great many other similar products out there, there is one that stands out from all the rest: Galacticomm. The standard Galacticomm 8-port 16550 UART, interrupt and address configurable board is functionally identical to all other non-coprocessing boards and like the others, works pretty well with PowerBASIC on all 8 ports, up to 4 open at a time in a single program (or all 8 running under something like desqview with a fossil driver) but what makes the Galacticomm board unique is the company's incredible marketing abilities which allow them to get away with selling the board for around $750 (it probably costs about $15 to make) and absolutely refusing any sort of tech support unless you buy their own overrated BBS software. After much prodding, I finally got them to fax me a bunch of pages which they tore out of a National Semiconductor spec book, and since I was new to working so closely with serial ports back then, it took me a little while to realize that there was nothing special (or even very useful) about this incredibly expensive common serial port circuit board, except that it cost me the equivalent of a whole 'nother PC. I ended up trading it to Lloyd Smith's son Michael for a Joe Weider weight machine. Michael sold it to a friend up North who actually had some Galacticomm software. For PowerBASIC examples of serial communications, particularly modem based, see James Davis' DWDOORxx series of door libraries, Dave Navarro's soon-to-be-released PC-Board toolkit (PB-KIT?), the files MODEM.BAS (author unknown, looks Navarro-esque), TERMINAL.BAS and XMODEM.BAS on our BBS demonstrate various ways of writing terminals and file transfer protocols, and HBASIC.ZIP is a dBASE compatible BBS program with source code, all of which can be found on our BBS, and other BBS's which support PowerBASIC. Erik Olson 6/11/93 (Jurassic Park opens TODAY!!!)