home *** CD-ROM | disk | FTP | other *** search
-
- #include "xc.h"
- int a_count = 0;
- int send_count = 0;
- int msr = 0;
- int lsr = 0;
- int hits[4] = {0,0,0,0};
- int msr_in[100] = {0};
- int lsr_in[100] = {0};
- int i;
-
- main()
- {
- int ch;
- long int xc_test();
- int far event_func();
- printf("Using setport for multiport board 0, 3F8Hex, COM3\n");
-
-
- /* Initialize XCOMMS and set up COM3 */
- xc_entr(8);
- setport(0x3f8,1,4,COM3,0);
- xc_link(COM3,0);
- xc_init(COM3,BAUD2400,NOPAR,DATA8,STOP1);
-
- /* Set up an event handler for receive and transmit characters */
- xc_set_int_exit(2,0xf,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(COM3, ch);
- }
- if(xc_test(COM3))
- {
- ch = xc_getc(COM3);
- xcv_wtty(ch);
- }
- }
-
- /* Disable event handler by supplying a mask of zero */
- xc_set_int_exit(2,0,event_func);
- xc_exit();
- printf("\na_count = %d, send_count = %d\n",a_count, send_count);
- printf("port hits = %d %d %d %d\n",hits[0],hits[1],hits[2],hits[3]);
- printf("msr count = %d, lsr count = %d\n",msr,lsr);
- for(i=0;lsr_in[i] != 0;i++)
- {
- printf("%x\n",lsr_in[i]);
- }
- }
-
- int far event_func(int port, int mask, int ch)
- {
- hits[port]++;
- 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 */
- if(mask == 2)
- send_count++;
- else
- if(mask == 3)
- msr++;
- else
- if(mask == 4)
- {
- lsr_in[lsr] = ch;
- lsr++;
- }
-
-
- return(0);
- }
-