hparra / ruby-serialport

ruby-serialport is a Ruby library that provides a class for using RS-232 serial ports
http://rubygems.org/gems/serialport
GNU General Public License v2.0
246 stars 58 forks source link

Windows - Can't connect to a Moxa Serial port - Bad file descriptor #37

Open pini-gh opened 12 years ago

pini-gh commented 12 years ago

Hi,

I'm trying to connect to a serial device through a Moxa Board C32065T. The 8 Moxa ports are reported by Windows as COM10 to COM17. My device is on COM13, and accessible from standard serial communication applications such as PortMon.

Using ruby-serialport I initialize the port with (since COM1 is port 0, I guess COM13 should be port 12): SerialPort.new 12, 9600

But the initialization fails with "EBADF: Bad file descriptor".

Is there a way to access the port by its name "COM13"?

Thanks in advance,

_g.

pini-gh commented 12 years ago

Hi again,

Reading the source code, I understand that the port parameter of SerialPort.new() can be either an integer or a string, so it could open a port by name (say "\.\COM13"). But:

SerialPort.new("\.\COM13") TypeError: can't convert String into Integer

Thanks,

_g.

pini-gh commented 12 years ago

It seems it's the same issue as #13: when I force the full path of serialport.rb in my require statement it works.

I've tested: renaming serialport.so to libserialport.so and modifying accordingly the require statement in serialport.rb. Then, "require 'serialport'" produces "cannot load such file -- serialport". I guess that serialport.so was loaded instead of serialport.rd which actually isn't in the search path.

Installing serialport.rb init /lib/ruby// and renaming back serialport.so did the trick.

Hence, the actual issue is relative to the serialport.rb installation path.

Thanks,

_g.