digital-transport 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e8d508990049e22bc47ebe1904cff7eb02fe744
4
- data.tar.gz: 18eda2ccc77a27e5b22af89dc0c79e940fe98b53
3
+ metadata.gz: 7af58d75f82ffdaf6870b242c530685e6285dc16
4
+ data.tar.gz: cefbffc637bc63cb05eeb4f5c162d5f558322693
5
5
  SHA512:
6
- metadata.gz: 35b6b983aefa5cc4c006ce1852821b4ba3db115be9ab6b581fbadc692bbe909e2bac36b8267168f965abeece9a19e4f13950627c9f51f0d6b7edea6cc4d56f07
7
- data.tar.gz: 4daeb4c8f929557399e230ee6297f51d3cf240595f533e5ff361f75b7cbfd2201967d0784eb45fa5190f0ab1f7306327646c32a53f1d17914a7c07d0afe7e0eb
6
+ metadata.gz: e1c1a80fefe85d91e10e925cf7e3dcf7202a84460513de4295a8f324d0659e7fd4126f57a2d3da797e37796025a06dbd9c02e3e025e061d992c34da5fe9e2e64
7
+ data.tar.gz: da4e1ba232ceabe3ace2fae5f576094e22249189cf9a55b4471fcc2aa8b3895767f1b3f0af1b2930f00054eb57b20ad7607a447004196319ebe13a310976f93b
@@ -6,17 +6,10 @@ module Digital
6
6
  class Serial
7
7
  include Digital::Transport::Errors
8
8
  include Digital::Transport::Adapters::Interface
9
- include CommPort
10
9
  include Functional
10
+ include Rs232
11
11
 
12
- DEFAULTS = {
13
- timeout: 10,
14
- baud_rate: CommPort::BAUD_115200,
15
- data_bits: CommPort::DATA_BITS_8,
16
- parity: CommPort::PAR_NONE,
17
- stop_bits: CommPort::STOP_BITS_1,
18
- flow_control: CommPort::FLOW_OFF
19
- }.freeze
12
+ DEFAULTS = { timeout: 10 }.freeze
20
13
 
21
14
  def initialize(port, opt = {})
22
15
  @port = port.freeze
@@ -31,15 +24,7 @@ module Digital
31
24
  # @see Adapters#new_serial_adapter
32
25
  #
33
26
  def connect
34
- io = Rs232.new(@port)
35
- io.connecting_timeout = @opts[:timeout].to_i if p.respond_to?(:connecting_timeout)
36
- io.open
37
- io.baud_rate = @opts[:baud_rate].to_i
38
- io.data_bits = @opts[:data_bits].to_i
39
- io.parity = @opts[:parity].to_i
40
- io.stop_bits = @opts[:stop_bits].to_i
41
- io.flow_control = @opts[:flow_control].to_i
42
- @io = io
27
+ @io = new_serial_port(@port, @opts).tap(&:connect)
43
28
  Either.right(self)
44
29
  rescue Exception => ex
45
30
  Either.left(ex)
@@ -64,7 +49,7 @@ module Digital
64
49
  end
65
50
 
66
51
  def open?
67
- @io && !@io.closed?
52
+ @io && @io.open?
68
53
  end
69
54
 
70
55
  def read(count, blocking = false)
@@ -84,6 +69,7 @@ module Digital
84
69
  end
85
70
  Either.right(array.empty? ? nil : array.join)
86
71
  rescue => ex
72
+ @io.close
87
73
  Either.left(ex)
88
74
  end
89
75
 
@@ -1,5 +1,5 @@
1
1
  module Digital
2
2
  module Transport
3
- VERSION = '0.8.1'.freeze
3
+ VERSION = '0.8.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digital-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Lishtaba