Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

few small fixes #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Console/Sony/PlayStation5/Views/PS5NorView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions Console/Sony/PlayStation5/Views/PS5UartView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ private async Task RunCodeLookupAsync()
var errorCode = TextBoxRawCommand.Text.ToUpperInvariant().Trim();
TextBoxRawCommand.Clear();
if (string.IsNullOrEmpty(errorCode)) return;
var errors = errorCodeList?.PlayStation5?.ErrorCodes?.Where(x => x.ID.StartsWith(errorCode, StringComparison.InvariantCultureIgnoreCase)).ToList();
var errors = errorCodeList?.PlayStation5?.ErrorCodes.FindAll(x => Regex.IsMatch(errorCode.Trim(), x.ID, RegexOptions.IgnoreCase));
if (errors == default || errors.Count == 0)
{
Log.AppendLine($"Error Code: {errorCode} - Not found in list.{Environment.NewLine}" +
Expand All @@ -742,17 +742,19 @@ private async Task RunCodeLookupAsync()
}
await Task.Run(() =>
{
foreach (var code in errors)
Log.Invoke((Action)(() =>
{
Log.AppendLine($"Found the following information.{Environment.NewLine}" +
$"Source: Internal Database{Environment.NewLine}" +
$"Error Code: {code.ID}");
Log.Append("Priroity Level: ");
Log.AppendLine(code.Priority.ToString(), code.Priority);
Log.AppendLine($"Message: {code.Message}");
Log.InsertFriendlyNameHyperLink("Click for TSB Information", $"{OnlineTsbUrl}{code.ID}");
$"Error Code: {errorCode}");
Log.AppendLine(string.Empty);
}
foreach (var code in errors)
{
Log.LogPlaystationErrorCode(code, true);
Log.InsertFriendlyNameHyperLink("Click for TSB Information", $"{OnlineTsbUrl}{code.ID}");
Log.AppendLine(string.Empty);
}
}));
});

}
Expand Down
16 changes: 9 additions & 7 deletions Console/Sony/Shared/Nvs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ internal class Nvs : INorData
internal ConsoleType ConsoleType; //offset 0x1C7010
private readonly byte[] Unknown0 = new byte[0x1ec]; //offset 0x1C7014
private readonly byte[] MotherBoardSerialNumberData = new byte[16]; //offset 0x1C7200
private readonly byte[] SerialData = new byte[16]; //offset 0x1C7210
private readonly byte[] Unknown1 = new byte[16]; //offset 0x1C7220
private readonly byte[] SerialData = new byte[32]; //offset 0x1C7210
private readonly byte[] SkuData = new byte[16]; //offset 0x1C7230
private readonly byte[] Unknown2 = new byte[16]; //offset 0x1C7240
private readonly byte[] BoardIdData = new byte[13]; //offset 0x1C7250
Expand Down Expand Up @@ -54,12 +53,17 @@ internal string MotherBoardSerialNumber

internal string Serial
{
get => SerialData.ReadCString();
get => SerialData.ReadStringUntilChar(0xFF);
set
{
Array.Clear(SerialData);
Array.Clear(SerialData, 0, SerialData.Length);
var data = Encoding.ASCII.GetBytes(value);
Array.Copy(data, SerialData, data.Length);
var length = Math.Min(data.Length, SerialData.Length);
Array.Copy(data, 0, SerialData, 0, length);
for (int i = length; i < SerialData.Length; i++)
{
SerialData[i] = 0xFF;
}
}
}

Expand Down Expand Up @@ -112,7 +116,6 @@ internal Nvs(BinaryReader reader)
Unknown0 = reader.ReadBytes(Unknown0.Length);
MotherBoardSerialNumberData = reader.ReadBytes(MotherBoardSerialNumberData.Length);
SerialData = reader.ReadBytes(SerialData.Length);
Unknown1 = reader.ReadBytes(Unknown1.Length);
SkuData = reader.ReadBytes(SkuData.Length);
Unknown2 = reader.ReadBytes(Unknown2.Length);
BoardIdData = reader.ReadBytes(BoardIdData.Length);
Expand Down Expand Up @@ -142,7 +145,6 @@ public byte[] ToArray()
buffer.AddRange(Unknown0);
buffer.AddRange(MotherBoardSerialNumberData);
buffer.AddRange(SerialData);
buffer.AddRange(Unknown1);
buffer.AddRange(SkuData);
buffer.AddRange(Unknown2);
buffer.AddRange(BoardIdData);
Expand Down
12 changes: 12 additions & 0 deletions Utils/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ internal static string ReadStringUntilChar(this BinaryReader reader, byte until)
}
return result.ToString();
}

internal static string ReadStringUntilChar(this byte[] str, byte until)
{
var result = new StringBuilder();
foreach (var character in str)
{
if (character == until)
break;
result.Append((char)character);
}
return result.ToString();
}

/// <summary>
/// Reads a fixed size ASCII string
Expand Down