Giter VIP home page Giter VIP logo

farmbot-serial's Introduction

STOP! You might not need this.

farmbot-serial is a component used by the Farmbot Raspberry Pi. If you are just trying to install a FarmBot, you do not need to use this. This component will be auto installed when you install the Raspberry Pi Controller.

If you are a developer looking to work directly with the FarmBot serial interface, you're in the right place.

Farmbot-Serial

A ruby gem for controlling Farmbot via serial line with EventMachine.

Usage

As an Interactive Console or Debugger

  git clone https://github.com/FarmBot/farmbot-serial.git
  cd farmbot-serial
  ruby console.rb

From there, you can type commands, such as:

move_relative x: 100

All REPL commands will be executed within the context of bot.commands.

As an Application

gem install farmbot-serial, '0.0.5'

require 'eventmachine'
require 'farmbot-serial'

bot = FB::Arduino.new # Defaults to '/dev/ttyACM0', can be configured.

EM.run do
  FB::ArduinoEventMachine.connect(bot)

  # Example 1: Writing to the serial line the "correct way" every 1.5 seconds.
  EventMachine::PeriodicTimer.new(1.5) do
    bot.commands.move_relative(x: 100, y: 50)
  end

  # Example 2: Writing raw gcode object to serial every 2.5
  EventMachine::PeriodicTimer.new(2.5) { bot.write FB::Gcode.new("F31 P8") }

  # This will execute after status has been updated / internal code.
  bot.onmessage { |gcode| puts "Message just came in." }

  # Try pulling the USB cable out to test this one.
  bot.onclose { puts "bye!"; EM.stop }
end

Upgrading to Ruby 2.2

This gem requires Ruby 2.2. As of this writing, a Pi is loaded with 1.9.3 by default.

To upgrade your ruby version, try this:

 curl -L https://get.rvm.io | bash -s stable --ruby

This will take about 2 hours on a standard pi.

farmbot-serial's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.