home *** CD-ROM | disk | FTP | other *** search
-
- #include "xc.h"
- int a_count = 0;
- int send_count = 0;
-
- main()
- {
- int ch;
- long int xc_test();
- int far event_func();
-
- /* Initialize XCOMMS and set up COM1 */
- xc_entr(8);
- xc_link(COM1,0);
- xc_init(COM1,BAUD2400,NOPAR,DATA8,STOP1);
-
- /* Set up an event handler for receive and transmit characters */
- xc_set_int_exit(COM1,3,event_func);
- /* Loop sending keys pressed and printing keys received */
- while(1)
- {
- if(xck_keyt())
- {
- ch = xck_getc();
- if((unsigned char) ch == 'Q') /* Hit Q to quit */
- break;
- xc_putc(COM1, ch);
- }
- if(xc_test(COM1))
- {
- ch = xc_getc(COM1);
- xcv_wtty(ch);
- }
- }
-
- /* Disable event handler by supplying a mask of zero */
- xc_set_int_exit(COM1,0,event_func);
- xc_exit();
- printf("a_count = %d, send_count = %d",a_count, send_count);
- }
-
- int far event_func(int port, int mask, int ch)
- {
- if(mask == 1) /* receive? */
- {
- if((char) ch == 'A') /* If = A, increment count */
- { /* and change to a B. */
- a_count++;
- return('B');
- }
- }
- else /* must be send */
- send_count++;
- return(0);
- }