Closed dakriege closed 5 years ago
Hey, no, if the device is not available you'll only find out by getting the timeout. Just try to reconnect in that case (maybe wait a few seconds in between). The fact that you can't correctly dispose is an issue though. I looked through the code and the only reason I can think of right now is, that the worker is not correctly cancelling if it's currently waiting for a prompt after sending a command.
Could you try if adding a timeout (I think something between 1000-2000ms should be fine) to the _commandFinishedEvent.WaitOne()
call (https://github.com/DarthAffe/OBD.NET/blob/master/OBD.NET/OBD.NET.Common/Devices/SerialDevice.cs#L221) fixes this behavior?
I set the .WaitOne() to 5000.
If I turn the adapter off, the watchdog times out and sets an error
When I turn the adapter back on the adapter can be reinitialized and communication starts again
A shorter timeout values cause normal responses to timeout with the adapter turned on.
Thanks for your help
From: DarthAffe [mailto:notifications@github.com] Sent: Tuesday, August 27, 2019 1:30 PM To: DarthAffe/OBD.NET OBD.NET@noreply.github.com Cc: dakriege dakrieger@ameritech.net; Author author@noreply.github.com Subject: Re: [DarthAffe/OBD.NET] Loss of communication hangs obd.net (#13)
Hey, no, if the device is not available you'll only find out by getting the timeout. Just try to reconnect in that case (maybe wait a few seconds in between). The fact that you can't correctly dispose is an issue though. I looked through the code and the only reason I can think of right now is, that the worker is not correctly cancelling if it's currently waiting for a prompt after sending a command.
Could you try if adding a timeout (I think something between 1000-2000ms should be fine) to the _commandFinishedEvent.WaitOne() call (https://github.com/DarthAffe/OBD.NET/blob/master/OBD.NET/OBD.NET.Common/Devices/SerialDevice.cs#L221) fixes this behavior?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DarthAffe/OBD.NET/issues/13?email_source=notifications&email_token=AGDU3TE2K4AHGCYJGXZYNQDQGVQBFA5CNFSM4IPVCUB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5IQL2Y#issuecomment-525403627 , or mute the thread https://github.com/notifications/unsubscribe-auth/AGDU3THGEF4VSROCV55OADTQGVQBFANCNFSM4IPVCUBQ . https://github.com/notifications/beacon/AGDU3TDYCZ4E2XTMPH5Y74TQGVQBFA5CNFSM4IPVCUB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5IQL2Y.gif
Virus-free. http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient www.avg.com
I've developed a simple OBD scanner to deliver data to HTML5 pages.
I have a watchdog that sends a data request command every sec and expects a reply back within 5 sec. If a reply is not received within 5 sec the scanner is paused so that it will not request any additional data.
If the OBD device is turned off while the scanner is running the watchdog will timeout and pause the scanner.
An attempt to dispose of the obd.net object and the serial connection object hangs on the obd.net.Dispose(). This eventually causes an http request timeout. The dispose never returns.
Nothing is logged in the windows event log or the debugger log.
Any ideas on how to make sure that if a device connection is lost there is means to clean things up.
Since this is service it will continue to try to make a connection with the device.