diff options
author | N.N. <matju@users.sourceforge.net> | 2008-04-28 18:10:15 +0000 |
---|---|---|
committer | N.N. <matju@users.sourceforge.net> | 2008-04-28 18:10:15 +0000 |
commit | 91c0003b158e5f0ed9d0677fb136ae8bb6f86ec5 (patch) | |
tree | d413a48086819f6a2620cd27d030861d122d4f3f /externals/gridflow/optional/usb.rb | |
parent | 98dfdfa2fc1c92ba69e33fd77ed3392034297c1f (diff) |
this is an old gridflow, and there's already a svn repository at http://gridflow.ca/svn/trunk
svn path=/trunk/; revision=9739
Diffstat (limited to 'externals/gridflow/optional/usb.rb')
-rw-r--r-- | externals/gridflow/optional/usb.rb | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/externals/gridflow/optional/usb.rb b/externals/gridflow/optional/usb.rb deleted file mode 100644 index 98191329..00000000 --- a/externals/gridflow/optional/usb.rb +++ /dev/null @@ -1,107 +0,0 @@ -=begin - $Id: usb.rb,v 1.1 2006-03-15 04:46:22 matju Exp $ - - GridFlow - Copyright (c) 2001,2002,2003,2004,2005 by Mathieu Bouchard - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - See file ../COPYING for further informations on licensing terms. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -=end - -module GridFlow - -class<<USB - attr_reader :busses -end - -FObject.subclass("delcomusb",1,1) { - Vendor,Product=0x0FC5,0x1222 - def self.find - r=[] - USB.busses.each {|dir,bus| - bus.each {|dev| - r<<dev if dev.idVendor==Vendor and dev.idProduct==Product - } - } - r - end - def initialize #(bus=nil,dev=nil) - r=DelcomUSB.find - raise "no such device" if r.length<1 - raise "#{r.length} such devices (which one???)" if r.length>1 - @usb=USB.new(r[0]) - if_num=nil - r[0].config.each {|config| - config.interface.each {|interface| - if_num = interface.bInterfaceNumber - } - } - # post "Interface # %i\n", if_num - @usb.set_configuration 1 - @usb.claim_interface if_num - @usb.set_altinterface 0 rescue ArgumentError - end - # libdelcom had this: - # uint8 recipient, deviceModel, major, minor, dataL, dataM; - # uint16 length; uint8[8] extension; - def _0_send_command(major,minor,dataL,dataM,extension="\0\0\0\0\0\0\0\0") - raise "closed" if not @usb - raise "extension.length!=8" if extension.length!=8 - @usb.control_msg( - 0x000000c8, 0x00000012, - minor*0x100+major, - dataM*0x100+dataL, - extension, 5000) - end - def delete; @usb.close; end -} - -FObject.subclass("klippeltronics",1,1) { - def self.find - r=[] - USB.busses.each {|dir,bus| - bus.each {|dev| - GridFlow.post "dir=%s, vendor=%x, product=%x", - dir, dev.idVendor, dev.idProduct - r<<dev if dev.idVendor==0xDead and dev.idProduct==0xBEEF - } - } - r - end - def initialize - r=self.class.find - post "%s", r.inspect - raise "no such device" if r.length<1 - raise "#{r.length} such devices (which one???)" if r.length>1 - $iobox=@usb=USB.new(r[0]) - if_num=nil - r[0].config.each {|config| - config.interface.each {|interface| - #post "interface=%s", interface.to_s - if_num = interface.bInterfaceNumber - } - } - # post "Interface # %i\n", if_num - # @usb.set_configuration 0 - @usb.claim_interface if_num - @usb.set_altinterface 0 rescue ArgumentError - end - #@usb.control_msg(0b10100001,0x01,0,0,"",1000) - #@usb.control_msg(0b10100001,0x01,0,1," ",0) - def delete; @usb.close; end -} - -end # module GridFlow |