ruby-serialport 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +30 -0
- data/LICENSE +339 -0
- data/Manifest +12 -0
- data/README +51 -0
- data/Rakefile +24 -0
- data/examples/miniterm.rb +25 -0
- data/ext/extconf.rb +13 -0
- data/ext/impl/posix_serialport.c +661 -0
- data/ext/impl/win_serialport.c +611 -0
- data/ext/serialport.c +482 -0
- data/ext/serialport.h +64 -0
- data/lib/serialport.rb +44 -0
- data/ruby-serialport.gemspec +35 -0
- metadata +82 -0
data/ext/serialport.h
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
/* Ruby/SerialPort $Id$
|
2
|
+
* Guillaume Pierronnet <moumar@netcourrier.com>
|
3
|
+
* Alan Stern <stern@rowland.harvard.edu>
|
4
|
+
* Daniel E. Shipton <dshipton@redshiptechnologies.com>
|
5
|
+
*
|
6
|
+
* This code is hereby licensed for public consumption under either the
|
7
|
+
* GNU GPL v2 or greater.
|
8
|
+
*
|
9
|
+
* You should have received a copy of the GNU General Public License
|
10
|
+
* along with this program; if not, write to the Free Software
|
11
|
+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
12
|
+
*
|
13
|
+
* For documentation on serial programming, see the excellent:
|
14
|
+
* "Serial Programming Guide for POSIX Operating Systems"
|
15
|
+
* written Michael R. Sweet.
|
16
|
+
* http://www.easysw.com/~mike/serial/
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef _RUBY_SERIAL_PORT_H_
|
20
|
+
#define _RUBY_SERIAL_PORT_H_
|
21
|
+
|
22
|
+
#define RUBY_SERIAL_PORT_VERSION "0.7.0"
|
23
|
+
|
24
|
+
#include <ruby.h> /* ruby inclusion */
|
25
|
+
#include <rubyio.h> /* ruby io inclusion */
|
26
|
+
|
27
|
+
struct modem_params
|
28
|
+
{
|
29
|
+
int data_rate;
|
30
|
+
int data_bits;
|
31
|
+
int stop_bits;
|
32
|
+
int parity;
|
33
|
+
};
|
34
|
+
|
35
|
+
struct line_signals
|
36
|
+
{
|
37
|
+
int rts;
|
38
|
+
int dtr;
|
39
|
+
int cts;
|
40
|
+
int dsr;
|
41
|
+
int dcd;
|
42
|
+
int ri;
|
43
|
+
};
|
44
|
+
|
45
|
+
#define NONE 0
|
46
|
+
#define HARD 1
|
47
|
+
#define SOFT 2
|
48
|
+
|
49
|
+
#if defined(OS_MSWIN) || defined(OS_BCCWIN)
|
50
|
+
#define SPACE SPACEPARITY
|
51
|
+
#define MARK MARKPARITY
|
52
|
+
#define EVEN EVENPARITY
|
53
|
+
#define ODD ODDPARITY
|
54
|
+
#else
|
55
|
+
#define SPACE 0
|
56
|
+
#define MARK 0
|
57
|
+
#define EVEN 1
|
58
|
+
#define ODD 2
|
59
|
+
#endif
|
60
|
+
|
61
|
+
static VALUE sBaud, sDataBits, sStopBits, sParity; /* strings */
|
62
|
+
static VALUE sRts, sDtr, sCts, sDsr, sDcd, sRi;
|
63
|
+
|
64
|
+
#endif
|
data/lib/serialport.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "serialport.so"
|
2
|
+
|
3
|
+
class SerialPort
|
4
|
+
private_class_method(:create)
|
5
|
+
|
6
|
+
# Creates a serial port object.
|
7
|
+
#
|
8
|
+
# <tt>port</tt> may be a port number
|
9
|
+
# or the file name of a defice.
|
10
|
+
# The number is portable; so 0 is mapped to "COM1" on Windows,
|
11
|
+
# "/dev/ttyS0" on Linux, "/dev/cuaa0" on Mac OS X, etc.
|
12
|
+
#
|
13
|
+
# <tt>params</tt> can be used to configure the serial port.
|
14
|
+
# See SerialPort#set_modem_params for details
|
15
|
+
def SerialPort::new(port, *params)
|
16
|
+
sp = create(port)
|
17
|
+
begin
|
18
|
+
sp.set_modem_params(*params)
|
19
|
+
rescue
|
20
|
+
sp.close
|
21
|
+
raise
|
22
|
+
end
|
23
|
+
return sp
|
24
|
+
end
|
25
|
+
|
26
|
+
# This behaves like SerialPort#new, except that you can pass a block
|
27
|
+
# to which the new serial port object will be passed. In this case
|
28
|
+
# the connection is automaticaly closed when the block has finished.
|
29
|
+
def SerialPort::open(port, *params)
|
30
|
+
sp = create(port)
|
31
|
+
begin
|
32
|
+
sp.set_modem_params(*params)
|
33
|
+
if (block_given?)
|
34
|
+
yield sp
|
35
|
+
sp.close
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
rescue
|
39
|
+
sp.close
|
40
|
+
raise
|
41
|
+
end
|
42
|
+
return sp
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ruby-serialport}
|
5
|
+
s.version = "0.7.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Guillaume Pierronnet, Alan Stern, Daniel E. Shipton, Jonas B\303\244hr"]
|
9
|
+
s.date = %q{2009-01-11}
|
10
|
+
s.description = %q{Ruby/SerialPort is a Ruby library that provides a class for using RS-232 serial ports.}
|
11
|
+
s.email = %q{daniel.shipton.oss@gmail.com}
|
12
|
+
s.extensions = ["ext/extconf.rb"]
|
13
|
+
s.extra_rdoc_files = ["ext/serialport.c", "lib/serialport.rb", "README"]
|
14
|
+
s.files = ["ChangeLog", "ext/extconf.rb", "ext/serialport.c", "ext/serialport.h", "ext/impl/posix_serialport.c", "ext/impl/win_serialport.c", "lib/serialport.rb", "LICENSE", "Manifest", "Rakefile", "README", "examples/miniterm.rb", "ruby-serialport.gemspec"]
|
15
|
+
s.has_rdoc = true
|
16
|
+
s.homepage = %q{http://ruby-serialport.rubyforge.org}
|
17
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruby-serialport", "--main", "README"]
|
18
|
+
s.require_paths = ["lib", "ext"]
|
19
|
+
s.rubyforge_project = %q{ruby-serialport}
|
20
|
+
s.rubygems_version = %q{1.3.1}
|
21
|
+
s.summary = %q{Ruby/SerialPort is a Ruby library that provides a class for using RS-232 serial ports.}
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 2
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_development_dependency(%q<echoe>, [">= 0"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
31
|
+
end
|
32
|
+
else
|
33
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-serialport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Guillaume Pierronnet, Alan Stern, Daniel E. Shipton, Jonas B\xC3\xA4hr"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-11 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: echoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Ruby/SerialPort is a Ruby library that provides a class for using RS-232 serial ports.
|
26
|
+
email: daniel.shipton.oss@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions:
|
30
|
+
- ext/extconf.rb
|
31
|
+
extra_rdoc_files:
|
32
|
+
- ext/serialport.c
|
33
|
+
- lib/serialport.rb
|
34
|
+
- README
|
35
|
+
files:
|
36
|
+
- ChangeLog
|
37
|
+
- ext/extconf.rb
|
38
|
+
- ext/serialport.c
|
39
|
+
- ext/serialport.h
|
40
|
+
- ext/impl/posix_serialport.c
|
41
|
+
- ext/impl/win_serialport.c
|
42
|
+
- lib/serialport.rb
|
43
|
+
- LICENSE
|
44
|
+
- Manifest
|
45
|
+
- Rakefile
|
46
|
+
- README
|
47
|
+
- examples/miniterm.rb
|
48
|
+
- ruby-serialport.gemspec
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://ruby-serialport.rubyforge.org
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options:
|
53
|
+
- --line-numbers
|
54
|
+
- --inline-source
|
55
|
+
- --title
|
56
|
+
- Ruby-serialport
|
57
|
+
- --main
|
58
|
+
- README
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
- ext
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project: ruby-serialport
|
77
|
+
rubygems_version: 1.3.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 2
|
80
|
+
summary: Ruby/SerialPort is a Ruby library that provides a class for using RS-232 serial ports.
|
81
|
+
test_files: []
|
82
|
+
|