CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/serialport/test/miniterm.rb
Views: 11766
1
require "../serialport.so"
2
3
4
if ARGV.size < 4
5
STDERR.print <<EOF
6
Usage: ruby #{$0} num_port bps nbits stopb
7
EOF
8
exit(1)
9
end
10
11
sp = SerialPort.new(ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i, ARGV[3].to_i, SerialPort::NONE)
12
13
open("/dev/tty", "r+") { |tty|
14
tty.sync = true
15
Thread.new {
16
while true do
17
tty.printf("%c", sp.getc)
18
end
19
}
20
while (l = tty.gets) do
21
sp.write(l.sub("\n", "\r"))
22
end
23
}
24
25
sp.close
26
27