Copyright Digital Equipment Corp. All rights reserved.

Example

   /*
    *   This is an example of using mrd_move_medium directly to move
    *   a cartridge from one slot to another.  To simplify the
    *   example, it only supports slot to slot moves, but it shows
    *   how the absolute element addresses are calcuated.  For each
    *   additional destination address given, the previous (successful)
    *   destination address is used as the source.
    *
    *   Usage:
    *
    *      mrd_ready robot port [ port... ]
    */
   #ifndef   lint
   static   char   SccsId[] = "@(#)mrd_ready.c   1.2 3/5/97" ;
   #endif

   #include <stdio.h>
   #include <stdlib.h>
   #include <mrd_common.h>
   #include <mrd_message.h>

   main(int argc, char *argv[])
   {
      int      pc ;      /* counter */
      int      port ;      /* Port number */
      int      address ;   /* Port address */
      int      status ;   /* return status */
      char      *robot ;   /* Robot to open */
      robot_info_t   robot_info ;   /* Robot data */
      dev_status_t   dev_status ;   /* Device status */
      char      log_info[MRD_MAX_LOG_STRING+1] ;

      /*
       *   Check that there are enough arguments.
       */
      if( argc < 3 ) {
         printf("usage: %s robot port [ port... ]\n", argv[0]) ;
         exit(1) ;
      }
      else
         robot  = argv[1] ;

      /*
       *   Initialize the channel field of the robot_info, so
       *   mrd_startup(3mrd) will actually open the robot.
       */
      robot_info.channel = BAD_CHANNEL ;

      status = mrd_startup(robot, &robot_info, log_info) ;

      if( status != MRD_STATUS_SUCCESS ) {
         printf("Startup failed on %s: %s.\n", robot,
            mrd_strstatus(status)) ;

         exit(1) ;
      }

      /*
       *   For each destination address on the command line,
       *   move the the cartridge in the source to the
       *   destination.  After each (successful) move, replace
       *   the previous source with this destination.
       */
      for(pc = 2; pc < argc; pc++) {
         /*
          *   Get the port number.
          */
         port = atoi(argv[pc]) ;

         /*
          *   Now the absolute address.
          */
         address = port + robot_info.port_start ;

         /*
          *   Print an audit as we go.  Since we know these
          *   are slots, convert back to relative addresses
          *   for the audit.
          */
         printf("Ready Inport #%d of %s\n", port, robot) ;

         status = mrd_ready(&robot_info, address, &dev_status) ;

         if( status != MRD_STATUS_SUCCESS ) {
            printf("Ready Inport failed on %s: %s.\n", robot,
               mrd_strstatus(status)) ;

            /*
             *   Since the cartridge didn't move, don't
             *   reset the source, by skipping the remainder
             *   of the loop.
             */
            continue ;
         }
      }

      (void)mrd_shutdown(&robot_info) ;

      return 0 ;
   }