rs_232 2.0.4

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6aaf6574acc291398d3ef899d016f84087d33a4c
4
+ data.tar.gz: 3ddc060515ebdbe1c14a9bb579ff2d40b44da0cc
5
+ SHA512:
6
+ metadata.gz: e64d9a67eaec60bbf1493bf181bf79ec8119551a30a5771fcb6aa58fcd8359f9babc0ef355d1557ed1ee945d6d0c0840adafbdee95bee157547fe3f9dfd28f3c
7
+ data.tar.gz: e191effcf9d48395668d3e3d73b9091553454f20875e21ea837a73e7e82a9eaed05c6fd19fe2911d3bd1fe5b2e000ff03f801a2a16c48f66ea968b2b545a400d
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013, Ingenico Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Rs232
2
+
3
+ Native implementation of the Rs-232 conneciton type
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ruby-rs-232'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ruby-rs-232
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require "rs_232"
23
+
24
+ class Serial
25
+ attr_reader :interface
26
+ include CommPort
27
+
28
+ # == constructor with default params
29
+ # by default port will be configured with:
30
+ #
31
+ # @baud_rate = 115200 # BAUD_115200
32
+ # @data_bits = 8 # DATA_BITS_8
33
+ # @parity = 0 # PAR_NONE
34
+ # @stop_bits = 1 # STOP_1
35
+ # @flow_control = 0 # FLOW_OFF
36
+ #
37
+ #
38
+ def initialize(port)
39
+ @interface ||= Rs232.new(port)
40
+ end
41
+
42
+ #
43
+ # other adapter methods here ...
44
+ #
45
+ # adapter example placed in the lib folder
46
+ #
47
+
48
+ end
49
+
50
+ #== Windows
51
+
52
+ @adapter = Serial.new("COM3")
53
+
54
+ #== Linux
55
+
56
+ @adapter = Serial.new("/dev/tty.usb00000")
57
+
58
+ #== Darwin
59
+
60
+ @adapter = Serial.new("/dev/ttyACM0")
61
+ ```
62
+
63
+
64
+ ## Contributing
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rake'
2
+ require 'bundler/setup'
3
+ require 'bundler/gem_tasks'
4
+
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ $:.unshift(File.dirname(__FILE__) + '/lib')
8
+
9
+ Dir['gem_tasks/**/*.rake'].each { |rake| load rake }
10
+
11
+ require 'bundler/gem_tasks'
12
+ require 'rake/extensiontask'
13
+
14
+ require 'rake/clean'
15
+
16
+ CLEAN.include %w(**/*.{log} doc coverage tmp)
17
+
18
+
19
+ def gem_spec
20
+ @gem_spec ||= Gem::Specification.load('rs_232.gemspec')
21
+ end
22
+
23
+
24
+ Rake::ExtensionTask.new('rs_232', gem_spec) do |ext|
25
+ # stub
26
+ end
27
+
28
+
29
+ desc 'code statistics'
30
+ task :stats do
31
+
32
+ def count(glob)
33
+ Dir[glob].inject(0) do |count, fi|
34
+ next unless File.file?(fi)
35
+ count + File.read(fi).lines.to_a.length
36
+ end
37
+ end
38
+
39
+ rb_lines = count 'lib/**/*.rb'
40
+ c_lines = count 'ext/**/*.{c,cpp,h,hpp}'
41
+
42
+ puts "Lines of Ruby: #{rb_lines}"
43
+ puts "Lines of C*: #{c_lines}"
44
+ end
45
+
46
+
47
+ task :default => [:clean, :compile]
data/bin/env.rb ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler'
3
+ require 'bundler/setup'
4
+ require 'pry'
5
+ require './features/support/env'
6
+
7
+ $stdout.puts 'Rs232 console started...'
8
+
9
+ Pry.start()
data/cucumber.yml ADDED
@@ -0,0 +1,24 @@
1
+ <%
2
+
3
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
4
+ rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format pretty #{rerun}"
5
+ std_opts = "--format pretty features --tags ~@wip --tag ~@wip-new-core -r features --strict"
6
+
7
+
8
+ wip_opts = "--color -r features --tags @wip:3,@wip-new-core"
9
+ wip_opts << ",@wip-jruby:3" if defined?(JRUBY_VERSION)
10
+
11
+ legacy_opts = ''
12
+ legacy_opts << " --tags ~@wire" if defined?(JRUBY_VERSION)
13
+ legacy_opts << " --tags ~@wip-jruby" if defined?(JRUBY_VERSION)
14
+
15
+ %>
16
+
17
+ default: <%= std_opts %> --tags ~@jruby features/.cucumber
18
+ windows_mri: <%= std_opts %> --tags ~@jruby --tags ~@spork --tags ~@wire --tags ~@needs-many-fonts CUCUMBER_FORWARD_SLASH_PATHS=true
19
+
20
+ ruby_1_9: <%= std_opts %> --tags ~@jruby
21
+ ruby_2_0: <%= std_opts %> --tags ~@jruby
22
+ wip: --wip <%= wip_opts %> features
23
+ none: --format pretty
24
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip --tag ~@wip-new-core
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Copyright (c) 2013, Ingenico Inc.
3
+ *
4
+ * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
5
+ * provided that the above copyright notice and this permission notice appear in all copies.
6
+ *
7
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
8
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
10
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
11
+ * PERFORMANCE OF THIS SOFTWARE.
12
+ *
13
+ **/
14
+
15
+
16
+ #include "constants.h"
17
+
18
+ void Constants_Init(VALUE root)
19
+ {
20
+ rb_define_const(root, "VERSION", rb_str_new2(VERSION));
21
+
22
+ rb_define_const(root, "BAUD_110", INT2FIX(BAUD110));
23
+ rb_define_const(root, "BAUD_300", INT2FIX(BAUD300));
24
+ rb_define_const(root, "BAUD_600", INT2FIX(BAUD600));
25
+ rb_define_const(root, "BAUD_1200", INT2FIX(BAUD1200));
26
+ rb_define_const(root, "BAUD_2400", INT2FIX(BAUD2400));
27
+ rb_define_const(root, "BAUD_4800", INT2FIX(BAUD4800));
28
+ rb_define_const(root, "BAUD_9600", INT2FIX(BAUD9600));
29
+ rb_define_const(root, "BAUD_19200", INT2FIX(BAUD19200));
30
+ rb_define_const(root, "BAUD_38400", INT2FIX(BAUD38400));
31
+ rb_define_const(root, "BAUD_57600", INT2FIX(BAUD57600));
32
+ rb_define_const(root, "BAUD_115200", INT2FIX(BAUD115200));
33
+
34
+ rb_define_const(root, "DATA_BITS_5", INT2FIX(DATA_5));
35
+ rb_define_const(root, "DATA_BITS_6", INT2FIX(DATA_6));
36
+ rb_define_const(root, "DATA_BITS_7", INT2FIX(DATA_7));
37
+ rb_define_const(root, "DATA_BITS_8", INT2FIX(DATA_8));
38
+
39
+ rb_define_const(root, "PAR_NONE", INT2FIX(PAR_NONE));
40
+ rb_define_const(root, "PAR_ODD", INT2FIX(PAR_ODD));
41
+ rb_define_const(root, "PAR_EVEN", INT2FIX(PAR_EVEN));
42
+
43
+ rb_define_const(root, "STOP_BITS_1", INT2FIX(STOP_1));
44
+ rb_define_const(root, "STOP_BITS_3", INT2FIX(STOP_2));
45
+
46
+
47
+ rb_define_const(root, "FLOW_OFF", INT2FIX(FLOW_OFF));
48
+ rb_define_const(root, "FLOW_HARDWARE", INT2FIX(FLOW_HARDWARE));
49
+ rb_define_const(root, "FLOW_XONXOFF", INT2FIX(FLOW_XONXOFF));
50
+
51
+ }
@@ -0,0 +1,98 @@
1
+ /*
2
+ * Copyright (c) 2013, Ingenico Inc.
3
+ *
4
+ * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
5
+ * provided that the above copyright notice and this permission notice appear in all copies.
6
+ *
7
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
8
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
10
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
11
+ * PERFORMANCE OF THIS SOFTWARE.
12
+ *
13
+ **/
14
+
15
+ #ifndef constants____FILEEXTENSION___
16
+ #define constants____FILEEXTENSION___
17
+
18
+ #include <ruby.h>
19
+
20
+
21
+ #define VERSION "3.0.0-rc"
22
+
23
+
24
+ #define LS_CTS 0x01
25
+ #define LS_DSR 0x02
26
+ #define LS_DCD 0x04
27
+ #define LS_RI 0x08
28
+ #define LS_RTS 0x10
29
+ #define LS_DTR 0x20
30
+ #define LS_ST 0x40
31
+ #define LS_SR 0x80
32
+
33
+
34
+ enum BaudRateType
35
+ {
36
+ BAUD110 = 110,
37
+ BAUD300 = 300,
38
+ BAUD600 = 600,
39
+ BAUD1200 = 1200,
40
+ BAUD2400 = 2400,
41
+ BAUD4800 = 4800,
42
+ BAUD9600 = 9600,
43
+ BAUD19200 = 19200,
44
+ BAUD38400 = 38400,
45
+ BAUD57600 = 57600,
46
+ BAUD115200 = 115200
47
+
48
+ };
49
+
50
+
51
+ enum DataBitsType
52
+ {
53
+ DATA_5 = 5,
54
+ DATA_6,
55
+ DATA_7,
56
+ DATA_8
57
+ };
58
+
59
+
60
+ enum ParityType
61
+ {
62
+ PAR_NONE,
63
+ PAR_ODD,
64
+ PAR_EVEN,
65
+ };
66
+
67
+
68
+ enum StopBitsType
69
+ {
70
+ STOP_1 = 1,
71
+ STOP_2
72
+ };
73
+
74
+
75
+ enum FlowType
76
+ {
77
+ FLOW_OFF,
78
+ FLOW_HARDWARE,
79
+ FLOW_XONXOFF
80
+ };
81
+
82
+
83
+ enum SettingsFlags
84
+ {
85
+ T_BaudRate = 0x0001,
86
+ T_Parity = 0x0002,
87
+ T_StopBits = 0x0004,
88
+ T_DataBits = 0x0008,
89
+ T_Flow = 0x0010,
90
+ T_TimeOut = 0x0100,
91
+ T_ALL = 0x0fff,
92
+ T_SettingsDone = 0x00ff,
93
+ };
94
+
95
+
96
+ void Constants_Init(VALUE);
97
+
98
+ #endif
@@ -0,0 +1,102 @@
1
+ require 'mkmf'
2
+ require 'rbconfig'
3
+
4
+ if ENV['DEBUG_C']
5
+ $CFLAGS << " -DDEBUG"
6
+ $CFLAGS << " -g -O"
7
+ $stdout.puts "compiling in debug mode... flags: #{$CFLAGS}"
8
+ end
9
+
10
+ def root(path)
11
+ File.expand_path("../#{path}/", __FILE__)
12
+ end
13
+
14
+ dir_config("rs_232")
15
+
16
+ $warnflags = '-Wall'
17
+
18
+ CPU = case RbConfig::CONFIG['host_cpu'].downcase
19
+ when /i[3456]86/
20
+ if RbConfig::CONFIG['host_os'] =~ /darwin/ && 0xfee1deadbeef.is_a?(Fixnum)
21
+ "x86_64"
22
+ else
23
+ "i386"
24
+ end
25
+
26
+ when /amd64|x86_64/
27
+ "x86_64"
28
+
29
+ when /ppc64|powerpc64/
30
+ "powerpc64"
31
+
32
+ when /ppc|powerpc/
33
+ "powerpc"
34
+
35
+ when /^arm/
36
+ "arm"
37
+
38
+ else
39
+ RbConfig::CONFIG['host_cpu']
40
+ end
41
+
42
+ $stdout.puts "Detecting CPU... "
43
+ $stdout.puts "CPU: #{CPU}"
44
+
45
+ OS = case RbConfig::CONFIG['host_os'].downcase
46
+ when /linux/
47
+ "linux"
48
+ when /darwin/
49
+ "darwin"
50
+ when /freebsd/
51
+ "freebsd"
52
+ when /openbsd/
53
+ "openbsd"
54
+ when /sunos|solaris/
55
+ "solaris"
56
+ when /mswin|mingw/
57
+ "windows"
58
+ else
59
+ RbConfig::CONFIG['host_os'].downcase
60
+ end
61
+
62
+ $stdout.puts "Detecting OS... "
63
+ $stdout.puts "OS: #{OS}"
64
+ $stdout.puts
65
+
66
+
67
+ have_header("ruby.h")
68
+ have_header("port.h")
69
+ have_header("stdio.h")
70
+
71
+ if OS == "windows"
72
+ $VPATH << "$(srcdir)/windows"
73
+ $INCFLAGS += " -I$(srcdir)/windows"
74
+ have_header("windows.h")
75
+ have_header("fcntl.h")
76
+ have_header("io.h")
77
+ have_header("ruby/io.h")
78
+ have_header("rubyio.h")
79
+ elsif %w(linux darwin).include? OS
80
+ $VPATH << " $(srcdir)/posix"
81
+ $INCFLAGS += " -I$(srcdir)/posix"
82
+ have_header("termios.h")
83
+ have_header("unistd.h")
84
+ have_header("string.h")
85
+ have_header("fcntl.h")
86
+ have_header("errno.h")
87
+ have_header("sys/ioctl.h")
88
+ else
89
+ raise "RS-233 implementation is not tested for this #{OS} palform."
90
+ end
91
+
92
+ $objs = %w(constants.o port.o initializer.o)
93
+
94
+ $CFLAGS += " -DOS_#{OS.upcase}"
95
+
96
+ $stdout.puts <<-MSG
97
+
98
+ Extending with: #{$CFLAGS}
99
+
100
+ MSG
101
+
102
+ create_makefile('rs_232')