Bon, ça me travaille cette histoire de matériel USB non compatible Fedora (Linux) 😉
Je viens de récupérer un fichier C++ pour analyser un port usb sous Linux :
http://www.cppfrance.com/codes/SCANNER-PORTS-USB-SOUS-LINUX_38102.aspx
/*
* Main
*
* Written by:
* Copyright 2006, Yasmin OROU GUIDOU <ogyasmin@yahoo.fr>
*
* USB
*/
#include <stdio.h>
#include <usb.h>
#include <errno.h> // Bibliothèque des erreurs.
struct usb_bus *busses;
struct usb_bus *bus;
struct usb_device *dev,*fdev;
usb_dev_handle *device_handle = 0;
void driver_init(void)
{
usb_init(); //Initialisation de la librairie (par example determine le chemin du repertoire des bus et peripheriques)
usb_find_busses(); // Enumère tous les bus USB du systemes
usb_find_devices();// Enumère tous les peripheriques sur tous les Bus présents)
// Parcours de la liste des bus et des périphériques
}
void usb_scan(void)
{
for (bus = usb_busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
printf("bus : %s Device %s \n id Vendor: %d | id Product : %d | Manufacturer Name : | Product Name : \n", bus->dirname,dev->filename ,dev->descriptor.idVendor,dev->descriptor.idProduct); // dev->descriptor.iManufacturer,dev->descriptor.iProduct ( Vous pouvez ajouter ces infos mais si les périphériques n'ont pas fournit au système les info il y aura erreur de segmentation
}
}
}
struct usb_device *usb_find_My_device(int idV, int idP)
{
for (bus = usb_busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
// condition vérifié si c'est un Mon flash disque iProduct=Flash Disk
if ((dev->descriptor.idVendor == idV) && (dev->descriptor.idProduct ==idP )) //Caract de ma clé USB32 idV=0x0ea0 idP=0x2168
return(dev);
}
}
return(0);
}
int main (void)
{
int send_status;
int open_status;
unsigned char send_data=0xff;
unsigned char receive_data=0;
driver_init();
usb_scan();
return 0;
}
J'ai donc nommé ce fichier "scan_usb.cpp",
mais quand je lance la commande ci-dessous... des erreurs la suive 🙂 :
[did@cool Scanner_USB]$ g++ -o test scan_usb.cpp -lusb
scan_usb.cpp:10:17: erreur: usb.h : Aucun fichier ou dossier de ce type
scan_usb.cpp:17: erreur: expected constructor, destructor, or type conversion before '*' token
scan_usb.cpp: In function 'void driver_init()':
scan_usb.cpp:20: erreur: 'usb_init' was not declared in this scope
scan_usb.cpp:21: erreur: 'usb_find_busses' was not declared in this scope
scan_usb.cpp:22: erreur: 'usb_find_devices' was not declared in this scope
scan_usb.cpp: In function 'void usb_scan()':
scan_usb.cpp:27: erreur: 'usb_busses' was not declared in this scope
scan_usb.cpp:27: erreur: invalid use of incomplete type 'struct usb_bus'
scan_usb.cpp:14: erreur: forward declaration of 'struct usb_bus'
scan_usb.cpp:29: erreur: invalid use of incomplete type 'struct usb_bus'
scan_usb.cpp:14: erreur: forward declaration of 'struct usb_bus'
scan_usb.cpp:29: erreur: invalid use of incomplete type 'struct usb_device'
scan_usb.cpp:16: erreur: forward declaration of 'struct usb_device'
scan_usb.cpp:31: erreur: invalid use of incomplete type 'struct usb_bus'
scan_usb.cpp:14: erreur: forward declaration of 'struct usb_bus'
scan_usb.cpp:31: erreur: invalid use of incomplete type 'struct usb_device'
scan_usb.cpp:16: erreur: forward declaration of 'struct usb_device'
scan_usb.cpp:31: erreur: invalid use of incomplete type 'struct usb_device'
scan_usb.cpp:16: erreur: forward declaration of 'struct usb_device'
scan_usb.cpp:31: erreur: invalid use of incomplete type 'struct usb_device'
scan_usb.cpp:16: erreur: forward declaration of 'struct usb_device'
scan_usb.cpp: In function 'usb_device* usb_find_My_device(int, int)':
scan_usb.cpp:37: erreur: 'usb_busses' was not declared in this scope
scan_usb.cpp:37: erreur: invalid use of incomplete type 'struct usb_bus'
scan_usb.cpp:14: erreur: forward declaration of 'struct usb_bus'
scan_usb.cpp:39: erreur: invalid use of incomplete type 'struct usb_bus'
scan_usb.cpp:14: erreur: forward declaration of 'struct usb_bus'
scan_usb.cpp:39: erreur: invalid use of incomplete type 'struct usb_device'
scan_usb.cpp:16: erreur: forward declaration of 'struct usb_device'
scan_usb.cpp:42: erreur: invalid use of incomplete type 'struct usb_device'
scan_usb.cpp:16: erreur: forward declaration of 'struct usb_device'
scan_usb.cpp:42: erreur: invalid use of incomplete type 'struct usb_device'
scan_usb.cpp:16: erreur: forward declaration of 'struct usb_device'
Je précise que
libusb est bien installé.
J'ai essayé de modifier la 1ère erreur en modifiant l'accès à "usb.h"
scan_usb.cpp:10:17: erreur: usb.h : Aucun fichier ou dossier de ce type
en mettant ce chemin à la place dans mon fichier "scan_usb.cpp" :
#include </usr/src/kernels/2.6.26.5-45.fc9.i686/include/config/usb.h>
mais ça ne marche pas !
Et comme ça fait bien 15 ans que je n'ai plus programmé en C et que c'était sur l'Atari... vous m'avez compris 🙂
Je ne saisis pas bien l'accès aux librairies...
Pouvez-vous m'aider ?