comp.lang.ada
 help / color / mirror / Atom feed
* USB Missile launcher
@ 2014-10-29 17:43 kadrickhenderson008
  2014-10-29 18:19 ` David Botton
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: kadrickhenderson008 @ 2014-10-29 17:43 UTC (permalink / raw)


I have a group project for a senior course at my University. We were assigned to choose a language and create something meaningful. The language we chose was Ada. Ada was a language developed for the Department of Defense, so we felt it would be nice to program a USB missile launcher: http://www.thinkgeek.com/product/8a0f/ using Ada. Can anyone guide me through the necessary steps to achieve this. We have the hex codes to send to the device. The device connects to the pc via USB. I have done some research and found that there is a library for serial port communication but have yet to find one for usb. Any advice would be helpful.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-29 17:43 USB Missile launcher kadrickhenderson008
@ 2014-10-29 18:19 ` David Botton
  2014-10-29 18:33   ` kadrickhenderson008
  2014-10-29 20:59 ` Dmitry A. Kazakov
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: David Botton @ 2014-10-29 18:19 UTC (permalink / raw)


You may want to start with what platform and compiler you are using


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-29 18:19 ` David Botton
@ 2014-10-29 18:33   ` kadrickhenderson008
  2014-10-29 18:42     ` kadrickhenderson008
  0 siblings, 1 reply; 11+ messages in thread
From: kadrickhenderson008 @ 2014-10-29 18:33 UTC (permalink / raw)


On Wednesday, October 29, 2014 2:19:05 PM UTC-4, David Botton wrote:
> You may want to start with what platform and compiler you are using

We are trying to decide whether to use a Windows or Linux environment. Seems that the Windows route maybe a little more tedious. We are using the GNAT compiler.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-29 18:33   ` kadrickhenderson008
@ 2014-10-29 18:42     ` kadrickhenderson008
  0 siblings, 0 replies; 11+ messages in thread
From: kadrickhenderson008 @ 2014-10-29 18:42 UTC (permalink / raw)


On Wednesday, October 29, 2014 2:33:42 PM UTC-4, kadrickhe...@yahoo.com wrote:
> On Wednesday, October 29, 2014 2:19:05 PM UTC-4, David Botton wrote:
> > You may want to start with what platform and compiler you are using
> 
> We are trying to decide whether to use a Windows or Linux environment. Seems that the Windows route maybe a little more tedious. We are using the GNAT compiler.

To be more specific: Windows 7 or Linux Ubuntu 14.04

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-29 17:43 USB Missile launcher kadrickhenderson008
  2014-10-29 18:19 ` David Botton
@ 2014-10-29 20:59 ` Dmitry A. Kazakov
  2014-10-30 20:25 ` Jacob Sparre Andersen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Dmitry A. Kazakov @ 2014-10-29 20:59 UTC (permalink / raw)


On Wed, 29 Oct 2014 10:43:09 -0700 (PDT), kadrickhenderson008@yahoo.com
wrote:

> I have a group project for a senior course at my University. We were
> assigned to choose a language and create something meaningful. The
> language we chose was Ada. Ada was a language developed for the Department
> of Defense, so we felt it would be nice to program a USB missile launcher:
> http://www.thinkgeek.com/product/8a0f/ using Ada.

Firing at the prof? (:-))

> Can anyone guide me
> through the necessary steps to achieve this. We have the hex codes to send
> to the device. The device connects to the pc via USB. I have done some
> research and found that there is a library for serial port communication
> but have yet to find one for usb.

USB communication is very different from RS-232 one.

> Any advice would be helpful.

You need a USB driver for the device and additionally, if exists, the
vendor library that talks to the device. 

It is possible to develop a USB driver if you have the device
specification, device class etc. Windows driver developing kit (DDK) is a
part of the MSDN subscription. I would not go into it.

When the device class is HID you could directly talk to it, e.g. see:

http://www.edn.com/design/communications-networking/4336292/Using-the-HID-class-eases-the-job-of-writing-USB-device-drivers 

P.S. Win32Ada is Ada bindings to Windows API. It comes with GNAT.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-29 17:43 USB Missile launcher kadrickhenderson008
  2014-10-29 18:19 ` David Botton
  2014-10-29 20:59 ` Dmitry A. Kazakov
@ 2014-10-30 20:25 ` Jacob Sparre Andersen
  2014-10-31 12:34 ` Björn Lundin
  2014-11-01 22:08 ` Stephen Leake
  4 siblings, 0 replies; 11+ messages in thread
From: Jacob Sparre Andersen @ 2014-10-30 20:25 UTC (permalink / raw)


kadrickhenderson008@yahoo.com writes:

> I have a group project for a senior course at my University. We were
> assigned to choose a language and create something meaningful. The
> language we chose was Ada. Ada was a language developed for the
> Department of Defense, so we felt it would be nice to program a USB
> missile launcher: http://www.thinkgeek.com/product/8a0f/ using
> Ada. Can anyone guide me through the necessary steps to achieve
> this. We have the hex codes to send to the device. The device connects
> to the pc via USB. I have done some research and found that there is a
> library for serial port communication but have yet to find one for
> usb. Any advice would be helpful.

Might it actually be a plain USB serial port device?  If that is the
case, then the serial port library included with GNAT should be
sufficient.

Fun little project you've chosen. ;-)

Greetings,

Jacob
-- 
"There are only two types of data:
                         Data which has been backed up
                         Data which has not been lost - yet"

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-29 17:43 USB Missile launcher kadrickhenderson008
                   ` (2 preceding siblings ...)
  2014-10-30 20:25 ` Jacob Sparre Andersen
@ 2014-10-31 12:34 ` Björn Lundin
  2014-10-31 18:06   ` björn lundin
  2014-11-01 22:08 ` Stephen Leake
  4 siblings, 1 reply; 11+ messages in thread
From: Björn Lundin @ 2014-10-31 12:34 UTC (permalink / raw)


On 2014-10-29 18:43, kadrickhenderson008@yahoo.com wrote:


The device connects to the pc via USB.


I've had success running the K8055 boards from Velleman via
libusb both on Windows and Linux.

It came with a driver/dll but if I remember correctly,
I had to loop through all usb looking at Vendor and device
interfaceing.

Looking around I can't find the code at work, might be at home.
But for the linux part, I took the c-code from
http://sourceforge.net/projects/libk8055
and rewrote it (parts of it) in Ada.
And one part was to get hold of the correct usb,
and open it. (The library supports 4 cards)


libk8055.c function OpenDevice
should give you some ideas.

The data passing mechanism is of course different,
But the 8055 has


/* globals for datatransfer */
struct k8055_dev {
    unsigned char data_in[PACKET_LEN+1];
    unsigned char data_out[PACKET_LEN+1];
    struct usb_dev_handle *device_handle;
    int DevNo;
};


and is written to by
/* Actual write of data to the device endpont, retry 3 times if not
reponding correctly */
static int WriteK8055Data(unsigned char cmd)
{
    int write_status = 0, i = 0;

    if (CurrDev->DevNo == 0) return K8055_ERROR;

    CurrDev->data_out[0] = cmd;
    for(i=0; i < 3; i++)
        {
        write_status = usb_interrupt_write(CurrDev->device_handle,
USB_OUT_EP, (char *)CurrDev->data_out, PACKET_LEN, USB_TIMEOUT);
        if (write_status == PACKET_LEN) return 0;
        if (DEBUG)
            fprintf(stderr, "Write retry\n");
        }
    return K8055_ERROR;
}

where I think usb_interrupt_write is libusb


the datastructure for your missile is perhaps
found in https://code.google.com/p/thunder-missile-api/

and MissileLauncher.cs from there idicates
* HID interface by         private UsbHidPort USB;
* The data structure , which seems to be treated as a bytearray

There are other libraries out there to see the actual protocol.

I'll see if I can find the usb-connecting code I did in Ada


--

Björn


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-31 12:34 ` Björn Lundin
@ 2014-10-31 18:06   ` björn lundin
  2014-11-04 18:24     ` kadrickhenderson008
  0 siblings, 1 reply; 11+ messages in thread
From: björn lundin @ 2014-10-31 18:06 UTC (permalink / raw)


Den fredagen den 31:e oktober 2014 kl. 13:33:23 UTC+1 skrev björn lundin:
> I'll see if I can find the usb-connecting code I did in Ada


I found it, and put the binding, and a test program in dropbox

https://dl.dropboxusercontent.com/u/26175828/lib_usb_binding.zip

--
Björn


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-29 17:43 USB Missile launcher kadrickhenderson008
                   ` (3 preceding siblings ...)
  2014-10-31 12:34 ` Björn Lundin
@ 2014-11-01 22:08 ` Stephen Leake
  4 siblings, 0 replies; 11+ messages in thread
From: Stephen Leake @ 2014-11-01 22:08 UTC (permalink / raw)


kadrickhenderson008@yahoo.com writes:

> I have a group project for a senior course at my University. We were
> assigned to choose a language and create something meaningful. The
> language we chose was Ada. Ada was a language developed for the
> Department of Defense, so we felt it would be nice to program a USB
> missile launcher: http://www.thinkgeek.com/product/8a0f/ using Ada.
> Can anyone guide me through the necessary steps to achieve this. We
> have the hex codes to send to the device. The device connects to the
> pc via USB. I have done some research and found that there is a
> library for serial port communication but have yet to find one for
> usb. Any advice would be helpful.

I would start by reading the software that comes with it. If you're
lucky, it has some simply calls you can create Ada bindings for, and
write your code on top of that.

Unless the requirement is to not use purchased code for your project,
which would make sense.

Even then, reading the purchased code will tell you a lot about how it
works, and what you need the Ada to do.

If you don't have access to the source, ask for it (it can't hurt).

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-10-31 18:06   ` björn lundin
@ 2014-11-04 18:24     ` kadrickhenderson008
  2014-11-05  9:06       ` Björn Lundin
  0 siblings, 1 reply; 11+ messages in thread
From: kadrickhenderson008 @ 2014-11-04 18:24 UTC (permalink / raw)


On Friday, October 31, 2014 2:06:58 PM UTC-4, björn lundin wrote:
> Den fredagen den 31:e oktober 2014 kl. 13:33:23 UTC+1 skrev björn lundin:
> > I'll see if I can find the usb-connecting code I did in Ada
> 
> 
> I found it, and put the binding, and a test program in dropbox
> 
> https://dl.dropboxusercontent.com/u/26175828/lib_usb_binding.zip
> 
> --
> Björn

This is awesome man. We were thinking of using a combination of Ada and python, since the PyUSB library allows easier communication to a USB. This resource is incredibly helpful. Thanks


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: USB Missile launcher
  2014-11-04 18:24     ` kadrickhenderson008
@ 2014-11-05  9:06       ` Björn Lundin
  0 siblings, 0 replies; 11+ messages in thread
From: Björn Lundin @ 2014-11-05  9:06 UTC (permalink / raw)


On 2014-11-04 19:24, kadrickhenderson008@yahoo.com wrote:
>> https://dl.dropboxusercontent.com/u/26175828/lib_usb_binding.zip

>This resource is incredibly helpful. Thanks

Nice to hear :-)


--
Björn


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-11-05  9:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29 17:43 USB Missile launcher kadrickhenderson008
2014-10-29 18:19 ` David Botton
2014-10-29 18:33   ` kadrickhenderson008
2014-10-29 18:42     ` kadrickhenderson008
2014-10-29 20:59 ` Dmitry A. Kazakov
2014-10-30 20:25 ` Jacob Sparre Andersen
2014-10-31 12:34 ` Björn Lundin
2014-10-31 18:06   ` björn lundin
2014-11-04 18:24     ` kadrickhenderson008
2014-11-05  9:06       ` Björn Lundin
2014-11-01 22:08 ` Stephen Leake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox