serialclient 0.1 → 0.2

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/bin/serialclient +15 -7
  3. metadata +6 -6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1
1
+ 0.2
data/bin/serialclient CHANGED
@@ -9,14 +9,21 @@ require 'micro-optparse'
9
9
  options = Parser.new do |p|
10
10
  p.banner = "Serial terminal client"
11
11
  p.option :port, "path to serial device, ex: /dev/ttyUSB0", :default => ""
12
- p.option :speed, "speed in baups", :default => 115200
12
+ p.option :speed, "speed in baups", :default => 115200 , :value_satisfies => lambda {|x| x >= 50 && x <= 256000}
13
+ p.option :data_bits, "data bits for modem params [5..8] on Unix [4..8] on Windows", :default => 8, :value_satisfies => lambda {|x| x >= 4 && x <= 8 }
14
+ p.option :stop_bits, "data bits for modem params", :default => 1, :value_in_set => [1, 2]
15
+ p.option :parity, "parity: NONE/EVEN/ODD/[MARK/SPACE] [Windows only]", :default => "NONE", :value_in_set => ["NONE", "EVEN", "ODD", "MARK", "SPACE"]
13
16
  end.process!
14
17
 
15
18
  class Serial_client < Rink::Console
16
19
  option :allow_ruby => false
17
20
 
18
- def initialize (port_, baup_)
21
+ def initialize (port_, baup_, data_bits_, stop_bits_, parity_)
19
22
  @sp = SerialPort.new port_, baup_
23
+ @sp.set_modem_params( { "data_bits" => data_bits_,
24
+ "stop_bits" => stop_bits_,
25
+ "parity" => parity_ }
26
+ )
20
27
  @read_th = Thread.new {
21
28
  while 1 do
22
29
  puts @sp.gets
@@ -32,13 +39,14 @@ class Serial_client < Rink::Console
32
39
 
33
40
  end
34
41
 
35
- Signal.trap('TERM') do
36
- Process.exit 0
42
+ Signal.trap('TERM') do
43
+ puts "\n"
44
+ Process.exit 0
37
45
  end
38
46
 
39
47
  Signal.trap('INT') do
40
- Process.exit 0
48
+ puts "\n"
49
+ Process.exit 0
41
50
  end
42
51
 
43
-
44
- Serial_client.new(options[:port], options[:speed])
52
+ Serial_client.new(options[:port], options[:speed].to_i, options[:data_bits], options[:stop_bits], SerialPort.const_get(options[:parity]))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serialclient
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-03 00:00:00.000000000 Z
12
+ date: 2012-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: serialport
16
- requirement: &84725230 !ruby/object:Gem::Requirement
16
+ requirement: &73421800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *84725230
24
+ version_requirements: *73421800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rink
27
- requirement: &84724820 !ruby/object:Gem::Requirement
27
+ requirement: &73421570 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *84724820
35
+ version_requirements: *73421570
36
36
  description: ! ' Need a terminal to communicate to a serial device like Hyperterminal,
37
37
  this gem has been done for you !
38
38