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