Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR_SEM_TIMEOUT when running sample code #308

Closed
MuddledBox opened this issue Jul 25, 2023 · 10 comments · Fixed by #313
Closed

ERROR_SEM_TIMEOUT when running sample code #308

MuddledBox opened this issue Jul 25, 2023 · 10 comments · Fixed by #313
Assignees
Labels
bug Something isn't working windows Specific to running on native Windows

Comments

@MuddledBox
Copy link

To reproduce my issues...

I run following the sample code, located here:

https://github.com/synthead/timex_datalink_client/blob/main/docs/timex_datalink_protocol_1.md

When using the following with the Pico with the below u2f:

https://github.com/synthead/timex-datalink-arduino/releases/tag/v1.0.0

I get:

78 55 C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rubyserial-0.6.0/lib/rubyserial/windows.rb:73:in write': ERROR_SEM_TIMEOUT (RubySerial::Error) from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:35:in block (2 levels) in write'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:32:in each' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:32:in block in write'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:31:in each' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:31:in write'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client.rb:113:in write' from ./timexTest.rb:132:in

'

OR

when using the the following with the same Pico with the below u2f:

https://github.com/famiclone6502/DIY_Datalink_Adapter/tree/main/pico

I get:

78 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rubyserial-0.6.0/lib/rubyserial/windows.rb:73:in write': ERROR_SEM_TIMEOUT (RubySerial::Error) from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:35:in block (2 levels) in write'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:32:in each' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:32:in block in write'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:31:in each' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client/notebook_adapter.rb:31:in write'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timex_datalink_client-0.12.1/lib/timex_datalink_client.rb:113:in write' from ./timexTest.rb:132:in

'


Running on Windows 11. There is no blinking on my Raspberry Pi Pico's inbuilt LED during either run. If I unplug the Pico and run, I just get "ERROR_FILE_NOT_FOUND". Both the above errors are consistent in length each time the application is run. Any ideas? Outdated gems?

@MuddledBox
Copy link
Author

Note: I changed the following in the example code:
serial_device: "\\.\COM3",

Which is the location of my device.

@synthead
Copy link
Owner

Oh interesting! I haven't tried this in Windows myself, but I have helped others get it working with WSL! Let's see if we can narrow down the issue. I don't have a Windows 11 machine, but I could see if it's reproducible with Windows 10.

I see C:/Ruby32-x64 in your exceptions. How did you install Ruby?

It also looks like you're calling ./timexTest.rb! Could you share this script?

@synthead synthead self-assigned this Jul 27, 2023
@synthead synthead added the bug Something isn't working label Jul 27, 2023
@synthead
Copy link
Owner

Here's where the error you're seeing is defined:

https://github.com/hybridgroup/rubyserial/blob/090df6685f383497e9080a354b22af07731ece40/lib/rubyserial/windows_constants.rb#L198

Here's where the error from rubyserial is being raised:

https://github.com/hybridgroup/rubyserial/blob/090df6685f383497e9080a354b22af07731ece40/lib/rubyserial/windows.rb#L73

I did a little research, and found that C:/Ruby32-x64 is a path that is used by RubyInstaller (GitHub repo here).

@synthead
Copy link
Owner

I was able to reproduce it!

image

I'll take a look and see what it'll take to get this fixed, thanks!

@synthead
Copy link
Owner

I'm seeing what I can find, and also filed a bug upstream:

This appears to be a bug with rubyserial somehow. The timex_datalink_client lib uses serial in a super basic manner:

  • It connects to the Notebook Adapter at 9600 baud with 8 data bits, no parity, and one stop bit (the rubyserial defaults)
  • There are generous sleep calls between writes, which should make data transfer even less troublesome
  • There are no serial read calls; timex_datalink_client simply writes data to a device (and slowly at that)

@synthead
Copy link
Owner

After some testing, I found that swapping the rubyserial gem with serialport works great in Windows (while also working great in Linux):

image

I'll get a PR up to change upstream gems and fix this issue 👍

@synthead
Copy link
Owner

synthead commented Jul 27, 2023

I believe this problem has been fixed with this PR!

To make it publicly available, I also just shipped timex_datalink_client v0.12.2!

To update timex_datalink_client on your installation, do:

gem update timex_datalink_client

This should produce output similar to:

$ gem update timex_datalink_client
Updating installed gems
Updating timex_datalink_client
Successfully installed timex_datalink_client-0.12.2
Parsing documentation for timex_datalink_client-0.12.2
Installing ri documentation for timex_datalink_client-0.12.2
Done installing documentation for timex_datalink_client after 0 seconds
Parsing documentation for timex_datalink_client-0.12.2
Done installing documentation for timex_datalink_client after 0 seconds
Gems updated: timex_datalink_client

I'd also flash the Pico uf2 file for timex-datalink-arduino to your Pico one more time to ensure that you're using a known good Notebook Adapter emulator:

Then, unplug and reinsert your Notebook Adapter to clear Windows of any lingering semaphore issues from rubyserial, and give it another shot! Since I could reproduce it verbatim and fix the issue, I felt confident enough to simply ship a new patch version of this gem. I think it'll work great 🙂

I'll leave this issue open for a few days just to make sure it works for you 👍

@synthead synthead added the windows Specific to running on native Windows label Jul 27, 2023
@MuddledBox
Copy link
Author

MuddledBox commented Jul 27, 2023

@synthead My "notebook adapter" is known working in emulated systems like Windows 98 SE, and I can confirm with the you the fix you implemented works for me in Windows 11. No updates besides updating to the newest version! Syncs with watch and everything.

@synthead
Copy link
Owner

Excellent! I'm really glad it works for you now! Thank you for filing this bug! Enjoy!

@synthead
Copy link
Owner

Upgraded timex_datalink_client in timex_datalink_crt, too:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows Specific to running on native Windows
Projects
None yet
2 participants