Modbus does not use an extra worker thread.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user