sterm 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e4bdd6323c4be6d5c976f1f17ec44245affa7b08d96e70174825f39cba1744cc
4
+ data.tar.gz: 7a451ed0c582e8b8ea4f5af4928a5802efc0119446df18d7d6daa068e7682083
5
+ SHA512:
6
+ metadata.gz: 872aabae485fb9f03794c476bfddd2485f19bcdf7656cb728817fa75a4a9c6496122a93898bafa515e346ae4a690763885cefa1dc06e3e6698a589147df96acf
7
+ data.tar.gz: db5115d727cf911d9d77b2d536fbb6e3013d176d4dd40e301868aa874761038d885da86e9974bcf949c9abcafd84f92327e3a6a27ba593675ffd3be8a1b9a4b7
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in sterm.gemspec
6
+ gemspec
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sterm (0.1.0)
5
+ rainbow
6
+ serialport
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ rainbow (3.0.0)
12
+ rake (10.5.0)
13
+ serialport (1.3.1)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ bundler (~> 1.17)
20
+ rake (~> 10.0)
21
+ sterm!
22
+
23
+ BUNDLED WITH
24
+ 1.17.2
@@ -0,0 +1,24 @@
1
+ # SerialTerm
2
+ SerialTerm is a very simple command line tool to output data received from a serial device using the <a href="https://rubygems.org/gems/serialport/versions/1.3.1" target="_blank">serialport</a> gem.
3
+
4
+ ## Installation
5
+ To install, just run:
6
+ $ gem install sterm
7
+
8
+ ## Usage
9
+
10
+ $ sterm DEVICE_PATH [-b BAUD_RATE -d DATA_BITS -s STOP_BITS -e LINE_ENDING]
11
+
12
+ Default baud rate is 115200
13
+ Default data bits is 8
14
+ Default stop bits is 1
15
+
16
+ LINE_ENDING is the **hex** value of the desired terminating string.
17
+ Default line ending is 0d0a (which is "\r\n" in hex).
18
+
19
+ ## Contributing
20
+
21
+ Bug reports and pull requests are welcome on GitHub at https://github.com/guineec/sterm.
22
+
23
+ ## License
24
+ This program is licensed under the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt">GNU GPLv2.0</a> as required by the use of <a href="https://rubygems.org/gems/serialport/versions/1.3.1" target="_blank">serialport</a>.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sterm"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # SerialTerm is a very simple command line tool that outputs data received from a serial device.
4
+ # Copyright (C) 2019 Cian Guinee
5
+
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; either version 2
9
+ # of the License, or (at your option) any later version.
10
+
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
+
20
+ require "sterm"
21
+
22
+ include Sterm
23
+
24
+ trap "SIGINT" do
25
+ puts "\nBye!"
26
+ exit(0)
27
+ end
28
+
29
+ Sterm.sterm(ARGV)
@@ -0,0 +1,104 @@
1
+ # SerialTerm is a very simple command line tool that outputs data received from a serial device.
2
+ # Copyright (C) 2019 Cian Guinee
3
+
4
+ # This program is free software; you can redistribute it and/or
5
+ # modify it under the terms of the GNU General Public License
6
+ # as published by the Free Software Foundation; either version 2
7
+ # of the License, or (at your option) any later version.
8
+
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+
18
+ require "sterm/version"
19
+ require "optparse"
20
+ require "rainbow"
21
+ require "serialport"
22
+
23
+ module Sterm
24
+ class Error < StandardError; end
25
+
26
+ def sterm(arguments)
27
+ # Parse the arguments provided by the user
28
+ opts = {}
29
+ op = OptionParser.new do |options|
30
+ options.banner = %Q{SerialTerm is a very simple command line tool to output data received from a serial device.
31
+ Usage: sterm DEVICE_PATH [options]\nTry starting with `sterm -h` for help\n\n}
32
+
33
+ options.on("-b BAUD_RATE", "--baud-rate", "Baud rate at which the serial device is transmitting (Default: 115200)") do |baud_rate|
34
+ opts[:baud_rate] = baud_rate
35
+ end
36
+
37
+ options.on("-d DATA_BITS", "--data-bits", "Data bits by device (Default: 8") do |data_bits|
38
+ opts[:data_bits] = data_bits
39
+ end
40
+
41
+ options.on("-s STOP_BITS", "--stop-bits", "Stop bits for device (Default: 1)") do |stop_bits|
42
+ opts[:stop_bits] = stop_bits
43
+ end
44
+
45
+ options.on("-e STRING", "--ends-with", "The string (in hex) that terminates each line sent by the device (Default: \"0D0A\" (\\r\\n)") do |ending|
46
+ opts[:ending] = ending
47
+ end
48
+ end
49
+ op.parse!(arguments)
50
+
51
+ # Ensure the device path is given
52
+ device_path = ""
53
+ if ARGV.length < 1
54
+ STDERR.puts Rainbow("ERROR:").red + " No device path specified. Exiting."
55
+ exit(11)
56
+ else
57
+ device_path = ARGV[0]
58
+ end
59
+
60
+ # Set the options
61
+ baud_rate = opts[:baud_rate]
62
+ if baud_rate.nil? || baud_rate.empty?
63
+ baud_rate = 115200
64
+ puts Rainbow("INFO:").aqua + " Using default baud rate of 115200."
65
+ else
66
+ baud_rate = baud_rate.to_i
67
+ end
68
+
69
+ data_bits = opts[:data_bits]
70
+ if data_bits.nil? || data_bits.empty?
71
+ data_bits = 8
72
+ puts Rainbow("INFO:").aqua + " Using default of 8 data bits."
73
+ else
74
+ data_bits = data_bits.to_i
75
+ end
76
+
77
+ stop_bits = opts[:stop_bits]
78
+ if stop_bits.nil? || stop_bits.empty?
79
+ stop_bits = 1
80
+ puts Rainbow("INFO:").aqua + " Using default of 1 stop bit."
81
+ else
82
+ stop_bits = stop_bits.to_i
83
+ end
84
+
85
+ line_end = [opts[:ending]].pack('H*')
86
+ if line_end.nil? || line_end.empty?
87
+ line_end = "\r\n"
88
+ puts Rainbow("INFO:").aqua + " Using default line ending of \"ODOA\" (\\r\\n)."
89
+ end
90
+
91
+ sp = SerialPort.new(device_path, baud_rate, data_bits, stop_bits, SerialPort::NONE)
92
+
93
+ if sp.nil?
94
+ puts Rainbow("ERROR:").red + " Couldn't initialize device at path " + device_path
95
+ exit(12)
96
+ end
97
+
98
+ puts Rainbow("CONNECT: ").green + " Connected to device at " + device_path
99
+
100
+ while (line = sp.readline(line_end))
101
+ puts Rainbow(device_path + ": ").yellow + line.chomp!
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,20 @@
1
+ # SerialTerm is a very simple command line tool that outputs data received from a serial device.
2
+ # Copyright (C) 2019 Cian Guinee
3
+
4
+ # This program is free software; you can redistribute it and/or
5
+ # modify it under the terms of the GNU General Public License
6
+ # as published by the Free Software Foundation; either version 2
7
+ # of the License, or (at your option) any later version.
8
+
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+
18
+ module Sterm
19
+ VERSION = "0.1.0"
20
+ end
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "sterm/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sterm"
8
+ spec.version = Sterm::VERSION
9
+ spec.authors = ["Cian Guinee"]
10
+ spec.email = ["cian.guinee@gmail.com"]
11
+ spec.licenses = ["GPL-2.0"] # As required by the serialport dependency
12
+ spec.summary = %q{Shows data transmitted from a UART device}
13
+ spec.homepage = "https://github.com/guineec/serial-term"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.17"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_dependency "serialport", "~> 1.3.1"
27
+ spec.add_dependency "rainbow", "~> 3.0.0"
28
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sterm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Cian Guinee
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: serialport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rainbow
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ description:
70
+ email:
71
+ - cian.guinee@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - bin/sterm
84
+ - lib/sterm.rb
85
+ - lib/sterm/version.rb
86
+ - sterm.gemspec
87
+ homepage: https://github.com/guineec/serial-term
88
+ licenses:
89
+ - GPL-2.0
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.0.1
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Shows data transmitted from a UART device
110
+ test_files: []