Files
Aaru/Aaru.Devices/Device/ScsiCommands/Certance.cs

80 lines
3.4 KiB
C#

// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Certance.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Certance vendor commands.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains vendor commands for Certance SCSI devices.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2025 Natalia Portillo
// ****************************************************************************/
using System;
using System.Diagnostics.CodeAnalysis;
using Aaru.Logging;
namespace Aaru.Devices;
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public partial class Device
{
/// <summary>Parks the load arm in preparation for transport</summary>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool CertancePark(out ReadOnlySpan<byte> senseBuffer, uint timeout, out double duration) =>
CertanceParkUnpark(out senseBuffer, true, timeout, out duration);
/// <summary>Unparks the load arm prior to operation</summary>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool CertanceUnpark(out ReadOnlySpan<byte> senseBuffer, uint timeout, out double duration) =>
CertanceParkUnpark(out senseBuffer, false, timeout, out duration);
/// <summary>Parks the load arm in preparation for transport or unparks it prior to operation</summary>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="park">If set to <c>true</c>, parks the load arm</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool CertanceParkUnpark(out ReadOnlySpan<byte> senseBuffer, bool park, uint timeout, out double duration)
{
byte[] buffer = [];
Span<byte> cdb = CdbBuffer[..6];
cdb.Clear();
senseBuffer = SenseBuffer;
cdb[0] = (byte)ScsiCommands.CertanceParkUnpark;
if(park) cdb[4] = 1;
LastError = SendScsiCommand(cdb, ref buffer, timeout, ScsiDirection.None, out duration, out bool sense);
Error = LastError != 0;
AaruLogging.Debug(SCSI_MODULE_NAME, Localization.CERTANCE_PARK_UNPARK_took_0_ms, duration);
return sense;
}
}