add failing stentofon tests

This commit is contained in:
Martijn Scheepers
2021-06-04 12:15:52 +02:00
parent eb303a6ca2
commit a308bb4876
5 changed files with 76 additions and 3 deletions

Binary file not shown.

View File

@@ -12,7 +12,6 @@ namespace UCS.Stentofon.UnitTest
[TestClass]
public class ACDP_Test
{
[TestMethod]
public void Reserved_Range_Message_Test()
{
@@ -51,6 +50,59 @@ namespace UCS.Stentofon.UnitTest
}
//Error from Aalsterweg intercom
//RX 014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00"?128 Inrit poort"=B0
//2021-06-03 06:30:10.0786|ERROR| - Checksum error - 014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00"?128 Inrit poort"=B0
//2021-06-03 06:30:10.0786|ERROR| - Message deserialize error - 014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00"?128 Inrit poort"=B0
//2021-06-03 06:30:10.0942|DEBUG| - RX 014101FF21004164EB004B07E50603061E0A3201102F1D2496000100021D2443010A00963201128F00"?128 Inrit poort"=81
//2021-06-03 06:30:10.1098|ERROR| - Checksum error - 014101FF21004164EB004B07E50603061E0A3201102F1D2496000100021D2443010A00963201128F00"?128 Inrit poort"=81
//2021-06-03 06:30:10.1098|ERROR| - Message deserialize error - 014101FF21004164EB004B07E50603061E0A3201102F1D2496000100021D2443010A00963201128F00"?128 Inrit poort"=81
//2021-06-03 06:33:14.8057|ERROR| - Checksum error - 014101FF21004164F7004B07E5060306210F3201101F1D2596000100021D2543010A00963201122F00"?122 Achteringan"=65
//2021-06-03 06:33:14.8057|ERROR| - Message deserialize error - 014101FF21004164F7004B07E5060306210F3201101F1D2596000100021D2543010A00963201122F00"?122 Achteringan"=65
//2021-06-03 06:33:14.8213|DEBUG| - RX 014101FF21004164F8004B07E5060306210F3201102F1D2596000100021D2543010A00963201122F00"?122 Achteringan"=5A
//2021-06-03 06:33:14.8213|ERROR| - Checksum error - 014101FF21004164F8004B07E5060306210F3201102F1D2596000100021D2543010A00963201122F00"?122 Achteringan"=5A
//2021-06-03 06:33:14.8213|ERROR| - Message deserialize error - 014101FF21004164F8004B07E5060306210F3201102F1D2596000100021D2543010A00963201122F00"?122 Achteringan"=5A
[TestMethod]
public void Message_From_Aasterweg_Test()
{
//2021-06-03 06:30:10.0786|ERROR| - Checksum error - 014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00"?128 Inrit poort"=B0
//2021-06-03 06:30:10.0786|ERROR| - Message deserialize error - 014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00"?128 Inrit poort"=B0
String msg = "014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00\"?128 Inrit poort\"=B0";
ACDP acdp = new ACDP();
int idx = acdp.Deserialize(ref msg);
//error when deserializing
Assert.AreEqual(-1, idx);
//no change to data
Assert.AreEqual("014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00\"?128 Inrit poort\"=B0", msg);
//Network Header
Assert.AreEqual((uint)1, acdp.SourceNode.Value);
Assert.AreEqual((uint)200, acdp.SourceDevice.Value);
Assert.AreEqual((uint)1, acdp.DestinationNode.Value);
Assert.AreEqual((uint)1, acdp.DestinationDevice.Value);
Assert.AreEqual((uint)1, acdp.HopCounter);
Assert.AreEqual((uint)0, acdp.OptionSize);
//Application header
Assert.AreEqual('A', (char)acdp.MessageClass.Value);
Assert.AreEqual((ushort)137, acdp.MessageReference.Value);
Assert.AreEqual((ushort)0x0000, acdp.MessageId.Value);
StringBuilder log = new StringBuilder();
acdp.ToLogString(ref log);
Assert.AreEqual("SrcNode=1 SrcDev=200 DstNode=1 DstDev=1 OptionSize=0 HopCnt=1 MsgClass=65 MsgRef=137", log.ToString());
//wrong message
Assert.AreEqual("01C80101014100890000=00", acdp.Serialize());
}
}
}

View File

@@ -30,6 +30,13 @@ namespace UCS.Stentofon.UnitTest
[DataRow("014101FF2100410399004C07E504010F2A2F3201111F197E000100000000=BE", (byte)0xBE)]
[DataRow("014101FF21004103AE004B07E504010F2B0E3201699F197F50000B000CD76E43000400A1430000000000\"StFout 123 \"=02", (byte)0x02)]
[DataRow("014101FF210041038A004B07E504010F2A293201112F197D9700010002197D43010A00973201122F00\"122 Personlsngng\"=84", (byte)0x84)]
//Aalsterweg centrale
[DataRow("014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00\"?128 Inrit poort\"=B0", (byte)0xB0)]
[DataRow("014101FF21004164EB004B07E50603061E0A3201102F1D2496000100021D2443010A00963201128F00\"?128 Inrit poort\"=81", (byte)0x81)]
[DataRow("014101FF21004164F7004B07E5060306210F3201101F1D2596000100021D2543010A00963201122F00\"?122 Achteringan\"=65", (byte)0x65)]
[DataRow("014101FF21004164F8004B07E5060306210F3201102F1D2596000100021D2543010A00963201122F00\"?122 Achteringan\"=5A", (byte)0x5A)]
public void Verify_Checksum_Test(string msg, byte chksum)
{
Assert.AreEqual(chksum, ACDPChecksum.CalcCheckSum(ref msg));
@@ -55,6 +62,13 @@ namespace UCS.Stentofon.UnitTest
[DataRow("014101FF2100410399004C07E504010F2A2F3201111F197E000100000000", (byte)0xBE)]
[DataRow("014101FF21004103AE004B07E504010F2B0E3201699F197F50000B000CD76E43000400A1430000000000\"StFout 123 \"", (byte)0x02)]
[DataRow("014101FF210041038A004B07E504010F2A293201112F197D9700010002197D43010A00973201122F00\"122 Personlsngng\"", (byte)0x84)]
//Aalsterweg centrale
[DataRow("014101FF21004164EA004B07E50603061E0A3201101F1D2496000100021D2443010A00963201128F00\"?128 Inrit poort\"", (byte)0xB0)]
[DataRow("014101FF21004164EB004B07E50603061E0A3201102F1D2496000100021D2443010A00963201128F00\"?128 Inrit poort\"", (byte)0x81)]
[DataRow("014101FF21004164F7004B07E5060306210F3201101F1D2596000100021D2543010A00963201122F00\"?122 Achteringan\"", (byte)0x65)]
[DataRow("014101FF21004164F8004B07E5060306210F3201102F1D2596000100021D2543010A00963201122F00\"?122 Achteringan\"", (byte)0x5A)]
public void Generate_Checksum_Test(string msg, byte chksum)
{
Assert.AreEqual(chksum, ACDPChecksum.CalcCheckSum(ref msg));

View File

@@ -6,6 +6,13 @@ using System.Threading.Tasks;
namespace UCS.Stentofon
{
//https://wiki.zenitel.com/wiki/Stentofon_Simple_Link_Layer
//HHHHHH...HH”tttt”=SS<CR><LF>
//“ and = are syntax delimiters in the format.
//<SS> is the 8-bit checksum of the original binary network layer message represented as 2 hex digits. The checksum is an ISO-1155 (bytewise XOR) checksum.
//If the trailing text parameter(s) contains any “ or control characters, the leading bytes of the text will be hex-coded instead up to and including the last “ or control character (as if the trailing text parameter(s) started there instead).
//What is considered trailing text parameter(s) is the same as for the ISO-1745-based link layers(Using the internal “Encoding Hint”).
public static class ACDPChecksum
{
private static byte CalcCheckSum(ref byte[] bytes)

View File

@@ -233,7 +233,7 @@ namespace UCS.Stentofon
private static void ConnectionTimerEvent(Object source, System.Timers.ElapsedEventArgs e)
{
ConnectCentral();
Errorlog.Error($"Connection lost with central {_stentofonConfigFile.CentralAddress}");
Errorlog.Error($"Connection lost with central {_stentofonConfigFile.CentralAddress}:{_stentofonConfigFile.CentralPort}");
}
private static void RestartConnectionTimer()