p1_meter_reader 0.1.0 → 0.1.1

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: 693ff520b5a8edca746d8d30de28e9356211de5a
4
- data.tar.gz: da0761bba90fe81a78ee0d570d8832308d87b8e5
3
+ metadata.gz: a153cd915a9a90ea647a8aa53080a6f2576cc1a9
4
+ data.tar.gz: 5805e34db9eddf3070f0f2762bd11a11c385a497
5
5
  SHA512:
6
- metadata.gz: b4c8fd08dba517c272ca43ac81cd62c8b07e534400a9981567dc9a4af2a9d43c2ba6a8c130018d27bfa23b75a218bcbe7989110a61fff12236703e3eb1229583
7
- data.tar.gz: 29f2cdf026f6f0db23d6493ace1f259b5c0a6e27bc00298d7bc0fd0e7ed58e0f2dc8b65511c6a69492e404d116d62c631997c118c73c3cb98ae9b043df810c6d
6
+ metadata.gz: 0b2ac2f42d78acfa7bdd292b9373f84ffbf4dac860be27f5fb587efa8784b98991f56ab7b190233e2a632e4bd7f28cb341bb7054d2a8c76060131d32abbe7038
7
+ data.tar.gz: 704671bcc2965fbb40cd9bfe229093de69e6aeafe064ce50ff0a7c66e6364ef1ec48c4800cf850c42a2adaab390041343bafe678b54d4de55661e4d451f30e13
@@ -1,9 +1,11 @@
1
+ require 'serialport'
2
+
1
3
  module P1MeterReader
2
4
  module DataParsing
3
5
  class StreamSplitter
4
- def initialize(stream, message_start)
6
+ def initialize(message_start, input: serial_port)
5
7
  @message_start = message_start
6
- @stream = stream.each_line
8
+ @stream = input.each_line
7
9
  end
8
10
 
9
11
  def read
@@ -20,6 +22,17 @@ module P1MeterReader
20
22
  return result if line.strip == "!"
21
23
  end
22
24
  end
25
+
26
+ private
27
+ def serial_port
28
+ serial_port = SerialPort.new("/dev/ttyUSB0", 9600)
29
+ serial_port.data_bits = 7
30
+ serial_port.stop_bits = 1
31
+ serial_port.parity = SerialPort::EVEN
32
+
33
+ serial_port
34
+ end
23
35
  end
24
36
  end
25
37
  end
38
+
@@ -1,3 +1,3 @@
1
1
  module P1MeterReader
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_dependency "serialport"
26
+ spec.add_runtime_dependency "serialport", "1.3.1"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 1.8"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p1_meter_reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lennaert Meijvogel
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: serialport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.3.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.3.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement