home *** CD-ROM | disk | FTP | other *** search
- *.............................................................................
- * Program Name: CFDPC11.PRG Copyright: Magna Carta Software, Inc. 1992.
- * Date Created: 05-18-92 Language: FoxPro v2.0x
- *.............................................................................
- * Description: Example of DigiBoard PC/X (PC/4 or PC/8) usage with CommTools
- * Based on FOXCOM11.
- * Usage Notes:
- * 1) Install the DigiBoard PC/X in the PC. You may choose any desired I/O
- * address for the ports, and the "status register" supported by the DigiBoard.
- * You may also choose any IRQ line supported by the card.
- *
- * 2) If you plan to use only ONE port on the DigiBoard, you can use any of the
- * FOXCOMxx examples. You do not need the routines contained herein;
- *
- * 3) If you plan to use the DigiBoard in "polled mode" (i.e., you do not
- * intend to use interrupts) you can use any of the FOXCOMxx examples. For each
- * port that you intend to use, call u8250_init() with the correct I/O address
- * for the port that you wish to use on the board.
- *
- * 4) If the above cases do not apply, you plan to use the DigiBoard in
- * interrupt-driven mode, using more than one port. The following applies to
- * your situation.
- * a) Think of the DigiBoard PC/X as an array of 4 (PC/4) or 8 (PC/8) standard
- * 8250 ports. We call u8250_init() once for each port that we plan to use;
- * b) Install the IPRs that you wish to use on each port. For example, if you
- * are using 4 ports, and you wish to use receive interrupts on each, call
- * install_ipr() 4 times (once to each port);
- * c) Since we need to install a special ISR that supports the DigiBoard, do
- * NOT call install_isr(). Instead, call DIGIPC_INSTALL_ISR() as shown below.
- * We call this only once, since one ISR handles all of the ports on the board.
- * The prototype for DIGIPC_INSTALL_ISR() is:
- *
- * DIGIPC_INSTALL_ISR(expN portid, expN irq, expN status_addr)
- * Arguments:
- * _parni(1) -- CommTools port ID;
- * _parni(2) -- interrupt request line (IRQ) to use;
- * _parni(3) -- Address of DigiPC/X status port;
- * Return value:
- * 0 -- Success;
- * -2 -- No IPRs installed;
- * PARMERROR -- Incorrect number or type of parameters;
- *
- * Note: The parameter 'portid' may be any one of the port IDs used to
- * reference a port on the DigiBoard. For example, if you are using all 8 ports
- * of a PC/8, and assign CommTools port IDs 5-12 to the DigiBoard ports, you
- * could specify any number from 5 to 12 as the parameter 'portid' in
- * DIGIPC_INSTALL_ISR().
- *
- * From this point on in the program, all of the CommTools device-independent
- * calls that work with a standard serial port, work with the DigiBoard.
- *
- * Note: The UARTs on these boards are socketed and may be replaced with
- * NS16550A UARTs for better performance. See the CommTools "Communications
- * Reference" for a description of the NS16550, and the CommTools "Technical
- * Reference" under "set_16550_threshold()" for the method used to set the FIFO
- * buffers.
- *.............................................................................
-
- CLEAR ALL
- SET TALK OFF
- SET ESCAPE OFF
-
- * Load the right library
- foxid = VERS()
- IF "2.0" $ foxid
- SET LIBR TO ctf && Identified FoxPro 2.0
- ELSE
- IF "2.5" $ VERS()
- IF "Windows" $ foxid && Identified FoxPro 2.5 for Windows
- CANCEL
- ELSE
- SET LIBR TO ctf25 && Identified FoxPro 2.5 for DOS
- ENDIF
- ENDIF
- ENDIF
-
- SET COLOR OF SCHEME 17 TO SCHEME 1 && save default color scheme
- SET COLOR OF SCHEME 18 TO SCHEME 2
-
- DO ctfhdr
- DO ctfutil
- SET PROCEDURE TO CTFUTIL
- version = 11
- portid = 0
-
- ACTIVATE WINDOW w_status
- ACTIVATE WINDOW w_term
-
- activeport = 0 && use port ID 0 for demo purposes
-
-
- * Initialize 4 ports on the PC/X. Assume the I/O addresses are set to 108h,
- * 110h, 120h, 130h. Note: This illustrates that the port I/O addresses
- * do not have to be evenly spaced on the PC/X.
- =u8250_init(0, x2d("108"), 19200, 8, PARITY_NONE, 1)
- =u8250_init(1, x2d("110"), 19200, 8, PARITY_NONE, 1)
- =u8250_init(2, x2d("120"), 19200, 8, PARITY_NONE, 1)
- =u8250_init(3, x2d("130"), 19200, 8, PARITY_NONE, 1)
-
- * Now install a receive IPR on EACH of the ports initialized above.
- * Just for grins, we will make the interrupt buffer sizes different.
- =install_ipr(0, RECEIVE, NULL, 1024) && initialize receive IPR
- =install_ipr(1, RECEIVE, NULL, 1536) && initialize receive IPR
- =install_ipr(2, RECEIVE, NULL, 2048) && initialize receive IPR
- =install_ipr(3, RECEIVE, NULL, 2560) && initialize receive IPR
-
- * Here's the only DigiBoard PC/X-specific call we use. Install the ISR
- * (we will assume we configured the board IRQ selection jumpers to IRQ 2).
- * We further assume that the status register is at 141h;
- =digipc_install_isr(0, 2, x2d("141"))
-
- * From here on out it's business as usual. All we do is use "activeport" to
- * provide a dumb terminal.
-
- @ 00,00 SAY "CommTools DigiBoard PC/X Terminal Version " +;
- ALLTRIM(STR(version)) + ": Press CTRL-A to return to menu"
-
- DEFINE PAD p_ct_emul OF main_menu PROMPT "\<Emulation" AT 00, 37
- ON SELECTION PAD p_ct_emul OF main_menu =do_term_emul(portid, 37)
-
- ACTIVATE MENU main_menu
-
-
-
- *
- * DO_TERM_EMUL(expN portid)
- * Show a menu that allows the user to select a terminal to emulate.
- * Called from mainmenu()
- *
- FUNCTION do_term_emul
- PARAMETERS portid, col
- PRIVATE nChoice, termtype
-
- termtype = get_terminal(col)
- IF termtype != CT_EOF
- * USE XONXOFF FLOW CONTROL (THIS LETS US BUFFER RECEIVED DATA) *
- =set_tx_xlat(portid, FLOWCTL, XONXOFF) && better accept flow control if > 2400 bps
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && echo RX data to screen
- =set_tx_xlat(portid, LOCAL_ECHO, FALSE) && (optionally) don't echo TX data
- ret = term_init(portid, termtype)
- =term_set(portid, TERM_ROWS, 45)
- =term_set(portid, TERM_COLS, 78)
- * =term_set(portid, TERM_KEYCLICK, 0) && "Click, click..."
- IF ret < 0
- =status_msg(0, "Insufficient memory for terminal emulation")
- ENDIF
- ENDIF
- RETURN (ret)
-
-
-
- *
- * GET_TERMINAL(expN tr, expN lc)
- * Show a menu that allows the user to select a terminal to emulate.
- * Called from do_terminal_menu()
- *
- FUNCTION get_terminal
- PARAMETER col
- PRIVATE termtype
-
- termtype = 0
- DEFINE POPUP pop_terminal FROM 01, col;
- IN SCREEN;
- SHADOW
- DEFINE BAR 1 OF pop_terminal PROMPT " \<TTY "
- DEFINE BAR 2 OF pop_terminal PROMPT " \<ANSI.SYS "
- DEFINE BAR 3 OF pop_terminal PROMPT " ANSI \<X3.64 "
- DEFINE BAR 4 OF pop_terminal PROMPT " VT\<52 "
- DEFINE BAR 5 OF pop_terminal PROMPT " VT\<100 "
- DEFINE BAR 6 OF pop_terminal PROMPT " VT\<220 "
-
- ON SELECTION POPUP pop_terminal termtype=_terminal_menu(BAR())
- ACTIVATE POPUP pop_terminal
- DEACTIVATE POPUP pop_terminal
- RELEASE POPUPS pop_terminal
- RETURN (termtype)
-
-
- FUNCTION _terminal_menu
- PARAMETERS nChoice
- PRIVATE termtype
-
- DO CASE
- CASE nChoice = 1
- termtype = TTY
- CASE nChoice = 2
- termtype = ANSI_SYS
- CASE nChoice = 3
- termtype = ANSI_X364
- CASE nChoice = 4
- termtype = DEC_VT52
- CASE nChoice = 5
- termtype = DEC_VT100
- CASE nChoice = 6
- termtype = DEC_VT220
- OTHERWISE
- termtype = CT_EOF
- ENDCASE
- =status_msg(0, "Terminal: " + ALLTRIM(PROMPT()))
- RETURN (termtype)
-
-
-
- FUNCTION ct_online
- PARAMETERS portid
-
- ACTIVATE WINDOW w_term
- * =CT_SET_WIN(portid)
- =c_term(portid) && switch to dumb terminal mode
- RETURN (0)
-
-
-
- *
- * C_TERM -- This is a dumb terminal loop in FoxPro.
- * Alternately poll the serial input buffer and the keyboard for data.
- *
- FUNCTION c_term
- PARAMETERS portid
- PRIVATE c
-
- ?
- DO WHILE .T.
- * CHECK SERIAL PORT FOR BYTE *
- c = c_getc(portid) && check the serial port for a byte
- * CHECK KEYBOARD FOR A KEY PRESS *
- c = INKEY() && check keyboard for a key
- DO CASE && evaluate the received key
- CASE c == 1 && CTRL-A was pressed
- RETURN (0)
- CASE c <> 0
- =c_putc(portid, c)
- ENDCASE
- ENDDO && do while .t.
- RETURN (0)
-