home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 500 / 471 / rccl142 < prev    next >
Text File  |  1987-03-02  |  2KB  |  106 lines

  1. /*
  2.  * MAC  Version 2.0           Author :  Vincent Hayward
  3.  *                                      School of Electrical Engineering
  4.  *                                      Purdue University
  5.  *      Dir     : sys
  6.  *      File    : lsitst.c
  7.  *      Remarks : fifo test program
  8.  *      Usage   : make make test; use with vaxtst.c
  9.  */
  10.  
  11. #include "../h/stdio11.h"
  12. #include "../h/fifoio.h"
  13.  
  14. #define YES     1
  15. #define NO      0
  16.  
  17. extern int (* onclk)();
  18. extern int tick;
  19.  
  20. int exch, wc, delay, code;
  21. struct fifobuf obuf, ibuf;
  22.  
  23. struct drcdevice *dp = DRC_ADDR;
  24.  
  25. main()
  26. {
  27.     int send();
  28.     int i, tcc;
  29.  
  30.     setbuf(stdin,NULL);
  31.     setbuf(stdout,NULL);
  32.  
  33.     for(i = 0; i < FIFOBUFS; ++i)
  34.         obuf.data[i] = ID;
  35.     obuf.wc = FIFOBUFS;
  36.  
  37.     exch = 0;
  38.     onclk = send;
  39.  
  40.     printf("\nflip switch to Micro and type <return> to begin ");
  41.     while (getchar() != '\n')
  42.         ;
  43.  
  44.     dp->drccsr = 0;
  45.     while ((dp->drccsr & FIFO_EMPTY) == 0)
  46.         i = dp->drcbuf;
  47.  
  48.     printf("\ntick delay ");
  49.     scanf("%d%d", &tcc, &delay);
  50.  
  51.     tick = tcc;             /* from now the clock starts */
  52.  
  53.     while (tick)            /* do something in the background */
  54.         wait();
  55.     printf("exit ... exch = %d   wc = %d   code = %d\n", exch, ibuf.wc, code);
  56.     for (i = 0; i < FIFOBUFS; ++i) {
  57.         printf("%o ", ibuf.data[i]);
  58.     }
  59. }
  60.  
  61. send()
  62. {
  63.     register int i;
  64.     int spin;
  65.  
  66.     i = dr11(&ibuf, &obuf);
  67.     if (i < 0) {
  68.         code = i;
  69.         tick = 0;
  70.         return;
  71.     }
  72.     if (ibuf.wc != FIFOBUFS) {
  73.         code = -9;
  74.         tick = 0;
  75.         return;
  76.     }
  77.     if (ibuf.data[0] == 0) {
  78.         tick = 0;
  79.         code = 0;
  80.         return;
  81.     }
  82.     for(i=0; i < wc; ++i) {
  83.         if (ibuf.data[i] != OD) {
  84.             code = -8;
  85.             tick = 0;
  86.             return;
  87.         }
  88.     }
  89.     spin = delay;
  90.     while(spin--)
  91.         ;
  92.     ++exch;
  93. }
  94.  
  95.  
  96. zexit(n)
  97. int n;
  98. {
  99.     register struct drcdevice *dp = DRC_ADDR;
  100.  
  101.     tick = 0;
  102.     dp->drccsr = 0;
  103.     printf("\nexit %d\n", n);
  104.     halt();
  105. }
  106.