LegacyNsfw/PcmHacks

Don't store port choice until after a successful operation

LegacyNsfw opened this issue · 1 comments

Right now the app stores the device type and serial port name as soon as the user closes the device-picker dialog box.

Something about ObdLink and/or Windows has corrupted ObdLink LX serial ports at the OS level, so the app hangs if you pick one. Then you kill the app and restart it, and it hangs again because it tries to use the same broken serial port.

After selecting a port, or closing the dialog box, the app should try to do a simple operation, like an OSID query, and only store the settings if the operation succeeds. That way if the serial port hangs the process, the app will restart with the old configuration (no config, or a working configuration) so the user can try a different port after they kill it and restart it.

Picture of just how broken things are when the app gets hung by a broken serial port:

image

I suspect this is the same issue.

When selecting a valid com port that has no device attached PCM Hammer freezes!
It throws, returns false, yet continues to try, thus freezes ...

A log selecting COM1, a valid port with no device!

[01:13:29:402]  PCM Hammer 019
[01:13:29:412]  ElmDevice initialization starting.
[01:13:29:424]  TX: 
[01:13:30:633]  TX: AT Z
[01:13:31:838]  
[01:13:31:838]  TX: AT E0
[01:13:33:043]  
[01:13:33:043]  TX: AT S0
[01:13:34:245]  
[01:13:34:245]  TX: AT RV
[01:13:35:446]  Voltage: 
[01:13:35:447]  TX: AT I
[01:13:36:651]  Elm ID: 
[01:13:36:655]  Initializing PcmHacking.AllProDeviceImplementation
[01:13:36:656]  TX: AT #1
[01:13:36:657]  Unable to initialize ObdLink or AllPro on COM1
[01:13:36:747]  System.TimeoutException: Vehicle.ResetConnection timed out.
   at PcmHacking.MainFormBase.<InitializeCurrentDevice>d__23.MoveNext() in C:\GitHub\PcmHacks\Apps\PcmLibraryWindowsForms\MainFormBase.cs:line 178
[01:13:37:954]  All Pro ID: 
[01:13:37:955]  TX: AT #3
[01:13:39:156]  All Pro self test result: 
[01:13:39:157]  TX: AT @1
[01:13:40:358]  All Pro firmware: 
[01:13:40:361]  TX: AT AL
[01:13:41:562]  Did not recieve expected response.  does not equal OK

The only connection this has to storing of the port is when it does crash and you have to kill the app it leaves the bad port configured in settings and upon re-opening the app it tries to use that bad port again ... now the user is stuck until they delete the settings.

edit:
IMO there is a step missing in ElmDeviceImplementation.Initialise().
It does,
AT Z
AT E0
AT S0
AT RV
AT I
Without ever checking AT Z for a valid response!