Ruby bindinds for libftdi
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
example add support bitbang mode for read/write. Nov 10, 2012
lib Version bump to 0.0.20 (to inform that it now depends on libftdi 0.20 Jun 16, 2013
.gitignore Working lights. Apr 11, 2012
.yardopts
Gemfile
LICENSE
README.md
Rakefile Prepare to release 0.0.1 Apr 11, 2012
libftdi-ruby.gemspec
test.rb

README.md

Description

Ruby bindings for libftdi - an open source library to talk to FTDI chips.

Prerequisites

You must install libftdi version 0.20 in addition to this gem.

Synopsys

require 'rubygems'
require 'ftdi'

ctx = Ftdi::Context.new

begin
  ctx.usb_open(0x0403, 0x6001)
  begin
    ctx.baudrate = 250000
    ctx.set_line_property(:bits_8, :stop_bit_2, :none)
    ctx.flowctrl = Ftdi::SIO_DISABLE_FLOW_CTRL

    arr = Array.new(513) { |i| i.zero? ? 0 : 1 }
    ctx.set_line_property2(:bits_8, :stop_bit_2, :none, :break_on)
    sleep 0.001
    ctx.set_line_property2(:bits_8, :stop_bit_2, :none, :break_off)
    sleep 0.001
    ctx.write_data(arr)

    sleep 1

    arr = [ 0 ] * 513
    ctx.set_line_property2(:bits_8, :stop_bit_2, :none, :break_on)
    sleep 0.001
    ctx.set_line_property2(:bits_8, :stop_bit_2, :none, :break_off)
    sleep 0.001
    ctx.write_data(arr)

    puts "Context is:"
    ctx.members.each { |k| puts "#{k} = #{ctx[k]}" }

  ensure
    ctx.usb_close
  end
rescue Ftdi::Error => e
  $stderr.puts e.to_s
end