Sha256: a1cbe837a67969eb2b2e53d14fe30d5dbde0ad05672b1cdb6e4a32ea91482699
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
module Artoo module Commands class Arduino < Artoo::Commands::Firmata package_name "arduino" desc "scan", "Scan for connected arduino devices" def scan Artoo::Commands::Scan.new().serial() end desc "connect [NAME] [PORT]", "Connect a serial device to a TCP socket using socat" option :retries, :aliases => "-r", :default => 0, :desc => "Number of times to retry connecting on failure" option :baudrate, :aliases => "-b", :default => 57600, :desc => "Baud rate to use to connect to the serial device" def connect(name, port) Artoo::Commands::Socket.new().connect(name, port, options[:retries], options[:baudrate]) end end end end # We need to register the commands in the main artoo CLI so they # can be picked up when this command file is required. # The steps needed to register new CLI commands from outside # artoo are: # 1. External command files (not in artoo main gem) need to be copied to the # artoo installed commands. # 2. We do this with a rake task that is triggered when the gem is installed # (see .gemspec file and look for extensions, ext/Rakefile), in the Rakefile # we defined a new default class that makes use of an artoo helper class/method # Artoo::Commands::Install helper method '.command'; see ext/Rakefile for details. # 3. Finally in our main command file (THIS FILE) we open the artoo CLI::Root class to register # the new commands. module CLI class Root desc "arduino SUBCOMMAND <serial_port>", "Installs avrdude, uploads firmata to the arduino and connects serial to socket" subcommand "arduino", Artoo::Commands::Arduino end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
artoo-arduino-1.4.2 | lib/artoo/commands/arduino.rb |