2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2016-01-13 19:59:44 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Fujitsu.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2016-01-13 19:59:44 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Fujitsu vendor commands.
|
2016-01-13 19:59:44 +00:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Contains vendor commands for Fujitsu SCSI devices.
|
2016-01-13 19:59:44 +00:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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
|
2016-01-13 19:59:44 +00:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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.
|
2016-01-13 19:59:44 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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/>.
|
2016-01-13 19:59:44 +00:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
// Copyright © 2011-2025 Natalia Portillo
|
2016-01-13 19:59:44 +00:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2016-01-13 19:59:44 +00:00
|
|
|
using System;
|
2017-12-21 14:30:38 +00:00
|
|
|
using System.Text;
|
2020-07-20 15:43:52 +01:00
|
|
|
using Aaru.Helpers;
|
2025-08-17 05:50:25 +01:00
|
|
|
using Aaru.Logging;
|
2016-01-13 19:59:44 +00:00
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
namespace Aaru.Devices;
|
|
|
|
|
|
2022-03-26 18:31:04 +00:00
|
|
|
public partial class Device
|
2016-01-13 19:59:44 +00:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Sets the data for the integrated display</summary>
|
|
|
|
|
/// <param name="senseBuffer">Returned SENSE buffer</param>
|
|
|
|
|
/// <param name="flash">If the display should start flashing</param>
|
|
|
|
|
/// <param name="mode">Display mode</param>
|
|
|
|
|
/// <param name="firstHalf">String to be shown in the first line of the display</param>
|
|
|
|
|
/// <param name="secondHalf">String to be shown in the second line of the display</param>
|
|
|
|
|
/// <param name="timeout">Timeout to wait for command execution</param>
|
|
|
|
|
/// <param name="duration">Time the device took to execute the command in milliseconds</param>
|
|
|
|
|
/// <returns><c>true</c> if the device set an error condition, <c>false</c> otherwise</returns>
|
2025-08-22 19:57:09 +01:00
|
|
|
public bool FujitsuDisplay(out ReadOnlySpan<byte> senseBuffer, bool flash, FujitsuDisplayModes mode,
|
|
|
|
|
string firstHalf, string secondHalf, uint timeout, out double duration)
|
2016-01-13 19:59:44 +00:00
|
|
|
{
|
2025-08-22 15:56:59 +01:00
|
|
|
byte[] tmp;
|
2025-11-24 20:12:10 +00:00
|
|
|
var firstHalfBytes = new byte[8];
|
|
|
|
|
var secondHalfBytes = new byte[8];
|
|
|
|
|
var buffer = new byte[17];
|
|
|
|
|
var displayLen = false;
|
|
|
|
|
var halfMsg = false;
|
2025-08-22 15:56:59 +01:00
|
|
|
Span<byte> cdb = CdbBuffer[..10];
|
2025-08-22 19:57:09 +01:00
|
|
|
senseBuffer = SenseBuffer;
|
2025-08-22 15:56:59 +01:00
|
|
|
cdb.Clear();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(firstHalf))
|
2016-01-13 19:59:44 +00:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
tmp = Encoding.ASCII.GetBytes(firstHalf);
|
|
|
|
|
Array.Copy(tmp, 0, firstHalfBytes, 0, 8);
|
|
|
|
|
}
|
2018-06-22 08:08:38 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!string.IsNullOrWhiteSpace(secondHalf))
|
|
|
|
|
{
|
|
|
|
|
tmp = Encoding.ASCII.GetBytes(secondHalf);
|
|
|
|
|
Array.Copy(tmp, 0, secondHalfBytes, 0, 8);
|
|
|
|
|
}
|
2016-01-13 19:59:44 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(mode != FujitsuDisplayModes.Half)
|
2023-10-03 23:12:01 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
|
|
|
|
|
!ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes))
|
|
|
|
|
displayLen = true;
|
|
|
|
|
else if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
|
|
|
|
|
ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes))
|
|
|
|
|
halfMsg = true;
|
2023-10-03 23:12:01 +01:00
|
|
|
}
|
2016-01-13 19:59:44 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
buffer[0] = (byte)((byte)mode << 5);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
if(displayLen) buffer[0] += 0x10;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
if(flash) buffer[0] += 0x08;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
if(halfMsg) buffer[0] += 0x04;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
buffer[0] += 0x01; // Always ASCII
|
2016-01-13 19:59:44 +00:00
|
|
|
|
2023-10-03 23:12:01 +01:00
|
|
|
Array.Copy(firstHalfBytes, 0, buffer, 1, 8);
|
2022-03-06 13:29:38 +00:00
|
|
|
Array.Copy(secondHalfBytes, 0, buffer, 9, 8);
|
2016-01-13 19:59:44 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
cdb[0] = (byte)ScsiCommands.FujitsuDisplay;
|
|
|
|
|
cdb[6] = (byte)buffer.Length;
|
2016-01-13 19:59:44 +00:00
|
|
|
|
2025-08-22 19:57:09 +01:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, timeout, ScsiDirection.Out, out duration, out bool sense);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 19:59:44 +00:00
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
AaruLogging.Debug(SCSI_MODULE_NAME, Localization.FUJITSU_DISPLAY_took_0_ms, duration);
|
2016-01-13 19:59:44 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
return sense;
|
2016-01-13 19:59:44 +00:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|