92 lines
3.3 KiB
C#
92 lines
3.3 KiB
C#
namespace SIRTBroadcaster.Abstraction
|
|
{
|
|
using System;
|
|
|
|
/// <summary>
|
|
/// Generic SIRT message.
|
|
/// Keeped simple in order to be serialized (to) and deserialized (from) as JSON or other formats.
|
|
/// <list type="number">
|
|
/// <listheader>It has always the same structure:</listheader>
|
|
/// <item>[0] - Start byte.</item>
|
|
/// <item>[1] - Message type.</item>
|
|
/// <item>[2] - Parameter 1.</item>
|
|
/// <item>[3] - Parameter 2.</item>
|
|
/// <item>[4 .. 7] - Radio address.</item>
|
|
/// <item>[8] - Data length.</item>
|
|
/// <item>[9 .. n] - Data bytes.</item>
|
|
/// <item>[9 + n .. 9 + n + 2] - CRC check sum.</item>
|
|
/// <item>[9 + n + 3] - Stop byte.</item>
|
|
/// </list>
|
|
/// </summary>
|
|
public class SIRTMessage : SIRTModel
|
|
{
|
|
/// <summary>
|
|
/// <list type="bullet">
|
|
/// <listheader>Describes the message direction:</listheader>
|
|
/// <item>PC -> SIRT always = 0x55.</item>
|
|
/// <item>SIRT -> PC always = 0xFF.</item>
|
|
/// </list>
|
|
/// </summary>
|
|
public byte StartByte { get; set; }
|
|
|
|
/// <summary>
|
|
/// <list type="bullet">
|
|
/// <listheader>Describes the message type:</listheader>
|
|
/// <item>Write PAM = 0x81.</item>
|
|
/// <item>Read PAM = 0x82.</item>
|
|
/// <item>Write RAC = 0x88.</item>
|
|
/// <item>Read RAC = 0x8B.</item>
|
|
/// <item>Write SIRT = 0x84.</item>
|
|
/// <item>Read SIRT = 0x87.</item>
|
|
/// </list>
|
|
/// </summary>
|
|
public byte MessageType { get; set; }
|
|
|
|
/// <summary>
|
|
/// TODO: Add description ...
|
|
/// </summary>
|
|
public byte Parameter1 { get; set; }
|
|
|
|
/// <summary>
|
|
/// TODO: Add description ...
|
|
/// </summary>
|
|
public byte Parameter2 { get; set; }
|
|
|
|
/// <summary>
|
|
/// The radio address as Uint32 converted as follows:
|
|
/// <para />
|
|
/// <code>uint address = BitConverter.ToUInt32(new byte[] { 0x00, 0x00, 0x00, 0x20 }, 0); // => 536870912.</code>
|
|
/// <para />
|
|
/// <code>byte[] addressBytes = BitConverter.GetBytes(address); // => new byte[] { 0x00, 0x00, 0x00, 0x20 }.</code>
|
|
/// <para>Note: From and to SIRT address bytes are reversed and are looking like that - new byte[] { 0x20, 0x00, 0x00, 0x00 }</para>
|
|
/// </summary>
|
|
public uint Address { get; set; }
|
|
|
|
/// <summary>
|
|
/// The length of the following data bytes.
|
|
/// Not longer than 128.
|
|
/// </summary>
|
|
public byte DataLength { get; set; }
|
|
|
|
/// <summary>
|
|
/// TODO: Add description ...
|
|
/// </summary>
|
|
public byte[] Data { get; set; } = new byte[0];
|
|
|
|
/// <summary>
|
|
/// TODO: Add description ...
|
|
/// </summary>
|
|
public byte[] CRC { get; set; } = new byte[2];
|
|
|
|
/// <summary>
|
|
/// TODO: Add description ...
|
|
/// </summary>
|
|
public byte StopByte { get; set; } = SIRTFixed.StopByte;
|
|
|
|
/// <summary>
|
|
/// TODO: Add description ...
|
|
/// </summary>
|
|
public DateTime TimeStamp { get; set; } = DateTime.Now;
|
|
}
|
|
}
|