Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

sniner/cleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sniner/cleware

Access library for some Cleware devices. It has been tested with these devices:

  • Ampel "traffic light" (0d50:0008 v29, v106)
  • Contact (0d50:0030 v3)
  • IO16 (0d50:0030 v14)

Dependencies

  • HIDAPI: Be sure to install the right hidapi library. It comes in two flavors: based on libusb and one called 'raw'. Get hidapi based on libusb if you have to choose one. On Arch Linux you will find one package with both flavors included.
  • libc: Needed for converting wide-strings.
  • FFI gem

Permissions

In order to grant users access to Cleware devices you have to give them write access on the corresponding device files /dev/usb/hiddev*. This can be accomplished by e.g. /etc/udev/rules.d/99-cleware.rules with following content:

ATTRS{idVendor}=="0d50", MODE="0666"

Building the gem

gem build cleware.gemspec
gem install cleware-0.1.0.gem

Example

require 'sniner/cleware'

include Sniner::Cleware::TrafficLight::Colors

tl = Sniner::Cleware.devices(:product => Sniner::Cleware::PRODUCT_LED).first

tl.open do |dev|
    # Setting colors individually
    dev.red = true
    dev.yellow = true
    sleep(1)

    # Using a bit mask
    dev.leds = RED|GREEN
    sleep(1)

    # Flipping on/off states
    dev.leds ^= ALL
    sleep(1)
end

HID API vs libusb

All Cleware gadgets are USB HID class devices. The USB human interface device (HID) class is an abstraction layer while libusb provides low-level access. As far as I know the HID API is the preferred way of accessing Cleware devices, but accessing via libusb does work too. A libusb version is included, but not used by default and is not maintained.

Further reading

About

Ruby library for Cleware devices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages