Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77cabfd712 | ||
|
|
c933e2d759 | ||
|
|
f3f0a46627 | ||
|
|
b5fb4c2947 | ||
|
|
f6cce9df3c |
@@ -311,6 +311,9 @@ namespace Common
|
||||
(userName.Equals("jan") && password.Equals("jaugust")) ||
|
||||
(userName.Equals("JCermak") && password.Equals("Zt6911")) ||
|
||||
(userName.Equals("gilles") && password.Equals("alibaba")) ||
|
||||
#if DEBUG
|
||||
(userName.Equals("Sensus Developers") && password.Equals("5fbg12gf5hn8nhy1fr")) ||
|
||||
#endif
|
||||
(userName.Equals(passwordOfDay) && password.Equals(passwordOfDay));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using NfcC7_DLL.NfcHanler.Utils;
|
||||
|
||||
namespace NfcC7_DLL.Tests.NfcHanler.Utils;
|
||||
|
||||
[TestClass]
|
||||
//[TestClass]
|
||||
[TestSubject(typeof(SERIAL_Driver))]
|
||||
public class SERIAL_DriverTest
|
||||
{
|
||||
@@ -22,15 +22,15 @@ public class SERIAL_DriverTest
|
||||
}
|
||||
|
||||
private readonly byte[] Open =
|
||||
{ 107 ,128 ,1 ,16 ,0 ,48 ,0 ,71 ,108 ,111 ,98 ,97 ,108 ,73 ,80 ,101 ,114
|
||||
,108 ,85 ,116 ,105 ,108 ,105 ,116 ,121 ,0 ,0 ,39 ,215 };
|
||||
{ 0x6B, 0x80, 0x01, 0x10, 0x00, 0x30, 0x00, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x49, 0x50, 0x65, 0x72,
|
||||
0x6C, 0x55, 0x74, 0x69, 0x6C, 0x69, 0x74, 0x79, 0x00, 0x00, 0x27, 0xD7 };
|
||||
private readonly byte[] CommDeviceSessionEnd = { 0x6B, 0x61, 0x00, 0x10, 0x05, 0x31, 0x00, 0x1F, 0x29, 0xF9, 0xC5 };
|
||||
|
||||
private readonly byte[] ProductDetails =
|
||||
{ 107, 48, 1, 16, 3, 33, 1, 2, 107, 144, 0, 0, 17, 64, 5, 0, 2, 4, 96, 98, 66, 4, 165, 100 };
|
||||
{ 0x6B, 0x30, 0x01, 0x10, 0x03, 0x21, 0x01, 0x02, 0x6B, 0x90, 0x00, 0x00, 0x11, 0x40, 0x05, 0x00, 0x02, 0x04, 0x60, 0x62, 0x42, 0x04, 0xA5, 0x64 };
|
||||
|
||||
private readonly byte[] ProductDetails2 =
|
||||
{ 107, 48, 1, 16, 3, 33, 1, 2, 107, 144, 0, 0, 17, 64, 5, 0, 2, 4, 96 };
|
||||
{ 0x6B, 0x30, 0x01, 0x10, 0x03, 0x21, 0x01, 0x02, 0x6B, 0x90, 0x00, 0x00, 0x11, 0x40, 0x05, 0x00, 0x02, 0x04, 0x60 };
|
||||
|
||||
static Con con5 = new Con(){
|
||||
com = "COM5",
|
||||
@@ -54,10 +54,10 @@ public class SERIAL_DriverTest
|
||||
|
||||
|
||||
|
||||
[TestMethod]
|
||||
//[TestMethod]
|
||||
public void SendMessage_Test()
|
||||
{
|
||||
Con con = con6;
|
||||
Con con = con5;
|
||||
|
||||
byte[] message = Open;
|
||||
byte[] bytesReceived;
|
||||
@@ -75,13 +75,36 @@ public class SERIAL_DriverTest
|
||||
driver.SendMessage(message, message.Length);
|
||||
//Assert.IsTrue(driver.GetRawData().Length == 0);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
//Assert.IsTrue(bytesReceived.Length > 0);
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
string response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
if (bytesReceived != null)
|
||||
{
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
string response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}", response);
|
||||
}
|
||||
|
||||
// --- Get Serial No ---
|
||||
message = ProductDetails;
|
||||
// Send Open message
|
||||
bool sendSuccess = driver.SendMessage(message, message.Length);
|
||||
Assert.IsTrue(sendSuccess, "Failed to send Open message");
|
||||
Console.WriteLine("Sent message for product details: {0}", message.ToString());
|
||||
bytesReceived = driver.GetRawData();
|
||||
// Display raw bytes (as hex or byte count)
|
||||
if (bytesReceived != null)
|
||||
{
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
string response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}", response);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Response not received!");
|
||||
}
|
||||
|
||||
message = CommDeviceSessionEnd;
|
||||
driver.SendMessage(message, message.Length);
|
||||
@@ -91,7 +114,7 @@ public class SERIAL_DriverTest
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
//[TestMethod]
|
||||
public void SendMessage_TestLoop()
|
||||
{
|
||||
Con con = con6;
|
||||
@@ -132,7 +155,7 @@ public class SERIAL_DriverTest
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
//[TestMethod]
|
||||
public void SendMessage_TestGetSerialNo()
|
||||
{
|
||||
Con con = con6;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public static class ProcessExtensions
|
||||
{
|
||||
public static Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (process == null) throw new ArgumentNullException(nameof(process));
|
||||
if (process.HasExited) return Task.CompletedTask;
|
||||
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
EventHandler handler = null;
|
||||
handler = (s, e) =>
|
||||
{
|
||||
try { tcs.TrySetResult(null); }
|
||||
finally { process.Exited -= handler; }
|
||||
};
|
||||
|
||||
process.EnableRaisingEvents = true;
|
||||
process.Exited += handler;
|
||||
|
||||
if (cancellationToken.CanBeCanceled)
|
||||
{
|
||||
cancellationToken.Register(() =>
|
||||
{
|
||||
tcs.TrySetCanceled(cancellationToken);
|
||||
process.Exited -= handler;
|
||||
});
|
||||
}
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
|
||||
{
|
||||
public static class ProcessExtensions
|
||||
{
|
||||
public static Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (process == null) throw new ArgumentNullException(nameof(process));
|
||||
if (process.HasExited) return Task.CompletedTask;
|
||||
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
EventHandler handler = null;
|
||||
handler = (s, e) =>
|
||||
{
|
||||
try { tcs.TrySetResult(null); }
|
||||
finally { process.Exited -= handler; }
|
||||
};
|
||||
|
||||
process.EnableRaisingEvents = true;
|
||||
process.Exited += handler;
|
||||
|
||||
if (cancellationToken.CanBeCanceled)
|
||||
{
|
||||
cancellationToken.Register(() =>
|
||||
{
|
||||
tcs.TrySetCanceled(cancellationToken);
|
||||
process.Exited -= handler;
|
||||
});
|
||||
}
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1308,6 +1308,7 @@
|
||||
<Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\PoseidonCfg.cs" />
|
||||
<Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\PoseidonProcParams.cs" />
|
||||
<Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\PoseidonReader.cs" />
|
||||
<Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\ProcessExtensions.cs" />
|
||||
<Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\ScopedLoggerFactory.cs" />
|
||||
<Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\SerialPortData.cs" />
|
||||
<Compile Include="Rig\RegisterReaders\PoseidonReader\communication\CalibrationStruct.cs" />
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace TBF.UI.Shared
|
||||
{
|
||||
Localize();
|
||||
#if DEBUG
|
||||
userNameTextBox.Text = "milan";
|
||||
passwordTextBox.Text = "kraken";
|
||||
userNameTextBox.Text = "Sensus Developers";
|
||||
passwordTextBox.Text = "5fbg12gf5hn8nhy1fr";
|
||||
#endif
|
||||
Array.Sort(Program.LocalSettings.TestBenches);
|
||||
for (int i = 0; i < Program.LocalSettings.BenchesCount; i++)
|
||||
|
||||
Reference in New Issue
Block a user