ruby-serialport icon indicating copy to clipboard operation
ruby-serialport copied to clipboard

Does test run?

Open ghost opened this issue 11 years ago • 1 comments

When I run the test, I get the following output:

miniterm.rb:11:in `initialize': wrong number of arguments (5 for 1..2) (ArgumentError)
    from miniterm.rb:11:in `new'
    from miniterm.rb:11:in `<main>'

Does that make sense? It is trying to run:

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

but the new method is looking for 2 args, looking at api docs:

(SerialPort) new(port, *params)

ghost avatar Apr 16 '14 15:04 ghost

I know 5 years old but it seems a simple question that should have been answered

I got the same thing.

try replacing miniterm.rb with...

require "../serialport.so"
require "rubygems"
require "serialport"

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

sp = SerialPort.new(ARGV[0], 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

in lib/serialport type ruby ../../test/miniterm.rb "/dev/ttyACM0" 1200 8 1 or something. That worked for me.

jontio avatar Jul 26 '19 22:07 jontio