It works!

This commit is contained in:
Neale Pickett 2013-09-08 19:06:25 -06:00
parent bc38826f46
commit 22f6bc30de
2 changed files with 15 additions and 18 deletions

10
alsa.c
View File

@ -126,14 +126,4 @@ alsa_write(uint8_t *data, size_t datalen)
}
snd_seq_drain_output(snd_handle);
{
int i;
printf("A> ");
for (i = 0; i < datalen; i += 1) {
printf("%02x ", data[i]);
}
printf("\n");
}
}

23
usb.c
View File

@ -9,7 +9,7 @@
#include "dump.h"
static struct libusb_device_handle *usb_dev;
static struct libusb_transfer *xfer;
static struct libusb_transfer *xfer = NULL;
static const struct device *d;
uint8_t data[80];
@ -31,6 +31,9 @@ static void
usb_initiate_transfer()
{
// Tell libusb we want to know about bulk transfers
if (xfer) {
libusb_free_transfer(xfer);
}
xfer = libusb_alloc_transfer(0);
libusb_fill_bulk_transfer(xfer, usb_dev, d->ep_in, data, sizeof(data), usb_xfer_done, NULL, 0);
libusb_submit_transfer(xfer);
@ -43,7 +46,6 @@ usb_xfer_done(struct libusb_transfer *transfer)
int datalen = transfer->actual_length;
alsa_write(data, datalen);
usb_initiate_transfer();
}
@ -133,14 +135,19 @@ usb_check_fds(fd_set *rfds, fd_set *wfds)
}
}
void
usb_write_done(struct libusb_transfer *transfer)
{
libusb_free_transfer(transfer);
}
void
usb_write(uint8_t *data, size_t datalen)
{
int i;
struct libusb_transfer *xfer;
printf("U> ");
for (i = 0; i < datalen; i += 1) {
printf("%02x ", data[i]);
}
printf("\n");
xfer = libusb_alloc_transfer(0);
libusb_fill_bulk_transfer(xfer, usb_dev, d->ep_out, data, datalen, usb_write_done, NULL, 0);
libusb_submit_transfer(xfer);
}