home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_08 / v7n8034a.txt < prev    next >
Text File  |  1989-06-28  |  2KB  |  59 lines

  1. /* Demonstration program:  parallel poll of HP-IB (IEEE-488) device
  2.  * J. M. Anderson, F&M College, 1989.
  3.  *
  4.  * Only the function "process" is shown; other functions are very similar,
  5.  * or identical, to their counterparts in "tablspoll.c"
  6.  */
  7.  
  8. int process()
  9. {
  10.     /* Process the interrupt.
  11.      * This function is called when an interrupt
  12.      * is detected on the bus.
  13.      *
  14.      * For the purpose of this demo, SRQ must be asserted by the
  15.      * tablet for pen press or menu pick.
  16.      */
  17.      
  18.     int bstatus, tstatus;    /* bus status, tablet status */
  19.     int x, y, p, k;            /* pen position, menu key */
  20.     
  21.     /* See if interrupt was caused by the tablet.  Perform parallel poll.
  22.      * The tablet will assert line 1 whose value is 2 when its address is
  23.      * 06; all of this is fixed in the tablet's hardware.  Therefore,
  24.      * we should look for a response to the parallel poll whose value is
  25.      * 2.
  26.      */
  27.     ieeewt("ppoll\n");
  28.     ieeescnf("%d", &bstatus);
  29.     if (bstatus == 2)            /* response from tablet */
  30.     {
  31.         /* Serial-poll the tablet to find its status;
  32.          * We know that it is the tablet which caused the interrupt;
  33.          * all we need to do now is find out why.
  34.          */
  35.         ieeewt("spoll 06\n");
  36.         ieeescnf("%d", &tstatus);
  37.         if PENPRESS
  38.         {
  39.             ieeewt("output 06;OD\n");
  40.             ieeewt("enter 06\n");
  41.             ieeescnf("%d,%d,%d",&x, &y, &p);
  42.                 /* beep high for stylus press on tablet */
  43.             ieeewt("output 06;BP 48,150,4\n");
  44.             printf("\ndigitized point: %d %d\n",x, y);
  45.             return(0);
  46.         }
  47.         
  48.         if MENUPICK
  49.         {
  50.             ieeewt("output 06;RS1\n");
  51.             ieeewt("enter 06\n");
  52.             ieeescnf("%d", &k);
  53.                 /* beep low for stylus press on menu square */
  54.             ieeewt("output 06;BP 8,150,4\n");
  55.             printf("Menu square %d touched.\n", k);
  56.             return(1);
  57.         }
  58.     }
  59. }