$compact optimize(3) debug pw(79) rom /*********************************************************************** ** ** ** ** ** OBJECTIVE : To demonstrate how one can send or receive a ** ** MULTIBUS-II signal (a 4 byte data-less message) ** ** to a remote agent using the Nucleus Communication ** ** Service of the iRMX II/III Operating Systems. ** ** ** ** ** ** ** ** USAGE: ** ** ** ** This program can be executed on any MULTIBUS-II board ** ** running the iRMX II/III Operating Systems. ** ** The board must be situated in slot SERVER$PSB$SLOT, where ** ** CLIENT$PSB$SLOT and SERVER$PSB$SLOT are defined in utils.lit. ** ** ** ** ** ** ALGORITHM : 1. Enable in-line exception handling feature. ** ** ** ** 2. Wait to receive a signal from agent in slot ** ** CLIENT$PSB$SLOT. ** ** ** ** 3. Display "SIGNAL RECEIVED" message to console. ** ** ** ** 4. Send a signal to the agent in slot ** ** CLIENT$PSB$SLOT. ** ** ** ** 5. Repeat steps 2 - 5 ** ** ** ** ** ***********************************************************************/ server: DO; $INCLUDE (utils.lit) $INCLUDE (utils.ext) $INCLUDE (:RMX:inc/nuclus.ext) $INCLUDE (:RMX:inc/bios.ext) $INCLUDE (:RMX:inc/eios.ext) $INCLUDE (:RMX:inc/hi.ext) $INCLUDE (:RMX:inc/udi.ext) DECLARE buffer TOKEN, eh_handler EX_HANDLER_STRUCT, index WORD, inbuffptr POINTER, port$info$struc SIG_PORT_INFO_STRUCT, max WORD, port$tkn TOKEN, server$socket DWORD, socket DWORD, status WORD, trans$id WORD, message (*) BYTE DATA (29,'Signal Received From Client',CR,LF,0), message2 (*) BYTE DATA (32,'Signal Has Been Sent To Client',CR,LF,0), message3 (*) BYTE DATA (34,'Waiting For a Signal From Client',CR,LF,0), data$ptr(255) BYTE, control$ptr(20) BYTE, count BYTE, no$signal BYTE, server$socket$ovl STRUCTURE (psb$slot WORD, port$id WORD) AT (@server$socket); /********************************************************************** ************************ MAIN PROGRAM BEGINS ************************* **********************************************************************/ main: /* Enable in-line exception handling */ CALL rq$get$exception$handler(@eh_handler,@status); eh_handler.mode = 0; CALL rq$set$exception$handler(@eh_handler,@status); /* Create the communication port object for this board */ port$info$struc.message$id = CLIENT$PSB$SLOT; /* Destination Board */ port$info$struc.reserved1 = 0; port$info$struc.type = SIGNAL$SERVICE; /* Transport Protocol */ port$info$struc.reserved2 = 0; port$info$struc.flags = FIFO$PORT$QUEUEING; port$tkn = rq$create$port (0, @port$info$struc,@status); CALL check$exception( @(14,'rq$create$port'), status); DO count = 0 TO 5; no$signal = 1; /* Loop until a signal has been received from the Client */ DO WHILE (no$signal); /* Display waiting for signal from client message */ CALL rq$c$send$co$response(nil,0,@message3,@status); CALL check$exception( @(21,'rq$c$send$co$response'), status); /* Try receiving a signal at the port */ CALL rq$receive$signal(port$tkn,1,@status); CALL check$exception( @(17,'rq$receive$signal'), status); IF (status = E$OK) THEN no$signal = 0; END; /* DO WHILE (no$signal) */ /* Display signal received message */ CALL rq$c$send$co$response(nil,0,@message,@status); CALL check$exception( @(21,'rq$c$send$co$response'), status); /* Display signal sent message */ CALL rq$c$send$co$response(nil,0,@message2,@status); CALL check$exception( @(21,'rq$c$send$co$response'), status); /* Send a signal back to the client board */ CALL rq$send$signal(port$tkn,@status); CALL check$exception( @(14,'rq$send$signal'), status); END; /* DO count = 0 TO 5 */ /* Clean up */ CALL rq$delete$port(port$tkn,@status); CALL check$exception( @(14,'rq$delete$port'), status); /* Exit gracefully */ CALL rq$exit$io$job(0,NIL,@status); CALL check$exception( @(14,'rq$exit$io$job'), status); END server; /* End of module */