|
OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
|
Constants and helpers for the OSDP Line Quality Test Procedure. More...
Static Public Member Functions | |
| static bool | IsLineQualityVendorCode (ReadOnlySpan< byte > candidate) |
| Determines whether the supplied bytes are the reserved line quality vendor code. | |
| static byte[] | GeneratePattern (TestPattern pattern, int length) |
| Generates the test data for a pattern. | |
| static bool | ValidatePattern (TestPattern pattern, ReadOnlySpan< byte > data) |
| Determines whether data matches what the pattern should have produced. | |
| static bool | IsSupportedPattern (TestPattern pattern) |
| Determines whether a pattern identifier is one this implementation can generate. | |
| static int | ToBaudRate (LineQualityBaudRate baudRateId) |
| Converts a Baud Rate ID into the baud rate it represents. | |
| static bool | TryGetBaudRateId (int baudRate, out LineQualityBaudRate baudRateId) |
| Converts a baud rate into the Baud Rate ID that represents it. | |
| static int | IterationsPerCombination (TestProfile profile) |
| Returns the number of iterations a profile runs for each pattern and size combination. | |
| static double | DetectionLimitPercent (int packetsSent) |
| Calculates the smallest packet loss rate a run of the given size can rule out, as a percentage, using the rule of three: with no observed failures the 95% upper confidence bound on the loss rate is approximately 3/N. | |
| static TimeSpan | TransmissionTime (int byteCount, int baudRate) |
| Calculates how long a frame occupies the line, used to let a transmission drain before changing the baud rate. | |
Static Public Attributes | |
| const byte | TestAddress = 0x7D |
| The dedicated line quality test address, 125 (0x7D). | |
| const byte | EchoCommandId = 0x01 |
| Command and reply identifier for the echo exchange. | |
| const byte | BaudRateChangeCommandId = 0x02 |
| Command and reply identifier for the baud rate change exchange. | |
| const int | EchoHeaderLength = 7 |
| Number of bytes preceding the test data in an echo request or response: three vendor code bytes, command/reply identifier, sequence number, pattern or status, and length. | |
| const int | MaxPayloadLength = 113 |
| The largest test payload every conforming responder must accept, 113 bytes. | |
Properties | |
| static IReadOnlyList< int > | TestPayloadLengths = new[] { 0, 48, MaxPayloadLength } [get] |
| The payload lengths exercised by the test matrix in section 3.10. | |
| static IReadOnlyList< int > | DefaultBaudRates [get] |
| The six baud rates named by OSDP section 5.2, in ascending order. | |
| static ReadOnlySpan< byte > | VendorCode [get] |
| The reserved line quality vendor code, 02-00-0A. | |
Constants and helpers for the OSDP Line Quality Test Procedure.
The procedure measures RS-485 physical layer quality by bouncing known bit patterns off a responder at a dedicated address and counting what comes back. It rides on osdp_MFG (0x80) and osdp_MFGREP (0x90) with a reserved vendor code, so test traffic coexists with production devices on the same bus without either interfering with the other.
Test traffic is always sent in clear text with CRC-16. A secure channel would encrypt the payload and turn every pattern into statistically identical pseudo-random data.
Definition at line 21 of file LineQualityProtocol.cs.
|
static |
Calculates the smallest packet loss rate a run of the given size can rule out, as a percentage, using the rule of three: with no observed failures the 95% upper confidence bound on the loss rate is approximately 3/N.
| packetsSent | Number of packets sent at a single baud rate. |
This is why a zero-failure result is not the same as a zero loss rate. Reporting the limit alongside a pass keeps the result from being read as a stronger claim than the sample size supports.
|
inlinestatic |
Generates the test data for a pattern.
| pattern | The pattern to generate. |
| length | Number of bytes to generate, 0 to MaxPayloadLength. |
| ArgumentOutOfRangeException | The length is negative or exceeds MaxPayloadLength, or the pattern is not defined. |
Definition at line 107 of file LineQualityProtocol.cs.
References IsSupportedPattern(), and MaxPayloadLength.
|
inlinestatic |
Determines whether the supplied bytes are the reserved line quality vendor code.
| candidate | Bytes to test, normally the first three bytes of an osdp_MFG payload. |
true when the bytes match 02-00-0A.Definition at line 87 of file LineQualityProtocol.cs.
Referenced by OSDP.Net.LineQuality.BaudRateChange.TryParse(), OSDP.Net.LineQuality.BaudRateChangeAck.TryParse(), OSDP.Net.LineQuality.EchoRequest.TryParse(), and OSDP.Net.LineQuality.EchoResponse.TryParse().
|
static |
Determines whether a pattern identifier is one this implementation can generate.
| pattern | The pattern identifier to test. |
true when the pattern is defined by the specification.The underlying type is byte, so an identifier can never be below TestPattern.AllZeros; only the upper bound needs checking.
Referenced by GeneratePattern(), and ValidatePattern().
|
inlinestatic |
Returns the number of iterations a profile runs for each pattern and size combination.
| profile | The profile to look up. |
| ArgumentOutOfRangeException | The profile is not defined. |
Definition at line 202 of file LineQualityProtocol.cs.
|
inlinestatic |
Converts a Baud Rate ID into the baud rate it represents.
| baudRateId | The identifier to convert. |
| ArgumentOutOfRangeException | The identifier is not defined. |
Definition at line 164 of file LineQualityProtocol.cs.
Referenced by OSDP.Net.LineQuality.LineQualityTest.RunAsync().
|
static |
Calculates how long a frame occupies the line, used to let a transmission drain before changing the baud rate.
| byteCount | Number of bytes in the frame. |
| baudRate | The rate the frame was sent at. |
|
inlinestatic |
Converts a baud rate into the Baud Rate ID that represents it.
| baudRate | The baud rate in bits per second. |
| baudRateId | On success, the matching identifier. |
true when the rate has a defined identifier.Definition at line 182 of file LineQualityProtocol.cs.
|
inlinestatic |
Determines whether data matches what the pattern should have produced.
| pattern | The expected pattern. |
| data | The data received back from the responder. |
true when every byte matches the pattern.Definition at line 135 of file LineQualityProtocol.cs.
References IsSupportedPattern().
|
static |
Command and reply identifier for the baud rate change exchange.
Definition at line 43 of file LineQualityProtocol.cs.
Referenced by OSDP.Net.LineQuality.BaudRateChange.BuildData(), OSDP.Net.LineQuality.BaudRateChangeAck.BuildData(), OSDP.Net.LineQuality.BaudRateChange.TryParse(), and OSDP.Net.LineQuality.BaudRateChangeAck.TryParse().
|
static |
Command and reply identifier for the echo exchange.
Definition at line 40 of file LineQualityProtocol.cs.
Referenced by OSDP.Net.LineQuality.EchoRequest.BuildData(), OSDP.Net.LineQuality.EchoResponse.BuildData(), OSDP.Net.LineQuality.EchoRequest.TryParse(), and OSDP.Net.LineQuality.EchoResponse.TryParse().
|
static |
Number of bytes preceding the test data in an echo request or response: three vendor code bytes, command/reply identifier, sequence number, pattern or status, and length.
Definition at line 49 of file LineQualityProtocol.cs.
Referenced by OSDP.Net.LineQuality.EchoRequest.BuildData(), OSDP.Net.LineQuality.EchoResponse.BuildData(), OSDP.Net.LineQuality.EchoRequest.TryParse(), and OSDP.Net.LineQuality.EchoResponse.TryParse().
|
static |
The largest test payload every conforming responder must accept, 113 bytes.
OSDP section 5.6 guarantees only a 128-byte receive buffer. A frame carries 6 header bytes and 2 CRC bytes, leaving 120 bytes of message data, of which EchoHeaderLength are consumed by the line quality header. At this length both the command and its echoed reply are exactly 128 bytes.
Definition at line 60 of file LineQualityProtocol.cs.
Referenced by GeneratePattern().
|
static |
The dedicated line quality test address, 125 (0x7D).
Chosen to sit above the usual production range and below the 0x7F configuration address, while remaining a legal osdp_COMSET assignment target.
Definition at line 37 of file LineQualityProtocol.cs.
|
staticget |
The six baud rates named by OSDP section 5.2, in ascending order.
This is the default set a test sweeps; 460800 is deliberately excluded because it is not an OSDP rate.
Definition at line 74 of file LineQualityProtocol.cs.
Referenced by OSDP.Net.LineQuality.LineQualityTest.RunAsync().
|
staticget |
The payload lengths exercised by the test matrix in section 3.10.
Definition at line 65 of file LineQualityProtocol.cs.
|
staticget |
The reserved line quality vendor code, 02-00-0A.
Definition at line 80 of file LineQualityProtocol.cs.