Skip to content

Commit

Permalink
Adding other people's code as found on the internet and my own stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
ab3nd committed Feb 11, 2011
0 parents commit e1f0f3d
Show file tree
Hide file tree
Showing 46 changed files with 20,266 additions and 0 deletions.
27 changes: 27 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* main.cpp
*
* Created on: Feb 11, 2011
* Author: ams
*
* Uses the object-oriented control program for controlling the Dream Cheeky
* Missile Launcher to move the launcher and fire the missiles.
*
*/

#include <iostream>
#include "missile_launcher.h"

using namespace std;

int main(int argc, char** argv)
{
MissileLauncher mc;
if(mc.init() == 0){
mc.fire();
}else{
cerr << "Failed to initialize missile launcher" << endl;
}

return 0;
}
5 changes: 5 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Makes the missile launcher
all: missileCommand

missileCommand:
g++ main.cpp missile_launcher.cpp -lusb -L/usr/lib -o missileCommand
68 changes: 68 additions & 0 deletions missile_launcher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* missile_launcher.cpp
*
* Created on: Feb 11, 2011
* Author: ams
*
* Creates and maintains info about a Dream Cheeky Missile Launcher.
*
*/

#include "missile_launcher.h"

void MissileLauncher::fire()
{

}

int MissileLauncher::init()
{
struct usb_bus *busses;

usb_init();
if (usb_find_busses() != 0)
{
cerr << "Failed to find USB buses" << endl;
return 1;
}

if (usb_find_devices() != 0)
{
cerr << "Failed to find USB devices" << endl;
return 1;
}

busses = usb_get_busses();

struct usb_bus *bus;

//Iterate through buses and devices, looking for a missile launcher
for (bus = busses; bus; bus = bus->next)
{
struct usb_device *dev;

for (dev = bus->devices; dev; dev = dev->next)
{
/* Check if this device is a missile launcher */
if (dev->descriptor.idVendor == 6465)
{
launcher = usb_open(dev);

int claimed = usb_claim_interface(launcher, 0);
if (claimed == 0)
{
//Rock on, we have a handle on it.
return 0;
}
else
{
cerr << "Could not claim Missile Launcher" << endl;
return 1;
}
}
}
}

cerr << "Did not find Missile Launcher. Is it plugged in?" << endl;
return 1;
}
25 changes: 25 additions & 0 deletions missile_launcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* missile_launcher.h
*
* Created on: Feb 11, 2011
* Author: ams
*/

#ifndef MISSILE_LAUNCHER_H_
#define MISSILE_LAUNCHER_H_

#include <usb.h>
#include <iostream>

using namespace std;

class MissileLauncher
{
public:
int init();
void fire();
private:
usb_dev_handle* launcher;
};

#endif /* MISSILE_LAUNCHER_H_ */
Binary file added other_peoples_code/ahmissile-0.5.tar.gz
Binary file not shown.
Empty file.
Loading

0 comments on commit e1f0f3d

Please sign in to comment.