sterm 0.1.7 → 0.2.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/lib/sterm.rb +20 -2
- data/lib/sterm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42886aeeeb2e631e038b7f5c6f5d0c7fe4edecb00c27ee273812520f158f3dba
|
4
|
+
data.tar.gz: fbd8d6b460e61a30607c712cf78e0bb930d04ccbe53118ab94b6025f5b508976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b506f75384960314d6861ad643fad19215599e1e90fd691d2b77fc504224568dee46377859ff95f535d58cb245d616b1589a2b04fb885b940f20210032467ab9
|
7
|
+
data.tar.gz: 16f175435fd57734e9d72478a1a33d3919a68d69c1f8447185dff43bbaa84a153e0e874566df50a09017a46119331b16ac732b36a3f1b43e5ca2fe4ed1163796
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# SerialTerm
|
2
|
+
<p align="center">
|
3
|
+
<img width="196" height="150" src="https://files.cians.site/sterm_image.png">
|
4
|
+
</p>
|
2
5
|
SerialTerm is a very simple command line tool to output data received from a serial device. It's built in ruby, and the <a href="https://rubygems.org/gems/serialport/versions/1.3.1" target="_blank">serialport</a> gem does most of the heavy lifting.
|
3
6
|
|
4
7
|
I've only tested this with one device but it should work for anything that uses a serial output. If you find errors/exceptions feel free to report them or fix them and issue a pull request.
|
@@ -24,7 +27,7 @@ Default line ending is 0d0a (which is "\r\n" in hex).
|
|
24
27
|
|
25
28
|
## Contributing
|
26
29
|
|
27
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/guineec/
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/guineec/serial-term.
|
28
31
|
|
29
32
|
## License
|
30
33
|
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>.
|
data/lib/sterm.rb
CHANGED
@@ -47,6 +47,10 @@ Usage: sterm DEVICE_PATH [options]\nTry starting with `sterm -h` for help\n\n}
|
|
47
47
|
opts[:ending] = ending
|
48
48
|
end
|
49
49
|
|
50
|
+
options.on("-n", "--[no-]line-numbers", "Print numbers at the start of each line of output (Default: true)") do |nums|
|
51
|
+
opts[:line_numbers] = nums
|
52
|
+
end
|
53
|
+
|
50
54
|
options.on_tail("-v", "--version", "Show version") do
|
51
55
|
puts Rainbow("SerialTerm version:").aqua + " #{Sterm::VERSION}"
|
52
56
|
exit
|
@@ -94,6 +98,10 @@ Usage: sterm DEVICE_PATH [options]\nTry starting with `sterm -h` for help\n\n}
|
|
94
98
|
puts Rainbow("INFO:").aqua + " Using default line ending of \"ODOA\" (\\r\\n)."
|
95
99
|
end
|
96
100
|
|
101
|
+
if opts[:line_numbers].nil?
|
102
|
+
opts[:line_numbers] = true
|
103
|
+
end
|
104
|
+
|
97
105
|
begin
|
98
106
|
sp = SerialPort.new(device_path, baud_rate, data_bits, stop_bits, SerialPort::NONE)
|
99
107
|
rescue Errno::ENOENT
|
@@ -107,9 +115,19 @@ Usage: sterm DEVICE_PATH [options]\nTry starting with `sterm -h` for help\n\n}
|
|
107
115
|
end
|
108
116
|
|
109
117
|
puts Rainbow("CONNECT: ").green + " Connected to device at " + device_path
|
110
|
-
|
118
|
+
|
119
|
+
line_num = 1
|
111
120
|
while (line = sp.readline(line_end))
|
112
|
-
|
121
|
+
nspaces = (6 - (line_num.to_s.length))
|
122
|
+
nspaces = 1 if nspaces < 1
|
123
|
+
line_num_text = "[#{line_num}]" + (" " * nspaces)
|
124
|
+
|
125
|
+
if opts[:line_numbers]
|
126
|
+
puts line_num_text + Rainbow(device_path + ": ").yellow + line.chomp!
|
127
|
+
line_num += 1
|
128
|
+
else
|
129
|
+
puts Rainbow(device_path + ": ").yellow + line.chomp!
|
130
|
+
end
|
113
131
|
end
|
114
132
|
end
|
115
133
|
end
|
data/lib/sterm/version.rb
CHANGED