deej icon indicating copy to clipboard operation
deej copied to clipboard

If deej starts too fast on windows startup it sometimes fails to detect sliders

Open prueker opened this issue 3 years ago • 13 comments

My PC boots quick and about half of the time, the application starts before it can detect the sliders and I have to manually close/restart deej so it detects them.

Maybe a check to see if sliders were detected could be added and if they were not, put in a retry-loop to try for 5 times every x seconds to prevent this? image

prueker avatar Nov 26 '20 16:11 prueker

Hi @prueker, thanks for writing.

I'd like to understand this problem a bit more in-depth in order to help you. The logs you attached are suggesting that deej connects successfully, and that it'll handle the next line read from serial as the baseline for the number of sliders (what you're calling "detecting sliders").

So to clarify - which of these most accurately describes what you're running into?

  1. deej appears to connect but doesn't actually read lines (and thus doesn't respond to slider movements) - but stays running (this shouldn't happen)
  2. deej starts, fails to connect, notifies you, and stays running (also shouldn't happen)
  3. deej fails to connect (e.g. because serial isn't available yet), notifies you and quits (should happen)

On a related note, I do plan to add more robust connection handling (including reconnection attempts where appropriate), but there isn't a specific time frame for this yet. As a workaround until then, adding a 20 to 30 second sleep in your startup script launching deej might be an acceptable solution.

omriharel avatar Nov 26 '20 20:11 omriharel

It's the number 1 case. deej starts, it says the "connected" line (which is the last line in the log until I close deej and restart it, as shown in the screenshot above), but not the "Detected sliders" line until I close deej and restart it, upon which it works immediately.

So I have the feeling that deej connects to the COM port, but the arduino might not have booted fully yet and isn't sending lines and so it somehow blocks it?

prueker avatar Nov 26 '20 20:11 prueker

Definitely sounds like something of that sort - I concur that some sort of retrying logic is the right call here. I'll likely do this in a small hotfix (and not as part of a more holistic improvement around connection stability), to solve this specific instance of it. If it's alright with you, I'll keep you updated here when it's ready. Thanks again for the report!

omriharel avatar Nov 26 '20 22:11 omriharel

Sounds good, I'll be happy to test it.

prueker avatar Nov 26 '20 22:11 prueker

Hijacking this a bit (similar, but not the same issue): when the pc goes in hibernation and then comes out of it, the connection with the arduino is gone. A restart of deej solves this. I guess this would be fixed when you implement that more robust connection handling?

Nickxsch avatar Feb 10 '21 10:02 Nickxsch

Hey @Nickxsch, sorry about the delay in responding. Yes, this would be fixed together with those changes. I still don't have an ETA for this, unfortunately. I hope that in the meantime continuing to restart deej isn't a huge hassle, and I will update here when a fix is implemented. Thanks!

omriharel avatar Feb 25 '21 09:02 omriharel

@omriharel not a problem at all. I know this isn't a commercial product with a full time dev team behind it 🙂 Just wanted to join in this discussion to maybe add some useful info. It'll be fixed when it's fixed. If I could, I would put in some effort myself, but I lack the skill of coding properly 😁

Nickxsch avatar Feb 25 '21 10:02 Nickxsch

I hacky workaround that I've been using involves AutoHotKey. A "script" that launches at start up will first wait 20 seconds, then open deej.exe (if it isn't already open).

Here is the script I'm using

Sleep 20000 ; Sleep for 20 seconds
Process, Exist, deej.exe ; Check if the process exists
If (ErrorLevel = 0) ; If it is not running
	{
	Run, C:\Users\jackr\Downloads\deej.exe ; open the process
	
	}
Else ; If it is running, ErrorLevel equals the process id for the target program (Printkey). Then close it.
	{
	; do nothing
	}

Modify the path and sleep time to fit your needs. The Config.yaml will need to be in the same location as the script.

Compile the script by right clicking on it and selecting compile script. This will produce an .exe file that can be placed in the startup folder. (make sure the config.yaml is also with this new "launch script" and NOT with deej.exe. )

JackPikatea avatar Feb 25 '21 14:02 JackPikatea

I just tossed the above PR up to solve the serial connections. It basically just closes the channels, drops out of the go routine, and restarts the serial if it loses connection. If it fails to connect, it will try again and then exponentially back off until it reaches a 100 second wait period at which point it just continues one try per 100 seconds.

marcuswu avatar Mar 28 '21 18:03 marcuswu

Marcus, you brilliant man, thanks!

Nickxsch avatar Mar 28 '21 19:03 Nickxsch

Updating here for posterity - the changes in #32 do the job but I currently have separate plans to fix this as part of a connection stability pass planned for the near future. I invite you to read my comment on the PR here for additional context.

I'll be sure to update this issue when this is released. Thank you!

omriharel avatar Jun 26 '21 23:06 omriharel

Was this ever solved? it's been a few years and i think i'm having the same issue

orbitinstasis avatar Mar 08 '24 14:03 orbitinstasis

Also getting this issue having recently built a device. Deej detects with no com port error but i have to restart deej and re insert the arduino then it works fine.

BeepBoopindie avatar Mar 31 '24 14:03 BeepBoopindie