Thought I would share: Ruby script to control USB dart launchers

Been hacking away at this for a bit and I'm calling this good for now   This script controls USB dart launchers like this guy:
0a81:0701 Chesen Electronics Corp. USB Missile Launcher
At the moment, it's coded to only control the above, but add your idVendor, idProduct, and movement codes to the ActionData hash and it should pick right up and work.
Requires the libusb and curses gems.  Codepad: http://codepad.org/v9h3ziYw
Enjoy!
#!/usr/bin/env ruby
Version = '0.1'
abort("Usage: #{__FILE__} idVendor:idProduct") if ARGV.empty?
require 'curses'
require 'libusb'
# Add your own idVendor, idProduct, and movement codes here!
ActionData = {
:idVendor => 0x0a81,
:idProduct => 0x0701
} => {
:up => 0x02,
:down => 0x01,
:left => 0x04,
:right => 0x08,
:fire => 0x10,
:stop => 0x20,
class RocketLauncher
attr_accessor :device
def move(symbol)
@usb.control_transfer(
:bmRequestType => 0x21,
:bRequest => 0x09,
:wValue => 0x0000,
:wIndex => 0x0000,
:dataOut => ActionData[{
:idVendor => device[:idVendor],
:idProduct => device[:idProduct]
}][symbol].chr
end
def start
begin
@usb = LIBUSB::Context.new.devices(
:idVendor => device[:idVendor],
:idProduct => device[:idProduct]
).first.open.claim_interface(0)
rescue LIBUSB::ERROR_ACCESS
abort("No permission to access USB device!")
rescue LIBUSB::ERROR_BUSY
abort("The USB device is busy!")
rescue NoMethodError
abort("Could not find USB device!")
end
Curses.noecho
Curses.init_screen
Curses.stdscr.keypad(true)
Curses.timeout = 150
Curses.addstr("USB Rocket Launcher Controller v#{Version} by Maxwell Pray")
loop do
Curses.setpos(2,0)
case Curses.getch
when Curses::Key::UP, 'w', 'W'
Curses.addstr("Movement: Up!")
self.move(:up)
when Curses::Key::DOWN, 's', 'S'
Curses.addstr("Movement: Down!")
self.move(:down)
when Curses::Key::LEFT, 'a', 'A'
Curses.addstr("Movement: Left!")
self.move(:left)
when Curses::Key::RIGHT, 'd', 'D'
Curses.addstr("Movement: Right!")
self.move(:right)
when Curses::Key::ENTER, 10, ' '
Curses.addstr("Movement: Fire!")
self.move(:fire)
when 27, 'q', 'Q'
exit
else
Curses.addstr("Waiting for key...")
self.move(:stop)
end
Curses.clrtoeol
end
end
end
launcher = RocketLauncher.new
device = ARGV[0].split(':').map { |id| id.to_i(base=16) }
launcher.device = {
:idVendor => device[0],
:idProduct => device[1]
launcher.start

problem fixed with method
detach_kernel_driver
thx ^^
but now there is no FIRE action with enter Action is active, but:
:fire  => 0x10
does nothing.
Where i can find any info about this? Maybe it must be another for my device?

Similar Messages

  • HT1318 I have received this in my email. Thought I would share, to see if it's authentic

    I have received this in my email. Thought I would share, to see if it's authentic
    Hello,
    The following information for your Apple ID was updated on 01/27/2014:
    Shipping and/or billing address
    Credit card
    If these changes were made in error, or if you believe an unauthorized person accessed your account, please reset your account password immediately by going to iforgot.apple.com.
    To review and update your security settings, sign in to appleid.apple.com.
    This is an automated message. Please do not reply to this email. If you need additional help, visit Apple Support.
    Thanks,
    Apple Customer Support
    TM and copyright © 2014 Apple Inc. 1 Infinite Loop, MS 96-DM, Cupertino, CA 95014.
    All Rights Reserved / Keep Informed / Privacy Policy / My Apple ID
    <Email Edited By Host>

    You really should not post your email address on a public forum such as this unless you just love to get spam. I requested that the Hosts edit them for your protection.
    Allan

  • I thought I would share some code also...

    Here is something I have been working on for a quite a while also:
    public class HolaMundo
        public static void main(String args[])
            System.out.println('\u00a1Hola Mundo!"):
    }I think the spanish gives it a kind of international feel.
    I hope you all like it.
    Oh, by the way, I get some errors when I compile it, could you tell me what the problem is.

    How about this:
    public class HelloWorldInternational {
      public static void main (String[] args) {
        for (int i = 0; i < args.length; i++) {
          String temp = (String)greeting.get(args);
    if (temp == null) {
    System.out.println("Sorry, I don't know \""+args[i]+"\".");
    continue;
    System.out.println(temp);
    private static Map greetings;
    static {
    greetings = new HashMap();
    greetings.put("English", "Hello World!")
    greetings.put("Espan�l", "�Hola Mundo!");
    greetings.put("Russkye", "Privyet Mir!");
    greetings.put("Latina", "Salve Terra!");

  • I just got the iphone 4 and my husband already had on. we share an itunes account and i signed up for i cloud and now ALL  of my husbands contacts are on my phone ... so I started to delete them (because i thought it would just be off my phone) and he cal

    i just got the iphone 4 and my husband already had on. we share an itunes account and i signed up for i cloud and now ALL  of my husbands contacts are on my phone ... so I started to delete them (because i thought it would just be off my phone) and he called screaming ..." please stop deleting ...  they are coming off my phone!" so two things ...  how can i get the contacts back ( i got up to j) AND is there a way to get them off just my phone

    Unfortunately there's no way to get back the contacts you deleted unless he backed them up somewhere else.  He'll just have to recreate them.  This happened because you are both syncing contacts with a shared iCloud account.  When you do this, the synced data is merged and any actions you take on one phone (such as deleting contacts) is also reflected on the other.  To fix this you both need to have separate iCloud accounts (you can continue to share the same Apple ID for purchasing from the iTunes and app stores).  To do this, on your phone go to Settings>iCloud and turn all data that is syncing with iCloud (contacts, calendars, etc.) to Off.  When prompted choose to keep the data on the iPhone.  After everything is turned off, scroll to the bottom and tap Delete Account.  (This will only delete the account from this phone, not from iCloud.  The other phone will not be effected by this.)  Next, set up a new iCloud account on your phone using a different Apple ID and turn iCloud data syncing for contacts, etc. back to On.  When prompted, choose Merge.  This will upload your data to your new account.  At this point you will have two different iCloud accounts, one for each phone, with identical data on them.
    You will then have to go to icloud.com on your computer and sign into each iCloud account separately and manually delete the unwanted data (such as deleting the your husband's contacts from your account, and vice versa).  These changes will be reflected on each phone.  When finished you will have individual iCloud accounts with just your own data on them.

  • I deleted all my playlist by mistake from itunes. tried copying the to on the go on ipod and thought it would copy it on to my itune but it didn't. does any one know how i can do this without redoing all my playlists. thanks

    I deleted all my playlist by mistake from itunes. tried copying them to on the go on ipod and thought it would copy it on to my itune but it didn't. does any one know how i can do this without redoing all my playlists. thanks

    Are the playlists still on the iPod? If so I can probably cook up a script to read them back into iTunes, or you can check the features of the various tools listed at the end of this user tip to see if you can find one that you want to use.
    tt2

  • I'm trying to share a script, but it won't work

    I have Story Plus and paying a monthly fee to have this.  Aren't I supposed to be able to share a script with someone?  When I send a share to someone, they get a message that says that I have exceeded my sharing limit.  I haven't shared with anyone so I don't understand.

    Hi Josh,
    Story allows for project level sharing. But once the project is shared, all the scripts within the project are shared with the user.
    You can share the project with your partner either as co-author or writer depending on the control you want.
    The writer  has limited permissions and cannot perform the following actions:
    See drafts of episodes authored by other writers
    Create or view reports and schedules
    See the lists assigned to the current project
    Share, archive, or rename a project shared with them
    See edit notifications for documents created by other users. In particular, users in this role will see the following notifications:
    For more details see:  http://helpx.adobe.com/content/help/en/story/help/collaborating-users.html
    Cheers,
    Anjali

  • Ruby scripts & launchd

    I have writting a ruby script for use by launchd. The script runs fine on it on without launchd and been tested several times on several items. However, when loaded by launchd it gives an error and exits. Here is the launchd plist:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>com.avicenna.webloc2url</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Program</key>
    <string>/Users/avicenna/Library/Scripts/webloc2url.rb</string>
    <key>ProgramArguments</key>
    <array>
    <string>webloc2url.rb</string>
    </array>
    <key>WatchPaths</key>
    <array>
    <string>/Users/avicenna/Downloads/Bookmarks</string>
    </array>
    </dict>
    </plist>
    and here is the syslog error:
    Nov 26 15:35:13 avicenna com. avicenna.webloc2url[17236]: nil
    Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: /Users/avicenna/Library/Scripts/webloc2url.rb:10
    Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: : private method `sub!' called for nil:NilClass (NoMethodError)
    Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: from /Users/avicenna/Library/Scripts/webloc2url.rb:4:in `each'
    Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: from /Users/avicenna/Library/Scripts/webloc2url.rb:4
    Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: nil
    Nov 26 15:35:38 avicenna com.apple.launchd[132] (com. avicenna.webloc2url[17243]): Exited with exit code: 1
    regarding the error:
    private method `sub!' called for nil:NilClass (NoMethodError)
    the stand alone script never complains about such an error, actually it does the substitution and prints what is expected. In fact, the script does the job well. So, this makes me think that there might be some limitation on the execution of ruby scripts by launchd? Or maybe the parameters I've put in the plist file are not correct or missing something?
    Any kind of help or hint would be appreciated.
    Thanks.

    jarik, thanks and sorry if I bothered you. I have made little changes in the script and I don't see any complains in the system.log anymore. Here is the script with the changes:
    #!/usr/bin/env ruby
    Dir.chdir("/Users/avicenna/Downloads/Bookmarks")
    d = Dir.new("/Users/avicenna/Downloads/Bookmarks/")
    d.each do |x|
    if x =~ /webloc/
    y = `strings '#{x}'/..namedfork/rsrc`.chomp.detect { |v| v =~ /http/ }
    webloc = File.open("#{x}", 'r+')
    webloc.puts "[InternetShortcut]\nURL" + y.sub!(/^./, '=')
    #puts y
    webloc.close
    oldFile = x
    newFile = x.sub(/webloc/, 'url')
    File.rename(oldFile, newFile)
    end
    end
    I've added the .chomp as you can notice and the substitution changed to '=' from the preceeding string instead of an empty ''. I hope this will fix it for good. And I don't know exactly what did that change anyway for launchd!
    Thanks again.

  • Script calendar control appearance

    I'm using Adobe LiveCycle Designer 7.0.
    I have a drop-down list that calculates a Date/Time value via a FormCalc script that fires on exit.
    The first three drop-down list items set fixed dates: today, 30 days from today and 60 days from today. The exit script works correctly for these three list items.
    I'd like to add a fourth drop-down list item called "any date". Selection of this list item would display the Acrobat calendar control so any date could be selected.
    Can the Acrobat calendar control be displayed in this manner?

    Hi Thought2,
    Sorry, as far as I know currently there is no in-build calendar control, but there are quite lot of third party calendar control developed by communities also companies, try to search with key words: "windows store app calendar control", you would
    be able to find some.
    Hope this helps.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • HT1977 I bought an app for my kid and it wasn't what we thought it would be.

    I bought an app for my kid and it wasn't what we thought it would be. How can I return this app and not be charged for it?

    Contact the developer.
    Important: Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. Apple assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. Apple provides this only as a convenience to our users. Apple has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and Apple assumes no responsibility in this regard. Please understand that a third-party site is independent from Apple and that Apple has no control over the content on that website. Please contact the vendor for additional information.

  • How do i change the email address for my icloud account on my 4s. when i sign in on line it is my new email address so i thought it would change automatically but obviously not!

    how do i change the email address for my icloud account on my 4s. when i sign in on line it is my new email address so i thought it would change automatically but obviously not!

    Settings>iCloud...scroll down...delete account. Then setup iCloud with your new ID.
    You can't change the Apple ID for your iCloud account, you have to delete it.

  • Please can you help....  I ordered an iPhone 5s in early September from the orange shop in Chamonix Mont-Blanc France.  I needed a new phone as i dropped my iPhone and broke it so it thought i would upgrade.  I was asked in the shop if I wanted a black or

    Please can you help....
    I ordered an iPhone 5s in early September from the orange shop in Chamonix Mont-Blanc France.
    I needed a new phone as i dropped my iPhone and broke it so it thought i would upgrade.
    I was asked in the shop if I wanted a black or white one, I asked for a Black one, as all my iPhones have all been Black as I DON'T LIKE White ones. (sorry)
    I was told my phone would arrive in a week so I waited with broken phone for new one. The following week I was told it would be the following week, the following week i was told the same but the assistant in the shop told me they would ring me when it arrived. Three days later i recieved a text from the shop to say the phone would be in tomorrow, when I went in they said it had not arrived and they would call me when it was in the shop.
    They called me on Thursday the 17th of October to say the phone was in the shop.
    I arrived at the shop at 6:00pm after my work, the shop closes at 7:00pm. I recieved the phone, signed for it and extra unwanted insurance with I was told I could only canceled in a month. I was then told they didn't have any sim cards in the shop, i said no problem the Phone i assume will need charging so i will take it home and charge it and return for the sim tomorrow.
    So the Phone remained boxed.
    When I returned home and opened the box I realised it was a white one, I replaced the lid put it back in the bag, and returned it to the shop first thing Friday 18th October, to point out the error, only to be told "to bad" ?? I was told I could have changed it the night before but not this morning? They said I had ordered a Black one but as I had signed for a White one nothing can be done. I was angry and left the shop. I returned later the same day with a French friend to try and resolve this problem, as I wasn't sure if something was being lost in translation. I didn't think I was being unreasonable, it is a very expensive piece of equipment and this wasn't what i wanted. They told my friend that the phone was not available in Black, that was the 5, and that the 5s was only available in silver and gold, and that mine was a silver one.
    I then thought it was my mistake as it was a new phone. She put a sim in the phone put it in the box and I left for a business meeting only to arrive and see a Black iPhone 5s sitting on the table??
    So I then returned back to the shop with the Black one and mine still all boxed and untouched to prove they had blatantly lied to me an hour ago, only to be told that there was nothing they were prepared to do.
    Is this fair practice ? I am at a loss with this and am looking for help ?

    Welcome to the Support Communities. This Apple doc may be of interest:
    Channel Member Code of Conduct
    Kings74 wrote:
    They told my friend that the phone was not available in Black, that was the 5, and that the 5s was only available in silver and gold..
    A minor point, but it may avoid a little confusion if, instead of saying "black" in reference to the iPhone 5s, say "space gray":
    "iPhone 5s — Available in silver, gold, and space gray" (Source)

  • I have  new computer, how do I transfer my old library over , thought Homesharing would work but I cant figure out how to transfer. Thanks

    I have a new laptop and have installed iTunes. How do I transfer my library from my old computer over?  I thought Homesharing would do it but I cant figure it out. I got to the point of it showing that I have homesharing on each computer but how do I download the old into the new?  Thanks

    I tried this with apps and it worked flawlessly!!
    You can do the same with music, playlists etc
    I did it on Windows 7 Ultimate 32-bit
    You should have same Itunes version on both systems!!
    Here are the methods to follow:
    Just for safety, on your new PC go to Edit > Preferences > Devices - and check "Prevent Ipods, Iphones and Ipad from syncing automatically.
    From your old computer,
    1) Open itunes
    2) Go to Edit > Preferences > Advanced
    3) here you may see a location under heading "itunes media folder location"
    4) Go to that location and open "mobile applications" folder. Copy the entire files/apps inside it and paste it to any removable device supporting the size.
    On your new computer:
    a) Repeat steps 1 to 3.
    b) Go to the location you have found in your new computer. You'll find same folders. Now, copy apps/files from your removable device to "Automatically Add to Itunes folder" DO NOT COPY it in Mobile applications folder because it won't sync that way!
    This completely restored all my apps that I had to transfer from my PC to laptop!! You can try to do same with music... This should work!
    HOPE THIS HELPS!

  • I found my old iPod shuffle and thought I would sync my iTunes library onto it, now my laptop no longer recognises my ipad! Very frustrating!

    I found my old iPod shuffle (3rd gen) and thought I would sync my iTunes library onto it, iTunes wouldn't recognise it at first so following forums on here I managed to find some apple software to reset and update the shuffle! This worked and the iPod shuffle was then recognised by iTunes but now my laptop no longer recognises my ipad! Very frustrating!
    Please can some one help! I've been searching on here for a few days now and have tried numerous suggestions from other people's questions but nothing has worked yet!

    You can try this:
    I am assuming you are running Windows:
    Plug in your iPad to the PC.
    Now go to "Start"   - "devices and printers"
    Is your iPad showing there ?   (you may have to scroll down)
    If you can see it - right click the iPad icon and select "Troubleshoot"
    If the USB driver is missing/incorrect it will tell you.
    You can also look here                      http://support.apple.com/kb/TS1538

  • HT1386 How do I get my music from cd's that is on my ipod to my library in itunes?  Got a new computer, thought icloud would help but it has erased anything is not purchased from my library.

    How do I get my music from cd's that is on my opod to my library in itunes?  I got a new computer, installed itunes and thought syncing would work.  It only synced purchases.  Any music I had from cd's is not in my library anymore.  Then I turned on the cloud and it erased those tracks from my other computer as well.  Help please.

    Your iPod can only be synced with one computer at a time.  If you try to sync it with a new computer/iTunes library, it will replace the contents of the iPod with whatever is in the new library. You should probably disable the autosync functionality first by going to Edit -> Preferences, clicking the Devices tab, and enabling the prevent iPods,iPhones, and iPads from automatically syncing option.
    Before doing anything else,  authorize the new computer with your iTunes Account.  In iTunes, choose Store -> Authorize This Computer and enter in the correct credentials. Either copy a backup file from your old computer to your new one or create a new backup of your iPod in iTunes before letting it sync.
    Then right->click on your iPod Touch from under the Devices section in the left hand pane of iTunes and choose Backup. You might also want to take a look at this article to see what it all included in the backup.
    iOS: How to back up
    Now onto synced content such as music, videos, photos, etc.  For iTunes purchases you can copy them back into iTunes by choosing File -> Transfer Purchases.  For all other nonpurchased iTunes content, see this excellent user tip from another forum member turingtest2 outlining the different methods and software available to help you copy content from your iPod back to your PC and into iTunes.
    Recovering your iTunes library from your iPod or iOS device
    Once the backup has been made and all other synced content such as music, videos, and photos are back in your iTunes library, restore your iPod from that backup you made earlier.  Here is more on backing up and restoring your iPod.
    iTunes: Backing up, updating, and restoring iOS software
    If you do happen to lose any purchased content, you can always redownload it from the iTunes Store again at no cost via iCloud.  See this article for information.
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    B-rock

  • How much ram can I add to my late 2008 MacBook Pro? I run Mavericks and just got a new inexpensive hard drive. RAM is not very expensive so Thought I would bump it up from the current 2MB of 1067 Mhz DDr3

    How much ram can I add to my late 2008 MacBook Pro? I run Mavericks and just got a new inexpensive hard drive. RAM is not very expensive so Thought I would bump it up from the current 2MB of 1067 Mhz DDr3

    Maximum Memory
    8.0 GB (Actual) 4.0 GB (Apple)
    Memory Slots
    2 - 204-pin PC3-8500 (1066 MHz) DDR3 SO-DIMM

Maybe you are looking for