Last active
May 4, 2021 21:23
-
-
Save a1ien/2ecb1ede44d2e6210b2517a31d2c564a to your computer and use it in GitHub Desktop.
test.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <libusb.h> | |
#include <string.h> | |
int main(void) | |
{ | |
int r; | |
libusb_device_handle* handle = NULL; | |
uint8_t out_ep = 0x01; | |
uint8_t in_ep = 0x81; | |
int transferred = 0; | |
r = libusb_init(NULL); | |
if (r < 0) | |
return r; | |
handle = libusb_open_device_with_vid_pid( | |
NULL, | |
0x2FE3,0x09 | |
); | |
char buf[64] = {}; | |
memcpy(buf, "test", 4); | |
r = libusb_bulk_transfer( | |
handle, | |
out_ep, | |
buf, | |
4, | |
&transferred, | |
1000 | |
); | |
printf("%i, transfer %i\n", r, transferred); | |
r = libusb_bulk_transfer( | |
handle, | |
in_ep, | |
buf, | |
5, | |
&transferred, | |
1000 | |
); | |
printf("%i, transfer %i\n", r, transferred); | |
libusb_exit(NULL); | |
return 0; | |
} | |
// build gcc test.c `pkg-config --libs --cflags libusb-1.0` -o test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment