home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a081 / 2.ddi / CTFXX.EXE / CTFDXI00.PRG < prev    next >
Encoding:
Text File  |  1993-05-14  |  4.5 KB  |  126 lines

  1. *.............................................................................
  2. *
  3. *   Program Name: CTFDXI00         Copyright: Magna Carta Software, Inc.
  4. *   Date Created: 04-21-92         Language:  FoxPro v2.x
  5. *.............................................................................
  6. * Description: Sample Terminal Program that illustrates the use of the
  7. * DigiBoard DigiCHANNEL COM/Xi intelligent serial board.
  8. * Note that we use board-specific calls to initialize the board, but
  9. * threrafter the CommTools calls are identical to those used to address a
  10. * standard serial port. This means run-time device independence.
  11. *.............................................................................
  12.  
  13. CLEAR ALL
  14. CLEAR
  15. SET TALK OFF
  16. SET ESCAPE OFF
  17. @00, 00 SAY "DOS Memory before loading CommTools" + STR(memory())
  18.  
  19. * Load the right library
  20. foxid = VERS()
  21. IF "2.0" $ foxid
  22.     SET LIBR TO ctf                 && Identified FoxPro 2.0
  23. ELSE
  24.     IF "2.5" $ VERS()
  25.         IF "Windows" $ foxid        && Identified FoxPro 2.5 for Windows
  26.             SET LIBR TO ctfw
  27.         ELSE
  28.             SET LIBR TO ctf25       && Identified FoxPro 2.5 for DOS
  29.         ENDIF
  30.     ENDIF
  31. ENDIF
  32.  
  33. SET COLOR OF SCHEME 17 TO SCHEME 1  && save default color scheme
  34. SET COLOR OF SCHEME 18 TO SCHEME 2
  35.  
  36. DO ctfhdr
  37. DO ctfutil
  38. SET PROCEDURE TO CTFUTIL
  39.  
  40. version     = 0
  41. def_colors  = "W+/B, N/W, N/B,,N/W"
  42. portid      = 0             && CommTools number to refer to port (0-31)
  43. channel     = 0             && DigiBoard port number (e.g. P1 = 0)
  44.  
  45. @ 01,00 SAY "CommTools DigiBoard DigiCHANNEL Com/Xi Terminal Version " + LTRIM(STR(version))
  46. @ 02,00 SAY "Press ESC to Exit"
  47.  
  48. * Initialize the DigiBoard.
  49. * Parameters:
  50. * 1) The number by which we wish to reference the board (0-3).
  51. *    Up to 4 boards (32-ports) may be installed in a single computer.
  52. * 2) I/O base address of the DigiBoard (we use hex '320');
  53. * 3) The memory base address of the DigiBoard (we use hex 'D800' to place
  54. *    the board shared memory next to the EMS page frame);
  55. * 4) Size of uploaded program
  56. * See the DigiBoard installation manual for available choices;
  57.  
  58. @03, 00 SAY "Initializing DigiBoard..."
  59. ret = comxi_init(0, x2d("320"), x2d("D800"), 1)
  60. @04, 00 SAY "Return code: " + LTRIM(STR(ret))
  61. IF ret < 0
  62.     @05, 00 SAY "Unable to initialize board"
  63.     @06, 00 SAY "Check memory and port address"
  64.     RETURN
  65. ELSE
  66.     @05, 00 SAY "Board successfully initialized"
  67. ENDIF
  68.  
  69. * Initialize each port on the DigiBoard that you wish to use.
  70. * DigiBoard, Inc. refers to a port as a 'channel'.
  71. * Call this function once for each channel that you wish to use.
  72. * We are only using one channel, so we only call it once.
  73. * Parameters are:
  74. * 1) The port ID (0-31) that we wish to use for reference;
  75. * 2) The board ID (0-3) assigned above;
  76. * 3) Channel number on the board (0-7). DigiBoard numbers these 1-8;
  77. * 4) Speed (bps);
  78. * 5) Data bits (5-8);
  79. * 6) Parity (any supported by the standard serial port);
  80. * 7) Stop Bits (1, 1½, 2);
  81.  
  82. @06, 00 SAY "Initializing channel " + LTRIM(STR(channel))
  83. ret = comxi_i_channel(portid, 0, channel, 9600, 7, PARITY_EVEN, 1)
  84. @07, 00 SAY "Return code: " + LTRIM(STR(ret))
  85. IF ret < 0
  86.     @08, 00 SAY "Unable to initialize port"
  87.     @09, 00 SAY "Check parameters and configuration"
  88.     RETURN
  89. ELSE
  90.     @08, 00 SAY "Channel " + LTRIM(STR(channel)) + " successfully initialized"
  91. ENDIF
  92.  
  93.  
  94. * From this point on, it's business as usual. No special calls needed.
  95. * CommTools translates standard calls into DigiBoard calls.
  96. * The board is automatically deinitialized at the end of the program, but
  97. * you may call comxi_deinit(<board_number>) prior to that if you wish.
  98.  
  99. =set_tx_xlat(portid, FLOWCTL, XONXOFF)    && assert flow ctl.
  100. =set_rx_xlat(portid, LOCAL_ECHO, TRUE)    && turn on RX local echo
  101. =c_term(portid)
  102. @ 24,00 SAY "End of CommTools DigiBoard Example " + LTRIM(STR(version))
  103. RETURN                               && quit to FoxPro/DOS
  104.  
  105.  
  106.  
  107. *
  108. * C_TERM(expN portid) -- This is the CLIPPER analog of term() in CCTxx.C.
  109. *
  110. PROCEDURE c_term
  111.     PARAMETERS portid
  112.     PRIVATE c
  113.  
  114.     ?
  115.     DO WHILE .T.
  116.         =c_getc(portid)                  && check the serial port for a byte
  117.         c = INKEY()                     && check keyboard for a key
  118.         DO CASE                         && evaluate the received key
  119.             CASE c == ESC               && ESCape was pressed
  120.                 RETURN
  121.             CASE c <> 0
  122.                 =c_putc(portid, c)
  123.         ENDCASE
  124.     ENDDO                               && DO WHILE .T.
  125. RETURN
  126.