Open fff opened 10 years ago
Hi there,
Sorry for the delay responding - did you manage to get it working at all?
cheers Perryn
Not really, we switched to host it in Windows, and it works fine.
Hi,
I'm also experiencing this same issue. Sounds like you threw in the towel, fff, but were you able to make any progress before then?
Cheers,
John
Hi Aurekin
I'd like to get to the bottom of this - Would you be able to make code changes and try them out on your system?
Perryn
I'd be happy to. Also not sure if this helps or if I'm going in totally the wrong direction but I noticed in my lsusb output for my build light:
Bus 001 Device 023: ID 0fc5:b080 Delcom Engineering
Device Descriptor:
.....removed for brevit....
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 10
Device Status: 0x0002
(Bus Powered)
Remote Wakeup Enabled
Looks like wMaxPacketSize is 8 bytes but libusb is sending:
submit transfer #<LIBUSB::Call::Transfer:0x00000004c72af0> buffer: #<FFI::Pointer address=0x007fd698131dc0> length: 16 status: :TRANSFER_COMPLETED callback: #<FFI::Function address=0x007fd6bf0c00c0> dev_handle: #<FFI::Pointer address=0x007fd6981309e0>
which seems to be 16 bytes?
Again, just messing around and clutching at straws but thought maybe it's useful.
heh - no idea :)
In the meantime try adding
begin
@handle.usb_detach_kernel_driver_np(0)
rescue LIBUSB::ERROR_NOT_FOUND
# Already detached
end
@handle.set_configuration(device.configurations.first)
@handle.usb_claim_interface(0)
after line 5 in light.rb?
Also, what version of Ubuntu are you running?
I'm running 14.04.
I added your code and I'm now getting
ActionController::RoutingError (undefined local variable or method `device' for #<Blinky::Light:0x000000049fc8e8>):
app/controllers/light_controller.rb:7:in `<class:LightController>'
app/controllers/light_controller.rb:5:in `<top (required)>'
Sounds like it might relate to light.rb:11 (@handle.set_configuration(device.configurations.first))
Also as an aside, I'm a Melb based TWer, just started at the beginning of the year. I'm working with Ranjeet and he mentioned that he knew you when we came across this project. Small world!
doh
In that case, instead of calling device.open in LightFactory and constructing Light with the result, you'll need to construct Light with the device and call open to obtain the handle.
Working like a charm, now. Posting my light_factory.rb and light.rb for reference:
light_factory.rb
module Blinky
class LightFactory
def self.detect_lights plugins, recipes
lights = []
found_devices = []
USB.devices.each do |device|
found_devices << device
matching_recipe = recipes[device.idVendor][device.idProduct]
if matching_recipe
lights << Light.new(device, matching_recipe, plugins)
end
end
raise NoSupportedDevicesFound.new found_devices if lights.empty?
lights
end
end
end
light.rb
module Blinky
class Light
def initialize device, recipe, plugins
@handle = device.open
begin
@handle.usb_detach_kernel_driver_np(0)
rescue LIBUSB::ERROR_NOT_FOUND
# Already detached
end
@handle.set_configuration(device.configurations.first)
@handle.usb_claim_interface(0)
self.extend(recipe)
plugins.each do |plugin|
self.extend(plugin)
end
self.init
end
def where_are_you?
5.times do
failure!
sleep(0.5)
success!
sleep(0.5)
end
off!
end
end
end
awesome, now we just need to make sure it still works on other platforms
Sounds like a plan. I can check it on a Mac and possibly a Windows machine if that would help?
it would, but I bet it wont work ;)
had the same issue with my linux x64 machine, with the patch you guys figured out, its now working like a charm. thanks
Just tested the fix on a windows machine and it seems to work just fine. Haven't had a chance to test on OSX yet but hopefully will sometime today.
hey @Aurenkin did you get anywhere?
I didn't get around to testing on OSX yet but thanks for reminding me, I should be able to borrow a Macbook today to test it out.
Sorry for taking so long to get to this! Finally put OSX back on my mac and tested today. Unfortunately it looks like with the code changes we made, it doesn't work for mac :( . Let me know if you want me to test anything else out.
hey @Aurenkin are you interested in helping out further on this?
Yeah for sure, I don't know if I have access to a build light anymore though but I will see if I can dig one up.
On 7 October 2014 14:50, Perryn Fowler notifications@github.com wrote:
hey @Aurenkin https://github.com/Aurenkin are you interested in helping out further on this?
— Reply to this email directly or view it on GitHub https://github.com/perryn/blinky/issues/7#issuecomment-58133012.
FWIW I'm having the same issue on a Raspberry Pi running Raspbian.
hi @holmesjr - did you try the patch described above?
First thing tomorrow, I'll give it a go and report the results. I can then test on a Mac to see if it still works there.
OK, the patch makes things work once. After that the same error pops up. These were run immediately one after the other.
irb(main):002:0> blinky = Blinky.new
=> #<Blinky::Blinky:0xb955dea8 @recipes={4037=>{4643=>Blinky::DelcomEngineering::VisualIndicator::GenerationI, 45184=>Blinky::DelcomEngineering::VisualIndicator::GenerationII}, 10168=>{493=>Blinky::ThingM::Blink1}, 7476=>{4=>Blinky::DreamCheeky::WebmailNotifier}}, @plugins=[Blinky::TestCiServer, Blinky::CCTrayServer], @lights=[#<Blinky::Light:0xb9b6c098 @handle=#<USB::DevHandle:0xb9b8f120 @dev=#<LIBUSB::DevHandle:0xb9b8f138 @device=#<LIBUSB::Device 1/13 0fc5:b080 Delcom Products Inc. USB IO Controller ? (HID (00,00))>, @pHandle=#<FFI::Pointer address=0xb9b72eb0>, @interrupt_transfer=nil, @control_transfer=nil, @bulk_transfer=nil>>>]>
irb(main):003:0> blinky.lights[0].success!
=> 8
irb(main):004:0> blinky.lights[0].success!
LIBUSB::ERROR_NO_DEVICE: LIBUSB::ERROR_NO_DEVICE in libusb_submit_transfer
from /home/pi/.gem/ruby/2.1.3/gems/libusb-0.2.2/lib/libusb/constants.rb:46:in `raise_error'
from /home/pi/.gem/ruby/2.1.3/gems/libusb-0.2.2/lib/libusb/transfer.rb:135:in `submit!'
from /home/pi/.gem/ruby/2.1.3/gems/libusb-0.2.2/lib/libusb/transfer.rb:162:in `submit_and_wait!'
from /home/pi/.gem/ruby/2.1.3/gems/libusb-0.2.2/lib/libusb/dev_handle.rb:390:in `control_transfer'
from /home/pi/.gem/ruby/2.1.3/gems/libusb-0.2.2/lib/libusb/compat.rb:316:in `usb_control_msg'
from /home/pi/Documents/Projects/blinky/lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb:35:in `set_colour'
from /home/pi/Documents/Projects/blinky/lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb:27:in `off!'
from /home/pi/Documents/Projects/blinky/lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb:7:in `success!'
from (irb):4
from /home/pi/.rubies/ruby-2.1.3/bin/irb:11:in '<main>'
Hmm, saying it worked was slightly optimistic. While it returned without an error, the light flashed instead of actually showing the chosen status. I've run the latest from git against the same light on a Mac (without the changes above) and the correct behaviour is observed.
I had the same problem when trying to control a 904008 light on a Raspberry Pi running Raspbian. After @Aurenkin's patch setting the lights worked. However something goes wrong later on when running .watch_test_server - not sure is it related with this patch or not.
During the "WARNING" state the light blinks yellow and dmesg
shows that the device is disconnected / reconnected very often during the warning blinking, which probably causes the issue of no device being found when trying to re-control it.
pi@raspberrypi ~ $ sudo ruby blinky-test.rb
BUILDING!
-
BUILD FAILED!
-
BUILDING!
-
WARNING!
-
BUILDING!
/var/lib/gems/1.9.1/gems/libusb-0.2.2/lib/libusb/constants.rb:46:in `raise_error': LIBUSB::ERROR_NO_DEVICE in libusb_submit_transfer (LIBUSB::ERROR_NO_DEVICE)
from /var/lib/gems/1.9.1/gems/libusb-0.2.2/lib/libusb/transfer.rb:135:in `submit!'
from /var/lib/gems/1.9.1/gems/libusb-0.2.2/lib/libusb/transfer.rb:162:in `submit_and_wait!'
from /var/lib/gems/1.9.1/gems/libusb-0.2.2/lib/libusb/dev_handle.rb:390:in `control_transfer'
from /var/lib/gems/1.9.1/gems/libusb-0.2.2/lib/libusb/compat.rb:316:in `usb_control_msg'
from /var/lib/gems/1.9.1/gems/blinky-0.0.12/lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb:35:in `set_colour'
from /var/lib/gems/1.9.1/gems/blinky-0.0.12/lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb:27:in `off!'
from /var/lib/gems/1.9.1/gems/blinky-0.0.12/lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb:17:in `building!'
from /var/lib/gems/1.9.1/gems/blinky-0.0.12/lib/ci_server_plugins/test_server_plugin.rb:25:in `watch_test_server'
from blinky-test.rb:5:in `<main>'
The blinking / reconnecting problem was due to the Delcom pulling too much current from the Raspi port. Putting an active USB hub in between solved that problem. But the patch was necessary for it to work.
I have also just run into this on current Raspbian on RPi 2.
Not sure what's the cause