Modbus does not use an extra worker thread.

This commit is contained in:
Milan Hanajik
2016-10-07 11:55:44 +02:00
parent e8748bab70
commit 45c64ae44b
@@ -62,9 +62,9 @@ namespace TBF.BenchControl.Modbus.Common
serialPort.Handshake = modbusCommonCfg.Handshake;
serialPort.Open();
stopWorkerThread = false;
workerThread = new Thread(Worker);
workerThread.Start();
//stopWorkerThread = false;
//workerThread = new Thread(Worker);
//workerThread.Start();
log.FatalFormat("Successfully initialized device {0}", ToString());
}
@@ -107,7 +107,16 @@ namespace TBF.BenchControl.Modbus.Common
/// <summary>Run this device</summary>
public void RunDeviceBefore()
{
}
int nrBytes = serialPort.BytesToRead;
if (nrBytes > 0)
{
char[] buffer = new char[nrBytes];
serialPort.Read(buffer, 0, nrBytes);
string s = Telegram.LogTelegram("Received: ", new string(buffer));
/// ODO: Add handler
//OnQuidoReceived(this, new QuidoReceivedEventArgs(s));
}
}
/// <summary>Run this device</summary>
public void RunDeviceAfter()
@@ -119,8 +128,8 @@ namespace TBF.BenchControl.Modbus.Common
{
if (serialPort != null)
{
stopWorkerThread = true;
workerThread.Join(2000);
//stopWorkerThread = true;
//workerThread.Join(2000);
serialPort.Close();
}
}