c - Wrong gem being required with require 'serialport' -


i've moved original question bottom no longer relavent problem.

i unable locate serialport.so able require this:

$ rvmree@global $ irb > require 'serialport.so' => true 

(gem list returns emtpy)

update:

require 'serialport' 

when executed in irb session, both requires return true when uninstall gem. so, appears gem being required via "require 'serialport'". i've searched system other versions of gem without result.

how can ensure correct gem being required?

update:

[removed list of gems]

when uninstall gems in rvm global namespace, can still require 'serialport' , true.

now output of gem list empty , require 'serialport' still returns true within irb.

i'm using rvm, i've emptied global gems, , gems in gemset i'm using. there no system gems name containing 'serialport', i've searched files included in gem directory such serialport.o, serialport.so , didn't find anything.

i'm @ loss possibly responding require 'serialport'

require 'serialport.so' 

also returns true and

sudo find / -name 'serialport.so' -print 

doesn't return anything.

any ideas?

original post:

i'm using serialport (1.0.4) gem.

documentation found @ http://rubydoc.info/gems/serialport/1.0.4/

here implementation.rb:

require 'rubygems' require 'serialport' port_str = "/dev/cu.usbserial" # serialport mount point baud_rate = 9600 data_bits = 8 stop_bits = 1 parity = 0  sp = serialport.new(port_str, data_bits, stop_bits, baud_rate, parity)  while barcode = sp.gets   puts barcode end  sp.close 


when running ruby implementation.rb, get:

implementation.rb:14:in `initialize': wrong number of arguments (5 2) (argumenterror) implementation.rb:14:in `open' implementation.rb:14 

this weird there doesn't appear initialize method anywhere (maybe ruby internally naming serialport::new initialize?).

the ruby part of gem looks like:

require 'serialport.so'  class serialport    private_class_method(:create)     # creates serial port object.    #    # <tt>port</tt> may port number    # or file name of defice.    # number portable; 0 mapped "com1" on windows,    # "/dev/ttys0" on linux, "/dev/cuaa0" on mac os x, etc.    #    # <tt>params</tt> can used configure serial port.    # see serialport#set_modem_params details    def serialport::new(port, *params)       sp = create(port)       begin          sp.set_modem_params(*params) # calls c extension       rescue          sp.close          raise       end       return sp    end   # serialport::open removed same thing new() block end 

this working other day , can't think of of changed.

i same error ruby-serialport gem (0.7.0) appears same quick glance @ both sources.

a sample implementation found @ http://www.sfc.wide.ad.jp/~mitsuya/4u/ruby-serialport-macosx.html

the latter gem (ruby-serialport) found @ http://rubyforge.org/projects/ruby-serialport/ (documentation @ http://ruby-serialport.rubyforge.org/)

any ideas? thanks.

looking @ $load_path within irb, started searching through them serialport related.

before long, found ~/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/i686-darwin10.6.0/serialport.bundle. after deleting it, tried require 'serialport' , got expected loaderror: no such file load -- serialport had uninstalled serialport gem debugging problem.

after gem install serialport, code works again expected.

had been thinking clearly, have done in first place , avoided headache. hope helps similar problem debug more quickly.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -