Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CommandStatus ReadFormatCapacities(bool all, out IList<CapacityDescriptor> caplist)
        {
            caplist = new List<CapacityDescriptor>();

            if (m_logger != null)
            {
                string args = all.ToString() + ", out caplist";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadFormatCapacities(" + args + ")"));
            }
            int len;

            using (Command cmd = new Command(ScsiCommandCode.ReadFormatCapacities, 10, 8, Command.CmdDirection.In, 60))
            {
                cmd.SetCDB16(7, 8);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                len = cmd.GetBuffer8(3) + 4;
            }
            using (Command cmd = new Command(ScsiCommandCode.ReadFormatCapacities, 10, len, Command.CmdDirection.In, 60))
            {
                cmd.SetCDB16(7, (ushort)len);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                int offset = 4;
                len = cmd.GetBuffer8(3) + 4;
                while (offset < len)
                {
                    caplist.Add(new CapacityDescriptor(cmd.GetBuffer(), offset, cmd.BufferSize));
                    offset += 8;
                }
            }
            return CommandStatus.Success;
        }
Exemple #2
0
        /// <summary>
        /// Returns the start address of the Layer 0 middle zone (DVD+R DL, DVD-R DL)
        /// </summary>
        /// <param name="isfixed">return value, if true, the middle zone start is changeable</param>
        /// <param name="location">return value, the location of the L0 middle zone</param>
        /// <returns>status of the command</returns>
        public CommandStatus ReadDvdMiddleZoneStartAddr(out bool isfixed, out uint location)
        {
            if (m_logger != null)
            {
                string args = "ReadDvdMiddleZoneStartAddr, out bool isfixed, out uint size";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadDvdStructure(" + args + ")"));
            }

            location = 0;
            isfixed = false;

            using (Command cmd = new Command(ScsiCommandCode.ReadDvdStructure, 12, 12, Command.CmdDirection.In, 5 * 60))
            {
                cmd.SetCDB8(7, 0x21);
                cmd.SetCDB8(8, 12);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                if ((cmd.GetBuffer8(4) & 0x80) != 0)
                    isfixed = true;

                location = cmd.GetBuffer32(8);
            }

            return CommandStatus.Success;
        }
Exemple #3
0
        /// <summary>
        /// Perform a SCSI inquiry on the device to get information about the device
        /// </summary>
        /// <param name="result">The return value describing the inquiry results</param>
        /// <returns></returns>
        public CommandStatus Inquiry(out InquiryResult result)
        {
            if (m_logger != null)
            {
                string args = "out result";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.Inquiry(" + args + ")"));
            }

            result = null;

            byte len = 0;
            using (Command cmd = new Command(ScsiCommandCode.Inquiry, 6, 36, Command.CmdDirection.In, 10))
            {
                cmd.SetCDB16(3, 36);
                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                len = cmd.GetBuffer8(4);
                len += 5;

                if (len <= cmd.BufferSize)
                {
                    result = new InquiryResult(cmd.GetBuffer(), len);

                    if (m_logger != null)
                        m_logger.DumpBuffer(9, "Raw Inquiry Result", cmd.GetBuffer(), len);
                    return CommandStatus.Success;
                }

                //
                // As an oddity, the Sony DW-G120A only supports requests that are an even number
                // of bytes.
                //
                if ((len % 2) == 1)
                    len = (byte)((len / 2 * 2) + (((len % 2) == 1) ? 2 : 0));
            }

            using (Command cmd = new Command(ScsiCommandCode.Inquiry, 6, len, Command.CmdDirection.In, 100))
            {
                cmd.SetCDB8(4, len);
                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                result = new InquiryResult(cmd.GetBuffer(), cmd.BufferSize);

                if (m_logger != null)
                    m_logger.DumpBuffer(9, "Raw Inquiry Result", cmd.GetBuffer(), cmd.BufferSize);
            }

            return CommandStatus.Success;
        }
Exemple #4
0
        /// <summary>
        /// Returns the size of layer 0 for DL media (DVD+R DL and DVD-R DL)
        /// </summary>
        /// <param name="isfixed">return value, if true size of L0 is changable</param>
        /// <param name="size">return value, the current size of L0</param>
        /// <returns>status of the command</returns>
        public CommandStatus ReadDvdLayer0Size(out bool isfixed, out uint size)
        {
            if (m_logger != null)
            {
                string args = "ReadDvdLayer0Size, out bool isfixed, out uint size";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadDvdStructure(" + args + ")"));
            }

            size = 0;
            isfixed = false;

            using (Command cmd = new Command(ScsiCommandCode.ReadDvdStructure, 12, 12, Command.CmdDirection.In, 5 * 60))
            {
                cmd.SetCDB8(7, 0x20);         // Read manufacturing information
                cmd.SetCDB8(8, 12);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                if ((cmd.GetBuffer8(4) & 0x80) != 0)
                    isfixed = true;

                size = cmd.GetBuffer32(8);
            }

            return CommandStatus.Success;
        }
Exemple #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="polled"></param>
        /// <param name="request"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public CommandStatus GetEventStatusNotification(bool polled, NotificationClass request, out EventStatusNotification result)
        {
            if (m_logger != null)
            {
                string args = polled.ToString() + ", " + request.ToString() + ", out result";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.GetEventStatusNotification(" + args + ")"));
            }

            ushort len = 0;
            result = null;

            using (Command cmd = new Command(ScsiCommandCode.GetEventStatusNotification, 10, 4, Command.CmdDirection.In, 10))
            {
                if (polled)
                    cmd.SetCDB8(1, 1);
                cmd.SetCDB8(4, (byte)request);
                cmd.SetCDB16(7, 4);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                byte n = cmd.GetBuffer8(2);
                if ((n & 0x80) != 0)
                {
                    // There are no events, just capture the header
                    result = new EventStatusNotification(cmd.GetBuffer(), cmd.BufferSize);
                    return CommandStatus.Success;
                }

                //
                // There are event notifications to be grabbed, allocate space for these
                //
                len = cmd.GetBuffer16(0);
                len += 4;               // For the length field
            }

            using (Command cmd = new Command(ScsiCommandCode.GetEventStatusNotification, 10, len, Command.CmdDirection.In, 10))
            {
                if (polled)
                    cmd.SetCDB8(1, 1);
                cmd.SetCDB8(4, (byte)request);
                cmd.SetCDB16(7, len);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                result = new EventStatusNotification(cmd.GetBuffer(), cmd.BufferSize);
            }

            return CommandStatus.Success;
        }