Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does test run? #51

Open
ghost opened this issue Apr 16, 2014 · 1 comment
Open

Does test run? #51

ghost opened this issue Apr 16, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 16, 2014

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)

@jontio
Copy link

jontio commented Jul 26, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant