Skip to content
Browse files

Merge git://github.com/hparra/ruby-serialport

  • Loading branch information...
2 parents cfc42a3 + 709e385 commit ffe1298267e08bb4fddf06c04f22a922464c70a7 root committed Nov 8, 2012
Showing with 125 additions and 64 deletions.
  1. +4 −1 .gitignore
  2. +7 −0 CHANGELOG
  3. +11 −0 CHECKLIST
  4. +2 −6 README
  5. +10 −1 Rakefile
  6. +1 −1 VERSION
  7. +0 −1 ext/native/extconf.rb
  8. +53 −8 ext/native/posix_serialport_impl.c
  9. +3 −3 ext/native/serialport.h
  10. +4 −8 ext/native/win_serialport_impl.c
  11. +30 −35 serialport.gemspec
View
5 .gitignore
@@ -1,10 +1,13 @@
.DS_Store
/pkg
/doc
+/tmp
/ext/native/*.bundle
/ext/native/*.log
/ext/native/*.o
/ext/native/*.so
/ext/native/Makefile
.*.swp
-tags
+tags
+*.gem
+*.bundle
View
7 CHANGELOG
@@ -1,3 +1,10 @@
+1.1.0 => 05/14/2012: [NEW] Ruby 2.0 Support [Aaron Patterson (tenderlove)]
+ [FIXED] Support for baud rates up to 1000000 in Windows [Will Koehler (willkoehler)]
+
+1.0.4 => 07/17/2010: [FIXED] [Windows] No longer restricted to specific bitrates
+ [FIXED] [Windows] Removed potentially insecure sprintf() use
+ [FIXED] [Windows] Workaround for rb_sys_fail not checking GetLastError()
+
1.0.3 => 04/08/2010: [FIXED] [Windows] Could not specify 10 or "COM10" or higher
[FIXED] [Windows] Warning passing INT instead of LONG to GetCommModemStatus
View
11 CHECKLIST
@@ -0,0 +1,11 @@
+# Ruby-Serialport Gem Pre-Push Checklist
+
+* rake version:bump
+* Update #define RUBY_SERIAL_PORT_VERSION (serialport.h)
+* Update CHANGELOG
+* Update README if necessary
+* rake install
+* TEST
+* rake release
+* gem update serialport
+* TEST
View
8 README
@@ -10,10 +10,6 @@ The native Windows version of this library supports Microsoft's Visual C++, Borl
-- Installation --
-This gem is hosted at Gemcutter. Before you can install this, or any other Gemcutter gem you must
-add it as a gem source:
- gem sources -a http://gemcutter.org
-
Then you can install the gem as normal:
sudo gem install serialport
@@ -30,7 +26,7 @@ Ruby's copy of miniterm.c !
** Class constants **
- VERSION -> aString (this release is "0.6")
+ VERSION -> aString (EX: this release is "0.6")
NONE, HARD, SOFT, SPACE, MARK, EVEN, ODD -> anInteger
** Class methods **
@@ -46,7 +42,7 @@ Ruby's copy of miniterm.c !
Optional modem_parameters:
- baudrate -> anInteger: from 50 to 256000, depends on platform.
+ baudrate -> anInteger: from 50 to 1000000, depends on platform.
databits -> anInteger: from 5 to 8 (4 is allowed on Windows)
View
11 Rakefile
@@ -1,6 +1,9 @@
require 'rubygems'
require 'rake'
+gem 'rake-compiler', '>= 0.4.1'
+require "rake/extensiontask"
+
begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
@@ -12,6 +15,11 @@ begin
gemspec.authors = ['Guillaume Pierronnet', 'Alan Stern', 'Daniel E. Shipton', 'Tobin Richard', 'Hector Parra', 'Ryan C. Payne']
gemspec.has_rdoc = true
gemspec.extensions << 'ext/native/extconf.rb'
+
+ Rake::ExtensionTask.new "serialport", gemspec do |ext|
+ ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
+ ext.ext_dir = "ext/native"
+ end
end
Jeweler::GemcutterTasks.new
rescue LoadError
@@ -21,4 +29,5 @@ end
task :clean do
rm_rf(Dir['doc'], :verbose => true)
rm_rf(Dir['pkg'], :verbose => true)
-end
+end
+
View
2 VERSION
@@ -1 +1 @@
-1.0.3
+1.1.0
View
1 ext/native/extconf.rb
@@ -5,7 +5,6 @@
os = /-([a-z]+)/.match(RUBY_PLATFORM)[1]
puts(os)
$CFLAGS += " -DOS_#{os.upcase}"
-$CFLAGS += " -DRUBY_1_9" if RUBY_VERSION =~ /^1\.9/
if !(os == 'mswin' or os == 'bccwin' or os == 'mingw')
exit(1) if not have_header("termios.h") or not have_header("unistd.h")
View
61 ext/native/posix_serialport_impl.c
@@ -35,6 +35,25 @@
#undef HAVE_FLOWCONTROL_HARD
#endif
+/* on mac os x, not all baud rates are defined in termios.h but
+ they are mapped to the numeric value anyway, so we define them here */
+#ifdef __APPLE__
+#ifndef B460800
+#define B460800 460800
+#endif
+#ifndef B500000
+#define B500000 500000
+#endif
+#ifndef B576000
+#define B576000 576000
+#endif
+#ifndef B921600
+#define B921600 921600
+#endif
+#ifndef B1000000
+#define B1000000 1000000
+#endif
+#endif
static char sTcgetattr[] = "tcgetattr";
static char sTcsetattr[] = "tcsetattr";
@@ -44,13 +63,13 @@ static char sIoctl[] = "ioctl";
int get_fd_helper(obj)
VALUE obj;
{
-#ifdef RUBY_1_9
+#ifdef HAVE_RUBY_IO_H
rb_io_t *fptr;
#else
OpenFile *fptr;
#endif
GetOpenFile(obj, fptr);
-#ifdef RUBY_1_9
+#ifdef HAVE_RUBY_IO_H
return (fptr->fd);
#else
return (fileno(fptr->f));
@@ -60,7 +79,7 @@ int get_fd_helper(obj)
VALUE sp_create_impl(class, _port)
VALUE class, _port;
{
-#ifdef RUBY_1_9
+#ifdef HAVE_RUBY_IO_H
rb_io_t *fp;
#else
OpenFile *fp;
@@ -107,11 +126,7 @@ VALUE sp_create_impl(class, _port)
case T_STRING:
Check_SafeStr(_port);
-#ifdef RUBY_1_9
port = RSTRING_PTR(_port);
-#else
- port = RSTRING(_port)->ptr;
-#endif
break;
default:
@@ -152,7 +167,7 @@ VALUE sp_create_impl(class, _port)
rb_sys_fail(sTcsetattr);
}
-#ifdef RUBY_1_9
+#ifdef HAVE_RUBY_IO_H
fp->fd = fd;
#else
fp->f = rb_fdopen(fd, "r+");
@@ -233,6 +248,21 @@ VALUE sp_set_modem_params_impl(argc, argv, self)
#ifdef B230400
case 230400: data_rate = B230400; break;
#endif
+#ifdef B460800
+ case 460800: data_rate = B460800; break;
+#endif
+#ifdef B500000
+ case 500000: data_rate = B500000; break;
+#endif
+#ifdef B576000
+ case 576000: data_rate = B576000; break;
+#endif
+#ifdef B921600
+ case 921600: data_rate = B921600; break;
+#endif
+#ifdef B1000000
+ case 1000000: data_rate = B1000000; break;
+#endif
default:
rb_raise(rb_eArgError, "unknown baud rate");
@@ -389,6 +419,21 @@ void get_modem_params_impl(self, mp)
#ifdef B230400
case B230400: mp->data_rate = 230400; break;
#endif
+#ifdef B460800
+ case B460800: mp->data_rate = 460800; break;
+#endif
+#ifdef B500000
+ case B500000: mp->data_rate = 500000; break;
+#endif
+#ifdef B576000
+ case B576000: mp->data_rate = 576000; break;
+#endif
+#ifdef B921600
+ case B921600: mp->data_rate = 921600; break;
+#endif
+#ifdef B1000000
+ case B1000000: mp->data_rate = 1000000; break;
+#endif
}
switch(params.c_cflag & CSIZE)
View
6 ext/native/serialport.h
@@ -21,10 +21,10 @@
#ifndef _RUBY_SERIAL_PORT_H_
#define _RUBY_SERIAL_PORT_H_
-#define RUBY_SERIAL_PORT_VERSION "1.0.3"
+#define RUBY_SERIAL_PORT_VERSION "1.0.4"
#include <ruby.h> /* ruby inclusion */
-#ifdef RUBY_1_9 /* ruby io inclusion */
+#ifdef HAVE_RUBY_IO_H /* ruby io inclusion */
#include <ruby/io.h>
#else
#include <rubyio.h>
@@ -59,7 +59,7 @@ struct line_signals
#define ODD ODDPARITY
#ifndef RB_SERIAL_EXPORT
- #ifndef RUBY_1_9
+ #ifndef HAVE_RUBY_IO_H
#define RB_SERIAL_EXPORT __declspec(dllexport)
#else
#define RB_SERIAL_EXPORT
View
12 ext/native/win_serialport_impl.c
@@ -36,14 +36,14 @@ static char sSetCommTimeouts[] = "SetCommTimeouts";
static HANDLE get_handle_helper(obj)
VALUE obj;
{
-#ifdef RUBY_1_9
+#ifdef HAVE_RUBY_IO_H
rb_io_t *fptr;
#else
OpenFile *fptr;
#endif
GetOpenFile(obj, fptr);
-#ifdef RUBY_1_9
+#ifdef HAVE_RUBY_IO_H
return (HANDLE) _get_osfhandle(fptr->fd);
#else
return (HANDLE) _get_osfhandle(fileno(fptr->f));
@@ -62,7 +62,7 @@ static void _rb_win32_fail(const char *function_call) {
VALUE RB_SERIAL_EXPORT sp_create_impl(class, _port)
VALUE class, _port;
{
-#ifdef RUBY_1_9
+#ifdef HAVE_RUBY_IO_H
rb_io_t *fp;
#else
OpenFile *fp;
@@ -95,11 +95,7 @@ VALUE RB_SERIAL_EXPORT sp_create_impl(class, _port)
case T_STRING:
Check_SafeStr(_port);
-#ifdef RUBY_1_9
str_port = RSTRING_PTR(_port);
-#else
- str_port = RSTRING(_port)->ptr;
-#endif
if (str_port[0] != '\\') /* Check for Win32 Device Namespace prefix "\\.\" */
{
snprintf(port, sizeof(port) - 1, "\\\\.\\%s", str_port);
@@ -155,7 +151,7 @@ VALUE RB_SERIAL_EXPORT sp_create_impl(class, _port)
errno = 0;
fp->mode = FMODE_READWRITE | FMODE_BINMODE | FMODE_SYNC;
-#ifdef RUBY_1_9
+#ifdef HAVE_RUBY_IO_H
fp->fd = fd;
#else
fp->f = fdopen(fd, "rb+");
View
65 serialport.gemspec
@@ -1,57 +1,52 @@
# Generated by jeweler
-# DO NOT EDIT THIS FILE
-# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
- s.name = %q{serialport}
- s.version = "1.0.3"
+ s.name = "serialport"
+ s.version = "1.1.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Guillaume Pierronnet", "Alan Stern", "Daniel E. Shipton", "Tobin Richard", "Hector Parra", "Ryan C. Payne"]
- s.date = %q{2010-04-19}
- s.description = %q{Ruby/SerialPort is a Ruby library that provides a class for using RS-232 serial ports.}
- s.email = %q{hector@hectorparra.com}
- s.extensions = ["ext/native/extconf.rb"]
+ s.date = "2012-05-26"
+ s.description = "Ruby/SerialPort is a Ruby library that provides a class for using RS-232 serial ports."
+ s.email = "hector@hectorparra.com"
+ s.extensions = ["ext/native/extconf.rb", "ext/native/extconf.rb"]
s.extra_rdoc_files = [
"LICENSE",
- "README"
+ "README"
]
s.files = [
- ".gitignore",
- "CHANGELOG",
- "LICENSE",
- "MANIFEST",
- "README",
- "Rakefile",
- "VERSION",
- "ext/native/extconf.rb",
- "ext/native/posix_serialport_impl.c",
- "ext/native/serialport.c",
- "ext/native/serialport.h",
- "ext/native/win_serialport_impl.c",
- "lib/serialport.rb",
- "serialport.gemspec",
- "test/miniterm.rb",
- "test/set_readtimeout.rb"
- ]
- s.homepage = %q{http://github.com/hparra/ruby-serialport/}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{Library for using RS-232 serial ports.}
- s.test_files = [
+ "CHANGELOG",
+ "CHECKLIST",
+ "LICENSE",
+ "MANIFEST",
+ "README",
+ "Rakefile",
+ "VERSION",
+ "ext/native/extconf.rb",
+ "ext/native/posix_serialport_impl.c",
+ "ext/native/serialport.c",
+ "ext/native/serialport.h",
+ "ext/native/win_serialport_impl.c",
+ "lib/serialport.rb",
+ "serialport.gemspec",
"test/miniterm.rb",
- "test/set_readtimeout.rb"
+ "test/set_readtimeout.rb"
]
+ s.homepage = "http://github.com/hparra/ruby-serialport/"
+ s.require_paths = ["lib"]
+ s.rubygems_version = "1.8.24"
+ s.summary = "Library for using RS-232 serial ports."
if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
else
end
else
end
end
+

0 comments on commit ffe1298

Please sign in to comment.
Something went wrong with that request. Please try again.