home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / DIGIPROG.ZIP / LOOPTEST.C < prev    next >
Text File  |  1991-11-21  |  2KB  |  80 lines

  1.  
  2.  
  3. #include <dos.h>
  4. #include <stdio.h>
  5.  
  6. main()
  7. {
  8.  
  9. struct REGPACK  sregs;
  10. int            y,x,cnt,dx1,dx2;
  11. union REGS     regs;
  12. char        *str = "DigiBoard";
  13. char        buff[100];
  14.  
  15.  
  16. /*
  17.     This program transmits a string, 'DigiBoard', from one channel to
  18.     another. This requires a null modem conector and a gender bender
  19.     between the two channel legs of the DigiBoard cable. It is assumed
  20.     that both channels are configured for the same baud rates ect..
  21.  
  22. */
  23.  
  24.  
  25.  
  26. printf("\nEnter TX channel # : ");
  27. scanf("%d",&dx1); while(kbhit()) getch();
  28.  
  29. printf("\nEnter RX channel # : ");
  30. scanf("%d",&dx2); while(kbhit()) getch();
  31.  
  32. /*  The ports are configured with xidoscfg.exe */
  33.  
  34.  
  35.     /* Get TX free space */
  36.  
  37.     sregs.r_ax = 0x1200;
  38.     sregs.r_dx = dx1;
  39.     intr(0x14,&sregs);
  40.     printf("\nChnl %d TX free space : %04X",dx1, sregs.r_ax);
  41.  
  42.     sregs.r_ax = 0x1200;
  43.     sregs.r_dx = dx2;
  44.     intr(0x14,&sregs);
  45.     printf("\nChnl %d TX free space : %04X",dx2, sregs.r_ax);
  46.  
  47.     /* write string */
  48.  
  49.     sregs.r_ax = 0x0e00;
  50.     sregs.r_cx = strlen(str);
  51.     sregs.r_dx = dx1;
  52.     sregs.r_es = FP_SEG(str);
  53.     sregs.r_bx = FP_OFF(str);
  54.     intr(0x14,&sregs);
  55.  
  56.     delay(1000);        /* wait for data to be transmitted */
  57.  
  58.     /* Get input character count */
  59.  
  60.     sregs.r_ax = 0x0A00;
  61.     sregs.r_dx = dx2;
  62.     intr(0x14,&sregs);
  63.     printf("\nChnl %d Input count   : %04X",dx2,sregs.r_ax);
  64.  
  65.  
  66.     /* Read string */
  67.  
  68.     sregs.r_cx = cnt = sregs.r_ax;
  69.     sregs.r_ax = 0x0F00;
  70.     sregs.r_dx = dx2;
  71.     sregs.r_es = FP_SEG(buff);
  72.     sregs.r_bx = FP_OFF(buff);
  73.     intr(0x14,&sregs);
  74.  
  75.     printf("\nChnl %d read data     : ",dx2);
  76.     for(x=0; x<cnt; x++)
  77.         printf("%c",buff[x]);
  78.  
  79.  
  80. }