This commit is contained in:
Roman Lumetsberger committed 2017-05-08 21:36:03 +02:00
1 parent 2ca0e8a899
commit 2b5b56a870
2 files changed
+15 -14

No files matched your search

+2 -2
View File
@@ -90,6 +90,7 @@ namespace OBD.NET.Devices
}
}
public virtual void SendCommand(ATCommand command)
{
SendCommand(command.Command);
@@ -164,12 +165,11 @@ namespace OBD.NET.Devices
if (sendCloseProtocol)
{
SendCommand(ATCommand.CloseProtocol);
//Thread.Sleep(500);
}
}
catch { }
_dataReceivedEventHandlers = null;
_dataReceivedEventHandlers.Clear();
base.Dispose();
}
+13 -12
View File
@@ -203,21 +203,22 @@ namespace OBD.NET.Devices
while (!commandCancellationToken.IsCancellationRequested)
{
string command = null;
commandQueue.TryTake(out command, Timeout.Infinite, commandCancellationToken.Token);
Logger?.WriteLine("Writing Command: '" + command.Replace('\r', '\'') + "'", OBDLogLevel.Verbose);
if (Connection.IsAsync)
if(commandQueue.TryTake(out command, Timeout.Infinite, commandCancellationToken.Token))
{
await Connection.WriteAsync(Encoding.ASCII.GetBytes(command));
}
else
{
Connection.Write(Encoding.ASCII.GetBytes(command));
Logger?.WriteLine("Writing Command: '" + command.Replace('\r', '\'') + "'", OBDLogLevel.Verbose);
}
//wait for command to finish
commandFinishedEvent.WaitOne();
if (Connection.IsAsync)
{
await Connection.WriteAsync(Encoding.ASCII.GetBytes(command));
}
else
{
Connection.Write(Encoding.ASCII.GetBytes(command));
}
//wait for command to finish
commandFinishedEvent.WaitOne();
}
}
}