2 * Copyright (C) 2009 Ubixum, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <libusb-1.0/libusb.h>
26 int main(int argc
__attribute__((unused
)),
27 char **argv
__attribute__((unused
)))
29 int transferred
, rv
, i
, ret
= 1;;
30 libusb_device_handle
*hndl
;
32 unsigned char buf
[512];
37 hndl
= libusb_open_device_with_vid_pid(ctx
, 0x4b4, 0x8613);
40 fprintf(stderr
, "failed to open device\n");
44 libusb_claim_interface(hndl
, 0);
46 libusb_set_interface_alt_setting(hndl
, 0, 0);
49 for (i
= 0; i
< (int)sizeof(buf
); i
++)
52 printf("OUT transfer to device\n");
54 rv
= libusb_bulk_transfer(hndl
, 0x02, bufl
, 32, &transferred
, 500);
56 fprintf(stderr
, "OUT Transfer failed: %d (%d transferred)\n", rv
, transferred
);
60 rv
= libusb_bulk_transfer(hndl
, 0x02, buf
, 0, &transferred
, 500);
62 fprintf(stderr
, "OUT0 Transfer failed: %d (%d transferred)\n", rv
, transferred
);
66 printf("IN transfer to device\n");
68 memset(buf
, 0, sizeof(buf
));
71 rv
=libusb_bulk_transfer(hndl
, 0x86, (unsigned char*)buf
,sizeof(buf
), &transferred
, 500);
73 fprintf(stderr
, "IN Transfer failed: %d (%d transferred)\n", rv
, transferred
);
76 printf("received %d bytes:\n", transferred
);
78 for (i
= 0; i
< transferred
; i
++)
79 printf ("%02x ", buf
[i
]);