Ruby-serialport doesn’t play well with RubyGems. Trying to require 'serialport' when using RubyGems results in:
NameError: (eval):1:in `private_class_method': undefined method `create' for class `Class'
from (eval):1
from (eval):1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from (irb):2The quick fix to get around this is by doing:
Kernel::require 'serialport'
It would be nicer if we could avoid the conflict with RubyGems. It would be even nicer if the serialport library was itself packaged as a gem. Turns out this has been done by aaronp but it doesn’t take advantage of GitHub’s automatic gem builder and doesn’t build correctly using GCC.
I’ve cloned and tidied the git repository. This gem version should build the needed native extension and work on both POSIX compatible and Windows operating systems.
Installing the serialport gem
If you haven’t configured GitHub as a gem source yet you will need to run the following command:
gem sources -a http://gems.github.com
Then, you can install the gem as normal:
sudo gem install toholio-serialport
Unlike the official ruby-serialport extension, this gem works with RubyGems (duh!). When you want to use it you should only need to do the following:
require 'rubygems' require 'serialport'
On a side note: git and GitHub rock. Forking, contributing to and merging projects should be this simple.
One Comment
Tried going through at least 3 different packages of this serialport library compiling each one. The original serialport package works great on osx…not so much on windows. It will work on windows, but only if the serial port is initialized via hypercom to begin with ( won’t set settings correctly ? )
When I try git’ing your branch, I get this error.
git clone git://github.com/toholio/ruby-serialport.git
Initialize ruby-serialport/.git
Initialized empty Git repository in
remote: error: object directory /data/git/repositories/4/cc/ff/56/aaronp/ruby-serialport.git/objects does not exist; check .git/objects/remote: info/alternates.
remote: Total 0 (delta 0), reused 0 (delta 0)
remote: aborting due to possible repository corruption on the remote side.
error: waitpid (async) failed
fatal: error in sideband demultiplexer
Post a Comment