InquiryCommandDescriptorBlock.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (C) 2012-2016 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace SCSI
  12. {
  13. public class InquiryCommand : SCSICommandDescriptorBlock
  14. {
  15. public bool EVPD; // Enable Vital Product Data
  16. public VitalProductDataPageName PageCode;
  17. public InquiryCommand() : base()
  18. {
  19. OpCode = SCSIOpCodeName.Inquiry;
  20. }
  21. public InquiryCommand(byte[] buffer, int offset)
  22. {
  23. OpCode = (SCSIOpCodeName)buffer[offset + 0];
  24. EVPD = (buffer[offset + 1] & 0x01) != 0;
  25. PageCode = (VitalProductDataPageName)buffer[offset + 2];
  26. AllocationLength = BigEndianConverter.ToUInt16(buffer, offset + 3);
  27. Control = buffer[offset + 5];
  28. }
  29. public override byte[] GetBytes()
  30. {
  31. byte[] buffer = new byte[6];
  32. buffer[0] = (byte)OpCode;
  33. if (EVPD)
  34. {
  35. buffer[1] |= 0x01;
  36. }
  37. buffer[2] = (byte)PageCode;
  38. BigEndianWriter.WriteUInt16(buffer, 3, AllocationLength);
  39. buffer[5] = Control;
  40. return buffer;
  41. }
  42. public ushort AllocationLength
  43. {
  44. get
  45. {
  46. return (ushort)TransferLength;
  47. }
  48. set
  49. {
  50. TransferLength = value;
  51. }
  52. }
  53. }
  54. }