home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s038 / 1.ddi / SUPP.LIF / SIGSRVR.PLM < prev    next >
Encoding:
Text File  |  1992-07-06  |  5.4 KB  |  138 lines

  1. $compact optimize(3) debug pw(79) rom
  2.  
  3. /***********************************************************************
  4.  **                                                                   **
  5.  **                                                                   **
  6.  **   OBJECTIVE : To demonstrate how one can send or receive a        **
  7.  **               MULTIBUS-II signal (a 4 byte data-less message)     **
  8.  **               to a remote agent using the Nucleus Communication   **
  9.  **               Service of the iRMX II/III Operating Systems.       **
  10.  **                                                                   **
  11.  **                                                                   **
  12.  **                                                                   **
  13.  **   USAGE:                                                          **
  14.  **                                                                   **
  15.  **    This program can be executed on any MULTIBUS-II board          **
  16.  **    running the iRMX II/III Operating Systems.                     **
  17.  **    The board must be situated in slot SERVER$PSB$SLOT, where      **
  18.  **    CLIENT$PSB$SLOT and SERVER$PSB$SLOT are defined in utils.lit.  **
  19.  **                                                                   **
  20.  **                                                                   **
  21.  **   ALGORITHM : 1. Enable in-line exception handling feature.       **
  22.  **                                                                   **
  23.  **               2. Wait to receive a signal from agent in slot      **
  24.  **                  CLIENT$PSB$SLOT.                                 **
  25.  **                                                                   **
  26.  **               3. Display "SIGNAL RECEIVED" message to console.    **
  27.  **                                                                   **
  28.  **               4. Send a signal to the agent in slot               **
  29.  **                  CLIENT$PSB$SLOT.                                 **
  30.  **                                                                   **
  31.  **               5. Repeat steps 2 - 5                               **
  32.  **                                                                   **
  33.  **                                                                   **
  34.  ***********************************************************************/
  35.  
  36. server: DO;
  37.  
  38. $INCLUDE (utils.lit)
  39. $INCLUDE (utils.ext)
  40.  
  41. $INCLUDE (:RMX:inc/nuclus.ext)
  42. $INCLUDE (:RMX:inc/bios.ext)
  43. $INCLUDE (:RMX:inc/eios.ext)
  44. $INCLUDE (:RMX:inc/hi.ext)
  45. $INCLUDE (:RMX:inc/udi.ext)
  46.  
  47. DECLARE    buffer                TOKEN,
  48.         eh_handler            EX_HANDLER_STRUCT,
  49.         index                WORD,
  50.         inbuffptr            POINTER,
  51.         port$info$struc        SIG_PORT_INFO_STRUCT,
  52.         max                    WORD,
  53.         port$tkn            TOKEN,
  54.         server$socket        DWORD,
  55.         socket                DWORD,
  56.         status                WORD,
  57.         trans$id            WORD,
  58.         message  (*)        BYTE    DATA
  59.                             (29,'Signal Received From Client',CR,LF,0),
  60.         message2 (*)        BYTE    DATA
  61.                             (32,'Signal Has Been Sent To Client',CR,LF,0),
  62.         message3 (*)        BYTE    DATA
  63.                             (34,'Waiting For a Signal From Client',CR,LF,0),
  64.         data$ptr(255)        BYTE,
  65.         control$ptr(20)        BYTE,
  66.         count                BYTE,
  67.         no$signal            BYTE,
  68.         server$socket$ovl    STRUCTURE    (psb$slot    WORD,
  69.                                          port$id    WORD)
  70.                             AT    (@server$socket);
  71.  
  72.  
  73.  
  74. /**********************************************************************
  75.  ************************ MAIN PROGRAM BEGINS *************************
  76.  **********************************************************************/
  77. main:
  78.  
  79.     /*    Enable in-line exception handling    */
  80.     CALL rq$get$exception$handler(@eh_handler,@status);
  81.     eh_handler.mode = 0;
  82.     CALL rq$set$exception$handler(@eh_handler,@status);
  83.  
  84.     /*    Create the communication port object for this board    */
  85.     port$info$struc.message$id    = CLIENT$PSB$SLOT;    /*    Destination Board    */
  86.     port$info$struc.reserved1    = 0;
  87.     port$info$struc.type        = SIGNAL$SERVICE;    /*    Transport Protocol    */
  88.     port$info$struc.reserved2    = 0;
  89.     port$info$struc.flags        = FIFO$PORT$QUEUEING;
  90.     port$tkn = rq$create$port (0, @port$info$struc,@status);   
  91.     CALL check$exception( @(14,'rq$create$port'), status);
  92.  
  93.  
  94.     DO count = 0 TO 5;
  95.  
  96.         no$signal = 1;
  97.  
  98.         /*    Loop until a signal has been received from the Client    */
  99.         DO WHILE (no$signal);
  100.  
  101.             /*    Display waiting for signal from client message    */
  102.             CALL rq$c$send$co$response(nil,0,@message3,@status);
  103.             CALL check$exception( @(21,'rq$c$send$co$response'), status);
  104.  
  105.             /*    Try receiving a signal at the port    */
  106.             CALL rq$receive$signal(port$tkn,1,@status); 
  107.             CALL check$exception( @(17,'rq$receive$signal'), status);
  108.  
  109.             IF (status = E$OK) THEN
  110.                 no$signal = 0;
  111.  
  112.         END;    /*    DO WHILE (no$signal)    */
  113.  
  114.         /*    Display signal received message    */
  115.         CALL rq$c$send$co$response(nil,0,@message,@status);
  116.         CALL check$exception( @(21,'rq$c$send$co$response'), status);
  117.  
  118.         /*    Display signal sent message    */
  119.         CALL rq$c$send$co$response(nil,0,@message2,@status);
  120.         CALL check$exception( @(21,'rq$c$send$co$response'), status);
  121.  
  122.         /*    Send a signal back to the client board    */
  123.         CALL rq$send$signal(port$tkn,@status);
  124.         CALL check$exception( @(14,'rq$send$signal'), status);
  125.  
  126.     END;    /*    DO count = 0 TO 5    */
  127.  
  128.  
  129.     /*    Clean up    */
  130.     CALL rq$delete$port(port$tkn,@status);
  131.     CALL check$exception( @(14,'rq$delete$port'), status);
  132.  
  133.     /*    Exit gracefully    */
  134.     CALL rq$exit$io$job(0,NIL,@status);
  135.     CALL check$exception( @(14,'rq$exit$io$job'), status);
  136.  
  137. END server;    /*    End of module    */
  138.