OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
CommunicationConfiguration.cs
1using System;
2using System.Linq;
3using System.Text;
6
8{
13 {
19 public CommunicationConfiguration(byte address, int baudRate)
20 {
21 Address = address;
22 BaudRate = baudRate;
23 }
24
26 public override byte Code => (byte)ReplyType.PdCommunicationsConfigurationReport;
27
31 public byte Address { get; }
32
36 public int BaudRate { get; }
37
39 public override ReadOnlySpan<byte> SecurityControlBlock() => SecurityBlock.ReplyMessageWithDataSecurity;
40
44 internal static CommunicationConfiguration ParseData(ReadOnlySpan<byte> data)
45 {
46 var dataArray = data.ToArray();
47 if (dataArray.Length != 5)
48 {
49 throw new Exception("Invalid size for the data");
50 }
51
52 return new CommunicationConfiguration(dataArray[0], Message.ConvertBytesToInt(dataArray.Skip(1).ToArray()));
53 }
54
56 public override byte[] BuildData() => [
57 Address, (byte)(BaudRate & 0xff),(byte)((BaudRate >> 8) & 0xff),
58 (byte)((BaudRate >> 16) & 0xff), (byte)((BaudRate >> 24) & 0xff)];
59
61 public override string ToString()
62 {
63 var build = new StringBuilder();
64 build.AppendLine($" Address: {Address}");
65 build.AppendLine($"Baud Rate: {BaudRate}");
66
67 return build.ToString();
68 }
69 }
70}
A base message class for sending or replying.
Definition Message.cs:12
Contains standard Security Control Block data that can be used when building messages.
Base class representing a payload an OSDP message.
Definition PayloadData.cs:9
override ReadOnlySpan< byte > SecurityControlBlock()
CommunicationConfiguration(byte address, int baudRate)
Initializes a new instance of CommunicationConfiguration class.
ReplyType
Identifies the type of OSDP protocol reply (PD -> ACU) message.
Definition ReplyType.cs:7