File: miniterm.rb

package info (click to toggle)
ruby-serialport 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 172 kB
  • sloc: ansic: 1,441; ruby: 67; makefile: 2
file content (25 lines) | stat: -rwxr-xr-x 428 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require "../serialport.so"


if ARGV.size < 4
  STDERR.print <<EOF
  Usage: ruby #{$0} num_port bps nbits stopb
EOF
  exit(1)
end

sp = SerialPort.new(ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i, ARGV[3].to_i, SerialPort::NONE)

open("/dev/tty", "r+") { |tty|
  tty.sync = true
  Thread.new {
    while true do
      tty.printf("%c", sp.getc)
    end
  }
  while (l = tty.gets) do
    sp.write(l.sub("\n", "\r"))
  end
}

sp.close