home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a081 / 2.ddi / CTFXX.EXE / CTFDCOM0.PRG < prev    next >
Encoding:
Text File  |  1992-04-21  |  4.1 KB  |  111 lines

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