mirror of
https://github.com/DarthAffe/OBD.NET.git
synced 2025-12-12 16:58:30 +00:00
fixes
This commit is contained in:
parent
2ca0e8a899
commit
2b5b56a870
@ -89,6 +89,7 @@ namespace OBD.NET.Devices
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual void SendCommand(ATCommand command)
|
||||
{
|
||||
@ -164,12 +165,11 @@ namespace OBD.NET.Devices
|
||||
if (sendCloseProtocol)
|
||||
{
|
||||
SendCommand(ATCommand.CloseProtocol);
|
||||
//Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
_dataReceivedEventHandlers = null;
|
||||
_dataReceivedEventHandlers.Clear();
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user