OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
BaudRateChange.cs
1using System;
5
7{
13 {
15 public const int PayloadLength = 6;
16
22 public BaudRateChange(byte sequenceNumber, LineQualityBaudRate baudRateId)
23 {
24 SequenceNumber = sequenceNumber;
25 BaudRateId = baudRateId;
26 }
27
29 public byte SequenceNumber { get; }
30
33
35 public override CommandType CommandType => CommandType.ManufacturerSpecific;
36
38 public override byte Code => (byte)CommandType;
39
41 public override ReadOnlySpan<byte> SecurityControlBlock() => SecurityBlock.CommandMessageWithDataSecurity;
42
44 public override byte[] BuildData()
45 {
46 var data = new byte[PayloadLength];
47 LineQualityProtocol.VendorCodeBytes.CopyTo(data, 0);
49 data[4] = SequenceNumber;
50 data[5] = (byte)BaudRateId;
51 return data;
52 }
53
60 public static bool TryParse(ReadOnlySpan<byte> payload, out BaudRateChange command)
61 {
62 command = null;
63
64 if (payload.Length < PayloadLength) return false;
65 if (!LineQualityProtocol.IsLineQualityVendorCode(payload)) return false;
66 if (payload[3] != LineQualityProtocol.BaudRateChangeCommandId) return false;
67
68 command = new BaudRateChange(payload[4], (LineQualityBaudRate)payload[5]);
69 return true;
70 }
71 }
72}
override ReadOnlySpan< byte > SecurityControlBlock()
BaudRateChange(byte sequenceNumber, LineQualityBaudRate baudRateId)
Initializes a Baud Rate Change command.
LineQualityBaudRate BaudRateId
Gets the requested baud rate identifier.
byte SequenceNumber
Gets the test sequence number.
static bool TryParse(ReadOnlySpan< byte > payload, out BaudRateChange command)
Attempts to parse a Baud Rate Change command from an osdp_MFG payload.
const int PayloadLength
Number of payload bytes in a baud rate change command.
Constants and helpers for the OSDP Line Quality Test Procedure.
const byte BaudRateChangeCommandId
Command and reply identifier for the baud rate change exchange.
static bool IsLineQualityVendorCode(ReadOnlySpan< byte > candidate)
Determines whether the supplied bytes are the reserved line quality vendor code.
Contains standard Security Control Block data that can be used when building messages.
LineQualityBaudRate
Baud Rate identifiers defined by the OSDP Line Quality Test Procedure, section 3.4.