Bonjour,

Je tourne vers votre communauté afin de trouver des réponses à mon problème.
J'essaye de récupérer les données prise par un tensiomètre qui est connecté en USB à l'ordinateur.
Je tiens à préciser qu'il existe un logiciel propriétaire qui récupère les données sous Windows mais fonctionnant sous Linux il n'existe aucun équivalent. Ainsi j'ai réaliser un petit programme permettant de récupérer ses données mais la commande USB_interrupt_write() me retourne l'erreur "-110 Connection timed out"

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <stdio.h>
#include <usb.h>
#include <string.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
 
 
const int IDPRODUCT = 0x0028;
const int IDVENDOR = 0x0590;
 
struct usb_bus *bus;
struct usb_device *appareil;
 
void driver_init(void) {               
    usb_init();                   
    usb_find_busses();             
    usb_find_devices();            
}
 
struct usb_device *usb_find_device(int idV, int idP) {
    printf("\n -- Recherche de l'USB (%04X|%04X) -- \n", idV, idP);
    for (bus = usb_busses; bus; bus = bus->next) { 
        for (appareil = bus->devices; appareil; appareil = appareil->next) { 
            if ((appareil->descriptor.idVendor == idV) && (appareil->descriptor.idProduct ==idP )) { 
                printf("     * Trouver\n");
                return(appareil);
            }
        }
    }
    printf("       ! Absent\n");
    return(0);
}
 
void resetDevice(usb_dev_handle *hdl) { 
    printf("\n -- Reset appareil -- \n");
    if (usb_reset(hdl)<0) printf("       ! Echec du reset !\n"); else printf("     * Fait\n");
 
}
 
void initDevice(usb_dev_handle *hdl){
	int ret;
	char donnee[8];
	memset(&donnee[0], 0, sizeof(donnee));
	donnee[0] = 0x01;
	donnee[1] = 0x01;
 
	ret = usb_interrupt_write(hdl,0x02,donnee,sizeof(donnee),8);
	printf("\n -- Init appareil -- \n");
	printf("     * ret %d \n ",ret); 
}
 
int main (void) {
    char str[100];
 
    // *************  Initialise le port usb *************
    driver_init();
 
    // *************  Recherche de l'apparei *************
    struct usb_device *tensiometre = usb_find_device(IDVENDOR, IDPRODUCT);  
        if (tensiometre ==0) {  // si on ne l'a pas trouvé ...
        printf("       ! Tensiometre mal branche !\n");
        return 0;
    }   
 
    // *************  Ouverture de l'appareil *************
    printf("\n -- Ouverture du port USB (Vendor, Product) = (0x%04X,  0x%04X) --\n", tensiometre->descriptor.idVendor, tensiometre->descriptor.idProduct);
    usb_dev_handle *tensiometreHandle = usb_open(tensiometre);  
    if (!tensiometreHandle) {
        printf("       ! Echec de l'ouveture !\n");
        return 0;
    } else printf("     * Appareil ouvert ");
    usb_get_string_simple(tensiometreHandle, 1, &str[0], 50) >=0 ? printf("\n       * %s", str) :printf("\n       ! Echec de la recuperation du NOM !\n");
 
 
    // *************  Opérations sur l'appareil *************
    resetDevice(tensiometreHandle);
    initDevice(tensiometreHandle);
 
}

Sachant que les endpoints ont comme descriptions :
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 10

La séquence d'initialisation est 01 01 (séquence trouver grâce à un sniffeur USB sous Windows lors d'une récupération de mesure).
Je précise aussi que le code est exécute en mode ROOT pour n'avoir pas les problèmes d'accès au port USB.

Alors si quelqu'un a une réponse pour palier à mon problème je suis preneur
Merci