Git Product home page Git Product logo

wiringpi-ruby-legacy's Introduction

This version of WiringPi-Ruby is EOL, Please see: https://github.com/WiringPi/WiringPi-Ruby

WiringPi: An implementation of most of the Arduino Wiring
	functions for the Raspberry Pi

WiringPiGem: The WiringPi library wrapped up for Ruby with some OO goodness, sanity checking and other handy additions.

WiringPi GPIO:

    require 'wiringpi'
    io = WiringPi::GPIO.new
    io.write(pin,value)
    io.read(pin,value)

    Shift out:

    io.write(latch_pin, LOW)
    io.shiftOut(data_pin, clock_pin, LSBFIRST or MSBFIRST, value)
    io.write(latch_pin, HIGH)

    Shift out an array of 1/0s (always uses LSBFIRST):

    io.shiftOutArray(data_pin, clock_pin, latch_pin, [0,1,0,0,1,1,1,0])

WiringPi GPIO with /sys/class/gpio:

    require 'wiringpi
    io = WiringPi::GPIO.new(WPI_MODE_SYS)
    # read/write/shift as usual

WiringPi Serial:

require 'wiringpi'
    s = WiringPi::Serial.new('/dev/ttyAMA0',9600)
    s.serialPuts('Hello world!')
    s.serialClose

Full details at:
	https://projects.drogon.net/raspberry-pi/wiringpi/

wiringpi-ruby-legacy's People

Contributors

computerlyrik avatar gadgetoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wiringpi-ruby-legacy's Issues

Does not build on Raspbian Ruby 1.9.1

Problems compiling native extensions on Raspbian. Detail currently unknown. Should roll a Raspbian SD and attempt to fix.

Requires Ruby-dev, also? Or fails with /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf

"cannot load such file -- wiringpi/wiringpi" in ruby 2.0

2.0.0-p0 :001 > require 'wiringpi'
LoadError: cannot load such file -- wiringpi/wiringpi
    from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /home/pi/.rvm/gems/ruby-2.0.0-p0/gems/wiringpi-1.1.0/lib/wiringpi.rb:1:in `<top (required)>'
    from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
    from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
    from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
    from (irb):1
    from /home/pi/.rvm/rubies/ruby-2.0.0-p0/bin/irb:16:in `<main>'

missing serialFlush wrapper

Hi, I noticed the method #serialFlush is missing from the ruby library, it seems to me that the wrapper for the underlying C method is as well (but C and C lib wrapping is something completely obscure to me as far as now).
Is there any ruby way to flush the data coming from the serial?

Thanks for help
Andrea

'Undefined symbol' at runtime (ArchLinux)

Hi,

Got a small issue when installing WiringPi-Ruby, all compilation and gem installation went well (except the include path to the WiringPi headers were wrong (?)).
But when I tried running it I got 'Undefined symbol' for wiringPiSetup, after checking with nm,
none of the WiringPi functions were "linked" inside the .so.
But all this seems "normal" as neither the Makefile nor any other files have anything related to libwiringpi.a;
which makes me think that I've done something wrong...

I ended up modifying the Makefile created by ruby :/ to explicitly link to libwiringpi..
Looks like everything works now, but I still feel like something is wrong :/

Thanks for your work !

Support revision 2 board / newer wiringpi library?

There's an update to the wiringpi library that auto-detects the revision of raspberry pi and adapts the pin number mappings to take into account the changed pinout of the header. Any plan to upgrade? I just looked at what it might take to do a pullup request, but I'm not familiar enough with swig and the ruby to c interface to do it with confidence...

this is a question related to WiringPi::Spi.new

I have implemented a small pure-ruby-library(150 lines) for spi-access.

usage:

require "wiringpi/spi"
spi = WiringPi::Spi.new("/dev/spidev0.0",speed: 1000000)
result = spi.dataRW([1,2,3,0,4],delay: 100,bytedelay: 10)
spi.close

The lib requires the package ruby-1.9x and ruby-ffi, both is available in rapbian wheezy

Do you think its worth to integrate it into this project?

con:

  • no c-wrapper -> maybe less performant
  • the interface is more OO and is different to wiringPi -> is this a pro?
    -...

pro:

  • pure ruby, easy to extend (even in live system)
  • no dependency to wiringPi
  • the current features of the c-winrinPi-spi was not enough for my use case
    -...

By the way, the same arguments also count for any other functionality of wiringPi ;-))

SPI support?

Am i doing somehting wrong? or is this just a bug?

irb(main):007:0> require 'wiringpi2'
=> false
irb(main):008:0> s = WiringPi::SPI.new(0,500000)
NameError: uninitialized constant WiringPi::SPI::Wiringpi
        from /var/lib/gems/1.9.1/gems/wiringpi2-2.0.1/lib/wiringpi/spi.rb:6:in `initialize'
        from (irb):8:in `new'
        from (irb):8
        from /usr/bin/irb:12:in `<main>'
irb(main):009:0>

/wiringpi.so: undefined symbol: digitalRead

LoadError: /root/.gem/ruby/2.0.0/gems/wiringpi-1.1.0/lib/wiringpi/wiringpi.so: undefined symbol: digitalRead - /root/.gem/ruby/2.0.0/gems/wiringpi-1.1.0/lib/wiringpi/wiringpi.so
from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in require' from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:inrequire'
from /root/.gem/ruby/2.0.0/gems/wiringpi-1.1.0/lib/wiringpi.rb:1:in <top (required)>' from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:inrequire'
from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in rescue in require' from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:35:inrequire'
from (irb):1
from /usr/bin/irb:12:in `

'

cannot load such file -- wiringpi (LoadError) with RubyDev installed

When running the following Ruby file as root:

#!/usr/bin/env ruby

require 'wiringpi'
io = WiringPi::GPIO.new(WPI_MODE_GPIO)
pin = 18
range = (15..255).to_a
range += range.reverse

def sleep_func(i)
  sleep(0.004) if (i > 150)
  sleep(0.005) if (i > 125) &&  (i < 151)
  sleep(0.007) if (i > 100) &&  (i < 126)
  sleep(0.010) if (i > 75)  &&  (i < 101)
  sleep(0.014) if (i > 50)  &&  (i < 76)
  sleep(0.018) if (i > 25)  &&  (i < 51)
  sleep(0.019) if (i > 1)   &&  (i < 26)
end

loop do 
  range.each do |i|
    io.pwmWrite pin, ((i/255.0) * 1000).to_i
    sleep_func i
  end

  sleep 1
end

I get this error:

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in 'require': cannot load such file -- wiringpi
(LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in 'require' 
from ./pulse.rb:3:in '{main}' 

The squiggly brackets are <>. The markdown didn't like them, hehe.

I read Gadgetoid's issue and dutifully installed ruby-dev, but the same error still occurs.
Not sure if it's bad coding, bad installing or something else. I'm a bit of a 'Ruby Newby', so please forgive me if I'm being stupid :)

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.