Commit 4d621b43b3b9eb483cff01908320e88235fce6d2

Authored by achemin1
1 parent f6896773

ajout interface du 4.2

Showing 1 changed file with 20 additions and 2 deletions   Show diff stats
1 #include "libusb_wrapper.h" 1 #include "libusb_wrapper.h"
2 #include <stdio.h> 2 #include <stdio.h>
  3 +#include <string.h>
3 4
4 int main(int argc, char *argv[]){ 5 int main(int argc, char *argv[]){
5 printf("Hello World :-|\n"); 6 printf("Hello World :-|\n");
@@ -15,8 +16,25 @@ int main(int argc, char *argv[]){ @@ -15,8 +16,25 @@ int main(int argc, char *argv[]){
15 } 16 }
16 else if(strcmp(argv[1], "demo4.2") == 0){//if 4.2 17 else if(strcmp(argv[1], "demo4.2") == 0){//if 4.2
17 printf("\e[91mDemo 4.2\e[39m\n"); 18 printf("\e[91mDemo 4.2\e[39m\n");
18 - //displayDeviceEndpoints(Ourdevice);  
19 - //else 19 +
  20 + if(argc > 3){
  21 + uint16_t vendor_id;
  22 + uint16_t product_id;
  23 + sscanf(argv[2], "%hu", &vendor_id);
  24 + sscanf(argv[3], "%hu", &product_id);
  25 +
  26 + libusb_device_handle* handle;
  27 + handle = libusb_open_device_with_vid_pid(context, vendor_id, product_id);
  28 + if(handle != NULL){
  29 + printf("Show endpoints of VID:%hu;PID:%hu\n", vendor_id, product_id);
  30 + displayDeviceEndpoints(NULL);
  31 + }
  32 + else{
  33 + printf("Error while getting handle of VID:%hu;PID:%hu\n", vendor_id, product_id);
  34 + }
  35 + }else{
  36 + printf("Error, need VID and PID\n");
  37 + }
20 }else{ 38 }else{
21 printf("Wrong command\n"); 39 printf("Wrong command\n");
22 } 40 }