home *** CD-ROM | disk | FTP | other *** search
- *.............................................................................
- *
- * Program Name: CTFDCOM0 Copyright: Magna Carta Software, Inc.
- * Date Created: 04-21-92 Language: FoxPro v2.0+
- *.............................................................................
- * Description: Sample Terminal Program that illustrates the use of the
- * DigiBoard DigiCHANNEL COM/Xi intelligent serial board.
- * Note that we use board-specific calls to initialize the board, but
- * threrafter the CommTools calls are identical to those used to address a
- * standard serial port. This means run-time device independence.
- *.............................................................................
-
- CLEAR ALL
- CLEAR
- SET TALK OFF
- SET ESCAPE OFF
- @00, 00 SAY "DOS Memory before loading CommTools" + STR(memory())
- SET LIBRARY TO ctf
- 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 = 0
- def_colors = "W+/B, N/W, N/B,,N/W"
- portid = 0 && CommTools number to refer to port (0-31)
- channel = 0 && DigiBoard port number (e.g. P1 = 0)
-
- @ 01,00 SAY "CommTools DigiBoard DigiCHANNEL Com/Xi Terminal Version " + LTRIM(STR(version))
- @ 02,00 SAY "Press ESC to Exit"
-
- * Initialize the DigiBoard.
- * Parameters:
- * 1) The number by which we wish to reference the board (0-3).
- * Up to 4 boards (32-ports) may be installed in a single computer.
- * 2) I/O base address of the DigiBoard (we use hex '320');
- * 3) The memory base address of the DigiBoard (we use hex 'D800' to place
- * the board shared memory next to the EMS page frame);
- * See the DigiBoard installation manual for available choices;
-
- @03, 00 SAY "Initializing DigiBoard..."
- ret = comxi_init(0, x2d("320"), x2d("D800"), 1)
- @04, 00 SAY "Return code: " + LTRIM(STR(ret))
- IF ret < 0
- @05, 00 SAY "Unable to initialize board"
- @06, 00 SAY "Check memory and port address"
- RETURN
- ELSE
- @05, 00 SAY "Board successfully initialized"
- ENDIF
-
- * Initialize each port on the DigiBoard that you wish to use.
- * DigiBoard, Inc. refers to a port as a 'channel'.
- * Call this function once for each channel that you wish to use.
- * We are only using one channel, so we only call it once.
- * Parameters are:
- * 1) The port ID (0-31) that we wish to use for reference;
- * 2) The board ID (0-3) assigned above;
- * 3) Channel number on the board (0-7). DigiBoard numbers these 1-8;
- * 4) Speed (bps);
- * 5) Data bits (5-8);
- * 6) Parity (any supported by the standard serial port);
- * 7) Stop Bits (1, 1½, 2);
-
- @06, 00 SAY "Initializing channel " + LTRIM(STR(channel))
- ret = comxi_i_channel(portid, 0, channel, 9600, 8, PARITY_NONE, 1)
- @07, 00 SAY "Return code: " + LTRIM(STR(ret))
- IF ret < 0
- @08, 00 SAY "Unable to initialize port"
- @09, 00 SAY "Check parameters and configuration"
- RETURN
- ELSE
- @08, 00 SAY "Channel " + LTRIM(STR(channel)) + " successfully initialized"
- ENDIF
-
-
- * From this point on, it's business as usual. No special calls needed.
- * CommTools translates standard calls into DigiBoard calls.
- * The board is automatically deinitialized at the end of the program, but
- * you may call comxi_deinit() prior to that if you wish.
-
- =set_tx_xlat(portid, FLOWCTL, XONXOFF) && assert flow ctl.
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && turn on RX local echo
- =c_term(portid)
- @ 24,00 SAY "End of CommTools DigiBoard Example " + LTRIM(STR(version))
- RETURN && quit to FoxPro/DOS
-
-
-
- *
- * C_TERM(expN portid) -- This is the CLIPPER analog of term() in CCTxx.C.
- *
- PROCEDURE c_term
- PARAMETERS portid
- PRIVATE c
-
- ?
- DO WHILE .T.
- =c_getc(portid) && check the serial port for a byte
- c = INKEY() && check keyboard for a key
- DO CASE && evaluate the received key
- CASE c == ESC && ESCape was pressed
- RETURN
- CASE c <> 0
- =c_putc(portid, c)
- ENDCASE
- ENDDO && DO WHILE .T.
- RETURN
-