Package org.jscsi.scsi.protocol.sense.additional

Examples of org.jscsi.scsi.protocol.sense.additional.SenseKeySpecificField


   }

   protected static SenseKeySpecificField decodeSenseKeySpecificField(SenseKey key, ByteBuffer input)
         throws IOException
   {
      SenseKeySpecificField field;
      switch (key)
      {
         case NO_SENSE :
            field = new ProgressIndication();
         case RECOVERED_ERROR :
            field = new ActualRetryCount();
         case NOT_READY :
            field = new ProgressIndication();
         case MEDIUM_ERROR :
            field = new ActualRetryCount();
         case HARDWARE_ERROR :
            field = new ActualRetryCount();
         case ILLEGAL_REQUEST :
            field = new FieldPointer();
         case COPY_ABORTED :
            field = new NoSenseKeySpecific(); // TODO: decode segment pointer, not supported now
         default :
            field = new NoSenseKeySpecific();
      }
      field.decode(input);
      return field;
   }
View Full Code Here


      try
      {
         byte[] info = this.getInformation();
         byte[] cmdi = this.getCommandSpecificInformation();
         KCQ kcq = this.getKCQ();
         SenseKeySpecificField field = this.getSenseKeySpecific();
         if (field == null)
         {
            field = new NoSenseKeySpecific();
         }

         // returned response code is byte with max value 0x7F (7-bit).
         int response = this.getResponseCode();

         // We mark VALID as 0 if info is null or over max size (4-byte).
         if (info != null && info.length == 4)
         {
            response |= 0x80;
         }
         else if (info.length < 4)
         {
            throw new RuntimeException("Returned sense information has invalid length: "
                  + info.length);
         }
         else
         {
            info = new byte[4]; // Ignore invalid or null value, will write all zeros to field
         }

         if (cmdi == null || cmdi.length != 4)
         {
            cmdi = new byte[4]; // Ignore invalid command specific information lengths.
         }

         out.writeByte(response); // VALID and RESPONSE CODE
         out.writeByte(0);
         out.writeByte(kcq.key().value()); // TODO: FILEMARK, EOM, and ILI not current supported
         out.write(info);
         out.writeByte(10); // no "Additional sense bytes" will be written, last byte is #17
         out.write(cmdi);
         out.writeByte(kcq.code());
         out.writeByte(kcq.qualifier());
         out.writeByte(0);
         out.write(field.encode());

         assert bs.toByteArray().length == FIXED_SENSE_DATA_LENGTH : "Invalid encoded sense data";
      }
      catch (IOException e)
      {
View Full Code Here

TOP

Related Classes of org.jscsi.scsi.protocol.sense.additional.SenseKeySpecificField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.