Skip to content
Ruby bindinds for libftdi
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
lib
.gitignore
.yardopts
Gemfile
LICENSE
README.md
Rakefile
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
You can’t perform that action at this time.