-
Notifications
You must be signed in to change notification settings - Fork 1
/
usb.c
40 lines (34 loc) · 1.14 KB
/
usb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright 2012-2015 Google Inc.
*
* 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; version 2 of the License.
*
* 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.
*/
#include <stdio.h>
#include "em100.h"
/* USB communication */
int send_cmd(libusb_device_handle *dev, void *data)
{
int actual;
int length = 16; /* haven't seen any other length yet */
libusb_bulk_transfer(dev, 1 | LIBUSB_ENDPOINT_OUT,
data, length, &actual, BULK_SEND_TIMEOUT);
return (actual == length);
}
int get_response(libusb_device_handle *dev, void *data, int length)
{
int actual;
libusb_bulk_transfer(dev, 2 | LIBUSB_ENDPOINT_IN,
data, length, &actual, BULK_SEND_TIMEOUT);
return actual;
}