hybridgroup / rubyserial

FFI Ruby library for RS-232 serial port communication
https://rubygems.org/gems/rubyserial
Other
154 stars 27 forks source link

ERROR_SEM_TIMEOUT (semaphore timeout) when using with Windows 10 and Ruby from RubyInstaller #52

Open synthead opened 1 year ago

synthead commented 1 year ago

Related to https://github.com/synthead/timex_datalink_client/issues/308.

When using Ruby from RubyInstaller running Windows 10, rubyserial raises ERROR_SEM_TIMEOUT (RubySerial::Error) while using an example script with the timex_datalink_client gem. This is a semaphore timeout in Windows that appears to be raised from FFI. This is while using a Teensy LC as a serial device.

Here is the exception:

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 `<main>'

Steps to reproduce:

  1. Have a Windows 10 machine handy with Ruby installed from RubyInstaller.
  2. Install the timex_datalink_client gem at version 0.12.1.
  3. Have a serial device ready. (Note: The timex_datalink_client gem only writes data to the device, so any arbitrary serial device will work. If you want, you can use a Teensy LC and flash it with https://github.com/synthead/timex-datalink-arduino/releases/tag/v1.0.0 if you want an exact reproduction case.)
  4. Copy the complete code example for Timex Datalink protocol 1 to a file, and run it with Ruby.
  5. Observe the error above.
hunterboerner commented 1 year ago

@deadprogram any thoughts?