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

Enhancement Request: Allow for easier opening of COMx (x>=10) on Windows #22

Closed
swabianeagle opened this issue Jan 20, 2015 · 6 comments

Comments

@swabianeagle
Copy link

I'm using rubyserial 0.2.1.

Currently, when using rubyserial on Windows I get the following results when opening a serial port:

irb(main):001:0> require 'rubyserial'
=> true
irb(main):002:0> ser1=Serial.new("COM8")
=> #<Serial:0x000000024ecc88 @fd=#<FFI::Pointer address=0x00000000000098>, @open=true>
irb(main):003:0> ser2=Serial.new("COM17")
RubySerial::Exception: ERROR_FILE_NOT_FOUND
        from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/rubyserial-0.2.1/lib/rubyserial/windows.rb:10:in `initialize'
        from (irb):3:in `new'
        from (irb):3
        from C:/Ruby21-x64/bin/irb:11:in `<main>'
irb(main):004:0> ser2=Serial.new("\\\\.\\COM17")
=> #<Serial:0x0000000329a448 @fd=#<FFI::Pointer address=0x0000000000009c>, @open=true>

Arguably it is my mistake that opening COM17 fails the first time, but it seems asymmetric to me that it works with COM8.

I added the following line to windows.rb and this seems to work:
added this to Serial#initialize (windows.rb, line 5)
address = "\\\\.\\#{address}" # needed for com-ports >= COM10

Now the behavior is symmetric:

irb(main):001:0> require 'rubyserial'
=> true
irb(main):002:0> ser1=Serial.new( "COM8" )
=> #<Serial:0x00000002dd7640 @fd=#<FFI::Pointer address=0x00000000000098>, @open=true>
irb(main):003:0> ser2=Serial.new( "COM17" )
=> #<Serial:0x0000000341a2f0 @fd=#<FFI::Pointer address=0x0000000000009c>, @open=true>

Adding the prefix multiple times doesn't seem to matter (I've tried it), so it should be safe to blindly add the prefix by default as I did.

Maybe this could be added in the next release.

@zankich
Copy link
Contributor

zankich commented Jan 20, 2015

@swabianeagle good catch, I would accept a pull request from you with this change, if you'd be so kind!

@swabianeagle
Copy link
Author

Hi Adrian,

sorry for my ignorance as I don't know git very well. What exactly do I have to
do to create a pull request.

Armin

On January 20, 2015 at 2:50 PM Adrian Zankich notifications@github.com
wrote:

@swabianeagle good catch, I would accept a pull request from you with this
change, if you'd be so kind!


Reply to this email directly or view it on GitHub:
#22 (comment)

@zankich
Copy link
Contributor

zankich commented Jan 20, 2015

First you'll want to fork this repo, https://help.github.com/articles/fork-a-repo/, and make the appropriate changes in your fork of rubyserial. Once you have your changes in place, you will see a pull request button, which is a green square with two arrows pointing towards each other. Hit that button and you're good to go! Here's github's help docs too about pull requests https://help.github.com/articles/using-pull-requests/#initiating-the-pull-request

zankich added a commit that referenced this issue Jan 29, 2015
Changes to windows.rb addressing issues #17 and #22
@f3rno
Copy link

f3rno commented May 24, 2015

Can you please tag a new release with this fix? It's a fairly serious problem on windows systems. Also, keeping the issue open is sure to cause some confusion, given that the issue is fixed in master (but not in the latest release).

@deadprogram
Copy link
Member

Ulp! You are right, let me see if we can fix that today.

@deadprogram
Copy link
Member

I just released version 0.2.3 please make sure this corrects your issue, and reopen if not. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants