Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pc"></param>
        /// <param name="page"></param>
        /// <param name="table"></param>
        /// <returns></returns>
        public CommandStatus ModeSense(PageControl pc, byte page, out ModeTable table)
        {
            if (m_logger != null)
            {
                string args = pc.ToString() + ", " + page.ToString() + ", out result";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ModeSense(" + args + ")"));
            }

            ushort len = 0;

            table = null;

            byte b = 0;
            b |= (byte)((byte)(pc) << 7);
            b |= (byte)(page & 0x3f);

            using (Command cmd = new Command(ScsiCommandCode.ModeSense, 10, 8, Command.CmdDirection.In, 60 * 5))
            {
                cmd.SetCDB8(1, 8);              // Disable block descriptors
                cmd.SetCDB8(2, b);
                cmd.SetCDB16(7, 8);

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

                len = cmd.GetBuffer16(0);
                len += 2;
            }

            using (Command cmd = new Command(ScsiCommandCode.ModeSense, 10, len, Command.CmdDirection.In, 60 * 5))
            {
                cmd.SetCDB8(1, 8);              // Disable block descriptors
                cmd.SetCDB8(2, b);
                cmd.SetCDB16(7, len);

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

                table = new ModeTable(cmd.GetBuffer(), cmd.BufferSize);
            }

            return CommandStatus.Success;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="save"></param>
        /// <param name="table"></param>
        /// <returns></returns>
        public CommandStatus ModeSelect(bool save, ModeTable table)
        {
            if (m_logger != null)
            {
                string t = "";
                for (int i = 0; i < table.Pages.Count; i++)
                {
                    if (t.Length > 0)
                        t += ", ";
                    t = t + table.Pages[i].PageCode;
                }
                string args = save.ToString() + ", ModeTable(" + t + ")";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ModeSelect(" + args + ")"));
            }

            using (Command cmd = new Command(ScsiCommandCode.ModeSelect, 10, table.Size, Command.CmdDirection.Out, 60 * 5))
            {
                byte b = 0x10;
                if (save)
                    b |= 0x01;

                cmd.SetCDB8(1, b);
                cmd.SetCDB16(7, table.Size);
                table.Format(cmd.GetBuffer());

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

            return CommandStatus.Success;
        }