34 lines
845 B
C#
34 lines
845 B
C#
using System;
|
|
|
|
namespace TBF.Rig.RegisterReaders.iPerlASICReader.communication.C4
|
|
{
|
|
public sealed class TouchReadResponse
|
|
{
|
|
public byte Control { get; }
|
|
public byte Status { get; }
|
|
public byte[] Payload { get; }
|
|
|
|
public bool IsOk => Status == 0x01;
|
|
|
|
public TouchReadResponse(byte control, byte status, byte[] payload)
|
|
{
|
|
Control = control;
|
|
Status = status;
|
|
Payload = payload ?? Array.Empty<byte>();
|
|
}
|
|
|
|
public string GetAsciiPayload()
|
|
{
|
|
if (Payload.Length == 0)
|
|
return null;
|
|
|
|
int length = Array.IndexOf(Payload, (byte)0x00);
|
|
if (length < 0)
|
|
length = Payload.Length;
|
|
|
|
return System.Text.Encoding.ASCII.GetString(Payload, 0, length);
|
|
}
|
|
}
|
|
|
|
|
|
} |