|
From: abdullah u. <abd...@ya...> - 2014-04-11 19:45:34
|
Tim,
Thank you for your reply.
I have arranged all the endpoints by checking via lsusb, w.r.t. isochronous mode.
I want to learn isochronous because audio device is for only a current project,
projects varies from audio to RF etc.
I tried every example I found in web, checked all the end point descriptors, transfer modes, bLength
parameters.
Additionally, I have run Valgrind for my program, I got "... possibly lost in loss records..." message.
I used Code::Blocks to implement the program.
The header file I implemented as follows:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include </usr/include/libusb-1.0/libusb.h>
#include<vector>
#ifndef CUSBREADWRITE_H
#define CUSBREADWRITE_H
// SoundBlaster / Creative Technology
//----------------------------------------------------
// adres 0x81 için
//#define EndPointISOAudioAddressIn 0x81
//#define EndPointISOIn EndPointISOAudioAddressIn
//#define MaxPacketSizeAudioIn 0x0003
// adres 0x82 için
//#define EndPointISOAudioAddressIn 0x82
//#define MaxPacketSizeAudioIn 0x00c4
//#define MaxPacketSizeAudioIn 0x0126
//#define MaxPacketSizeAudioIn 0x0184
//#define MaxPacketSizeAudioIn 0x0246
#define bLengthISOAudioIn 9
//----------------------------------------------------
// SoundBlaster / Creative Technology
// LG_WebCam
//----------------------------------------------------
// adres 0x81 için
#define EndPointISOVideoAddressIn 0x81
//#define EndPointISOIn EndPointISOVideoAddressIn
#define MaxPacketSizeVideoIn 0x0080
//#define MaxPacketSizeVideoIn 0x0100
//#define MaxPacketSizeVideoIn 0x0320
//#define MaxPacketSizeVideoIn 0x0b20
//#define MaxPacketSizeVideoIn 0x1320
//#define MaxPacketSizeVideoIn 0x1400
#define bLengthISOVideoIn 7
//----------------------------------------------------
// LG_WebCam
using namespace std;
class CusbReadWrite
{
public:
int i;
int e;// usb aygıtıyla bağlantı kontrolü
int bytes_read;
int nbytes;
//int transferred;
libusb_transfer *xfr;
libusb_device **devs; //pointer to pointer of device, used to retrieve a list of devices
libusb_device_handle *dev_Rx_handle; //a device handle
libusb_device_handle *dev_Tx_handle; //a device handle
libusb_context *ctx; //a libusb session
int r; //for return values
ssize_t cnt; //holding number of devices in list
libusb_device_descriptor desc_Rx;
libusb_device_descriptor desc_Tx;
libusb_device_descriptor desc;
vector<libusb_device_descriptor> desc_buffer;
int usb_ind; // index of the usb device to receive data from
CusbReadWrite();
void ReadWriteDataViaUSBDev();
virtual ~CusbReadWrite();
protected:
private:
int i2;
// audio
//unsigned char data_received[bLengthISOAudioIn];
// video
unsigned char data_received[bLengthISOVideoIn];
//unsigned char data_received[bLengthISOAudioIn];
unsigned char data2transmit[7];
static void iso_callback(struct libusb_transfer *transfer);
int MaxPacketSizeIn;
unsigned char EndPointISOIn;
};
#endif // CUSBREADWRITE_H
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
class (cpp) file is below for 1st program:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include<cassert>
#include<errno.h>
#include <stdio.h>
#include <string.h>
#include </usr/include/libusb-1.0/libusb.h>
//#include<usb.h>
#include<iostream>
#include<vector>
#include<sys/types.h>
#include<stdlib.h>
#include<sys/ioctl.h>
#include "CusbReadWrite.h"
using namespace std;
CusbReadWrite::CusbReadWrite()
{
//ctor
// Video
EndPointISOIn=EndPointISOVideoAddressIn;
MaxPacketSizeIn=MaxPacketSizeVideoIn;
// Audio
//MaxPacketSizeIn=MaxPacketSizeAudioIn;
//EndPointISOIn=EndPointISOAudioAddressIn;
}
CusbReadWrite::~CusbReadWrite()
{
//dtor
}
// USB aygıtından veri okunması
void CusbReadWrite::ReadWriteDataViaUSBDev()
{
//ctor
i=0;
libusb_context *ctx = NULL; //a libusb session
//*ctx = NULL; //a libusb session
r = libusb_init(&ctx); //initialize the library for the session we just declared
if(r < 0) {
cout<<"Atama hatası oluşmuştur "<<r<<endl; //there was an error
//return 1;
}
else cout<<"ctx : "<<ctx<<endl;
libusb_set_debug(ctx, 3); //set verbosity level to 3, as suggested in the documentation
cout<<"ctx : "<<ctx<<endl;
cnt = libusb_get_device_list(ctx, &devs); //get the list of devices
if(cnt < 0) {
cout<<"Hata oluştu, USB aygıtlarınızı kontrol ediniz"<<endl; //there was an error
//return 1;
}
cout<<"Tespit edilen USB aygıt sayısı > "<<cnt<<endl;
desc={0};
for(i=0;i<cnt;i++){
//cout<<"Device # : "<<i<<endl;
libusb_device *device = devs[i];
desc={0};
r = libusb_get_device_descriptor(device, &desc);
assert(r == 0);
desc_buffer.push_back(desc);
//printf("Vendor:Device = %04x:%04x\n", desc.idVendor, desc.idProduct);
//printf("Vendor:Device = %x:%x\n", desc.idVendor, desc.idProduct);
}
// Veri alımı için USB aygıt belirlenmesi
i=0;
e=0;
cout<<"Aktif USB aygıt listesi :"<<endl;
for(i=0;i<cnt;i++)
{
cout<<i<<". Ürün / Bayii Numarası : "<<desc_buffer.at(i).idProduct<<" / "<<desc_buffer.at(i).idVendor<<endl;
}
cout<<"Lütfen veri alımı için kullanacağınız USB aygıtının sırasını belirtiniz"<<endl;
cin>>usb_ind;
if(0<=usb_ind&&usb_ind<cnt)
{
desc_Rx=desc_buffer.at(usb_ind);
cout<<"USB aygıt bilgileri ( Ürün / Bayii Numarası ) : "<<desc_Rx.idProduct<<" / "<<desc_Rx.idVendor<<endl;
}
else cout<<"Hatalı giriş yaptınız."<<endl;
cout<<"ctx"<<ctx<<endl;
//cout<<"USB aygıt bilgileri ( Ürün / Bayii Numarası ) : "<<desc.idProduct<<" / "<<desc.idVendor<<endl;
dev_Rx_handle = libusb_open_device_with_vid_pid(ctx, desc_Rx.idVendor, desc_Rx.idProduct); //these are vendorID and productID I found for my usb device
cout<<"dev_handle"<<dev_Rx_handle<<endl;
if(dev_Rx_handle == NULL)
{
cout<<"Veri alımında USB aygıtına erişimde hata oluştu."<<endl;
}
else cout<<"Veri alımında USB aygıtı kullanılabilir."<<endl;
libusb_set_configuration(dev_Rx_handle,1);
if(libusb_kernel_driver_active(dev_Rx_handle, 0) != 0)
{
cout<<"Kernel sürücüsü aktif durumda."<<endl;
// if(libusb_detach_kernel_driver(dev_Rx_handle, 0) == 0)
// cout<<"Kernel sürücüsü durduruldu."<<endl;
libusb_detach_kernel_driver(dev_Rx_handle, 0);
cout<<"Kernel sürücüsü durduruldu."<<endl;
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
}
else cout<<"Kernel sürücüsü kullanılabilir"<<endl;
e = libusb_claim_interface(dev_Rx_handle, 0);
//cout<<"e : "<<e<<endl;
cout<<"dev_Rx_handle interface kurulumu : "<<libusb_error_name(e)<<endl;
// Veri iletişimi
//transferred = 0;
//xfr=libusb_alloc_transfer(sizeof(data_received));
xfr=libusb_alloc_transfer(MaxPacketSizeIn);
// xfr=libusb_alloc_transfer(sizeof(data_received)/sizeof(unsigned char));
if(!xfr)
{
cout<<"Veri alımı için gerekli hafıza ayrılamamıştır"<<endl;
cout<<"xfr : "<<xfr<<endl;
cout<<"Hata : "<<ENOMEM<<" - OUT OF MEMORY"<<endl;
}
else
{
cout<<"Veri alımı için gerekli bellek başarıyla ayrılmıştır"<<endl;
cout<<"Veri alımı için transfer adresi - xfr : "<<xfr<<endl;
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
cout<<"ctx"<<ctx<<endl;
}
for(i=0;i<20;i++)
{
// e=libusb_clear_halt( dev_Rx_handle, EndPointISOIn);
//
// if(e==LIBUSB_SUCCESS)
// cout<<"USB aygıtıyla iletişim gerçekleştirilmekte"<<endl;
// else cout<<"Hata : "<<libusb_error_name(e)<<endl;
//cout<<"Veri alımı için transfer adresi - xfr : "<<xfr<<endl;
//libusb_fill_iso_transfer(xfr, devh, ep, buf,sizeof(buf), num_iso_pack, cb_xfr, NULL, 0);
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
cout<<"ctx"<<ctx<<endl;
libusb_fill_iso_transfer(xfr, dev_Rx_handle, EndPointISOIn, data_received,sizeof(data_received),
MaxPacketSizeIn, iso_callback, NULL, 0);
// libusb_fill_iso_transfer(xfr, dev_Rx_handle, EndPointISOIn, data_received,MaxPacketSizeIn,
// sizeof(data_received), iso_callback, NULL, 10000);
//cout<<"flag fill"<<endl;
//libusb_set_iso_packet_lengths( xfr, sizeof(data_received)/sizeof(unsigned char) );
libusb_set_iso_packet_lengths( xfr, MaxPacketSizeIn );
//cout<<"flag set"<<endl;
e=libusb_submit_transfer(xfr);
//printf( "%d\n", errno );
cout<<"i : "<<i<<endl;
if(e==LIBUSB_SUCCESS)
cout<<"USB aygıtıyla iletişim gerçekleştirilmekte"<<endl;
else cout<<"Hata : "<<libusb_error_name(e)<<endl;
}
//cout<<"xfr free"<<endl;
libusb_free_transfer(xfr);
//cout<<"release dev rx handle"<<endl;
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
e = libusb_release_interface(dev_Rx_handle, 0);
cout<<"dev_Rx_handle release interface : "<<libusb_error_name(e)<<endl;
libusb_close(dev_Rx_handle);
cout<<"dev_Rx_handle close : "<<libusb_error_name(e)<<endl;
libusb_free_device_list(devs, 1); //free the list, unref the devices in it
//cout<<"exit ctx"<<endl;
cout<<"ctx"<<ctx<<endl;
libusb_exit(ctx);
}
void CusbReadWrite::iso_callback(struct libusb_transfer *transfer){
int i;
int buf_index=0;
printf("iso_callback called :: num_iso_packets=%d, endpoint=%#x, actual_length(invalid)=%d, buffer=%p\n",
transfer->num_iso_packets, transfer->endpoint, transfer->actual_length, transfer->buffer);
for (i = 0; i < transfer->num_iso_packets; i++) {
struct libusb_iso_packet_descriptor *desc = &transfer->iso_packet_desc[i];
// print_bytes((char*) desc, sizeof(struct libusb_iso_packet_descriptor));
// printf("\n");
#if 0
unsigned char *pbuf = transfer->buffer + buf_index;
buf_index+=desc->length;
printf(" desc->length=%d, desc->actual_length=%d, desc->status=%#x\n", desc->length, desc->actual_length, desc->status);
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
cout<<"ctx"<<ctx<<endl;
// if (desc->actual_length != 0) {
// printf("isopacket %d received %d bytes:\n", i, desc->actual_length);
// print_bytes(pbuf, desc->actual_length);
// }
#endif
}
//libusb_free_transfer(transfer);
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
the second program, class (cpp) file - implemented after reading the discussion:
LibUSB Dev - "memory leak" debug message after libusb_close, and upon application exit.
LibUSB Dev - "memory leak" debug message after libusb_cl...
"memory leak" debug message after libusb_close, and upon application exit. I've been debugging my Windows App using 1.0.8 the libusb library. Upon exit, using ...
View on libusb.6.n5.nabble.com Preview by Yahoo
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include<cassert>
#include<errno.h>
#include <stdio.h>
#include <string.h>
#include </usr/include/libusb-1.0/libusb.h>
//#include<usb.h>
#include<iostream>
#include<vector>
#include<sys/types.h>
#include<stdlib.h>
#include<sys/ioctl.h>
#include "CusbReadWrite.h"
using namespace std;
CusbReadWrite::CusbReadWrite()
{
//ctor
// Video
EndPointISOIn=EndPointISOVideoAddressIn;
MaxPacketSizeIn=MaxPacketSizeVideoIn;
// Audio
//MaxPacketSizeIn=MaxPacketSizeAudioIn;
//EndPointISOIn=EndPointISOAudioAddressIn;
}
CusbReadWrite::~CusbReadWrite()
{
//dtor
}
// USB aygıtından veri okunması
void CusbReadWrite::ReadWriteDataViaUSBDev()
{
//ctor
i=0;
libusb_context *ctx = NULL; //a libusb session
//*ctx = NULL; //a libusb session
r = libusb_init(&ctx); //initialize the library for the session we just declared
if(r < 0) {
cout<<"Atama hatası oluşmuştur "<<r<<endl; //there was an error
//return 1;
}
else cout<<"ctx : "<<ctx<<endl;
libusb_set_debug(ctx, 3); //set verbosity level to 3, as suggested in the documentation
cout<<"ctx : "<<ctx<<endl;
cnt = libusb_get_device_list(ctx, &devs); //get the list of devices
if(cnt < 0) {
cout<<"Hata oluştu, USB aygıtlarınızı kontrol ediniz"<<endl; //there was an error
//return 1;
}
cout<<"Tespit edilen USB aygıt sayısı > "<<cnt<<endl;
desc={0};
for(i=0;i<cnt;i++){
//cout<<"Device # : "<<i<<endl;
libusb_device *device = devs[i];
desc={0};
r = libusb_get_device_descriptor(device, &desc);
assert(r == 0);
desc_buffer.push_back(desc);
//printf("Vendor:Device = %04x:%04x\n", desc.idVendor, desc.idProduct);
//printf("Vendor:Device = %x:%x\n", desc.idVendor, desc.idProduct);
}
// Veri alımı için USB aygıt belirlenmesi
i=0;
e=0;
cout<<"Aktif USB aygıt listesi :"<<endl;
for(i=0;i<cnt;i++)
{
cout<<i<<". Ürün / Bayii Numarası : "<<desc_buffer.at(i).idProduct<<" / "<<desc_buffer.at(i).idVendor<<endl;
}
cout<<"Lütfen veri alımı için kullanacağınız USB aygıtının sırasını belirtiniz"<<endl;
cin>>usb_ind;
if(0<=usb_ind&&usb_ind<cnt)
{
desc_Rx=desc_buffer.at(usb_ind);
cout<<"USB aygıt bilgileri ( Ürün / Bayii Numarası ) : "<<desc_Rx.idProduct<<" / "<<desc_Rx.idVendor<<endl;
}
else cout<<"Hatalı giriş yaptınız."<<endl;
cout<<"ctx"<<ctx<<endl;
//cout<<"USB aygıt bilgileri ( Ürün / Bayii Numarası ) : "<<desc.idProduct<<" / "<<desc.idVendor<<endl;
dev_Rx_handle = libusb_open_device_with_vid_pid(ctx, desc_Rx.idVendor, desc_Rx.idProduct); //these are vendorID and productID I found for my usb device
cout<<"dev_handle"<<dev_Rx_handle<<endl;
if(dev_Rx_handle == NULL)
{
cout<<"Veri alımında USB aygıtına erişimde hata oluştu."<<endl;
}
else cout<<"Veri alımında USB aygıtı kullanılabilir."<<endl;
libusb_set_configuration(dev_Rx_handle,1);
if(libusb_kernel_driver_active(dev_Rx_handle, 0) != 0)
{
cout<<"Kernel sürücüsü aktif durumda."<<endl;
// if(libusb_detach_kernel_driver(dev_Rx_handle, 0) == 0)
// cout<<"Kernel sürücüsü durduruldu."<<endl;
libusb_detach_kernel_driver(dev_Rx_handle, 0);
cout<<"Kernel sürücüsü durduruldu."<<endl;
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
}
else cout<<"Kernel sürücüsü kullanılabilir"<<endl;
e = libusb_claim_interface(dev_Rx_handle, 0);
//cout<<"e : "<<e<<endl;
cout<<"dev_Rx_handle interface kurulumu : "<<libusb_error_name(e)<<endl;
// Veri iletişimi
//transferred = 0;
//xfr=libusb_alloc_transfer(sizeof(data_received));
// xfr=libusb_alloc_transfer(MaxPacketSizeIn);
//
//// xfr=libusb_alloc_transfer(sizeof(data_received)/sizeof(unsigned char));
//
//
// if(!xfr)
// {
// cout<<"Veri alımı için gerekli hafıza ayrılamamıştır"<<endl;
// cout<<"xfr : "<<xfr<<endl;
// cout<<"Hata : "<<ENOMEM<<" - OUT OF MEMORY"<<endl;
//
// }
// else
// {
// cout<<"Veri alımı için gerekli bellek başarıyla ayrılmıştır"<<endl;
// cout<<"Veri alımı için transfer adresi - xfr : "<<xfr<<endl;
// cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
// cout<<"ctx"<<ctx<<endl;
// }
i=0;
i2=0;
for(i=0;i<20;i++)
{
libusb_context *ctx = NULL; //a libusb session
//*ctx = NULL; //a libusb session
r = libusb_init(&ctx); //initialize the library for the session we just declared
if(r < 0) {
cout<<"Atama hatası oluşmuştur "<<r<<endl; //there was an error
//return 1;
}
else cout<<"ctx : "<<ctx<<endl;
libusb_set_debug(ctx, 3); //set verbosity level to 3, as suggested in the documentation
cout<<"ctx : "<<ctx<<endl;
cnt = libusb_get_device_list(ctx, &devs); //get the list of devices
if(cnt < 0) {
cout<<"Hata oluştu, USB aygıtlarınızı kontrol ediniz"<<endl; //there was an error
//return 1;
}
//cout<<"Tespit edilen USB aygıt sayısı > "<<cnt<<endl;
desc={0};
for(i2=0;i2<cnt;i2++){
//cout<<"Device # : "<<i<<endl;
libusb_device *device = devs[i2];
desc={0};
r = libusb_get_device_descriptor(device, &desc);
assert(r == 0);
desc_buffer.push_back(desc);
}
dev_Rx_handle = libusb_open_device_with_vid_pid(ctx, desc_Rx.idVendor, desc_Rx.idProduct); //these are vendorID and productID I found for my usb device
if(dev_Rx_handle == NULL)
{
cout<<"Veri alımında USB aygıtına erişimde hata oluştu."<<endl;
}
//else cout<<"Veri alımında USB aygıtı kullanılabilir."<<endl;
libusb_set_configuration(dev_Rx_handle,1);
if(libusb_kernel_driver_active(dev_Rx_handle, 0) != 0)
{
cout<<"Kernel sürücüsü aktif durumda."<<endl;
// if(libusb_detach_kernel_driver(dev_Rx_handle, 0) == 0)
// cout<<"Kernel sürücüsü durduruldu."<<endl;
libusb_detach_kernel_driver(dev_Rx_handle, 0);
cout<<"Kernel sürücüsü durduruldu."<<endl;
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
}
//else cout<<"Kernel sürücüsü kullanılabilir"<<endl;
e = libusb_claim_interface(dev_Rx_handle, 0);
//cout<<"e : "<<e<<endl;
//cout<<"dev_Rx_handle interface kurulumu : "<<libusb_error_name(e)<<endl;
// Veri iletişimi
//transferred = 0;
//xfr=libusb_alloc_transfer(sizeof(data_received));
xfr=libusb_alloc_transfer(MaxPacketSizeIn);
// xfr=libusb_alloc_transfer(sizeof(data_received)/sizeof(unsigned char));
if(!xfr)
{
cout<<"Veri alımı için gerekli hafıza ayrılamamıştır"<<endl;
cout<<"xfr : "<<xfr<<endl;
cout<<"Hata : "<<ENOMEM<<" - OUT OF MEMORY"<<endl;
}
else
{
cout<<"Veri alımı için gerekli bellek başarıyla ayrılmıştır"<<endl;
cout<<"Veri alımı için transfer adresi - xfr : "<<xfr<<endl;
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
cout<<"ctx"<<ctx<<endl;
}
// cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
//cout<<"ctx"<<ctx<<endl;
libusb_fill_iso_transfer(xfr, dev_Rx_handle, EndPointISOIn, data_received,sizeof(data_received),
MaxPacketSizeIn, iso_callback, NULL, 0);
// libusb_fill_iso_transfer(xfr, dev_Rx_handle, EndPointISOIn, data_received,MaxPacketSizeIn,
// sizeof(data_received), iso_callback, NULL, 10000);
//cout<<"flag fill"<<endl;
//libusb_set_iso_packet_lengths( xfr, sizeof(data_received)/sizeof(unsigned char) );
libusb_set_iso_packet_lengths( xfr, MaxPacketSizeIn );
//cout<<"flag set"<<endl;
e=libusb_submit_transfer(xfr);
//printf( "%d\n", errno );
//cout<<"i : "<<i<<endl;
if(e==LIBUSB_SUCCESS)
cout<<"USB aygıtıyla iletişim gerçekleştirilmekte"<<endl;
else cout<<"Hata : "<<libusb_error_name(e)<<endl;
libusb_free_transfer(xfr);
//cout<<"release dev rx handle"<<endl;
//cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
e = libusb_release_interface(dev_Rx_handle, 0);
//cout<<"dev_Rx_handle release interface : "<<libusb_error_name(e)<<endl;
libusb_close(dev_Rx_handle);
//cout<<"dev_Rx_handle close : "<<libusb_error_name(e)<<endl;
libusb_free_device_list(devs, 1); //free the list, unref the devices in it
//cout<<"exit ctx"<<endl;
//cout<<"ctx"<<ctx<<endl;
libusb_exit(ctx);
}
}
void CusbReadWrite::iso_callback(struct libusb_transfer *transfer){
int i;
int buf_index=0;
printf("iso_callback called :: num_iso_packets=%d, endpoint=%#x, actual_length(invalid)=%d, buffer=%p\n",
transfer->num_iso_packets, transfer->endpoint, transfer->actual_length, transfer->buffer);
for (i = 0; i < transfer->num_iso_packets; i++) {
struct libusb_iso_packet_descriptor *desc = &transfer->iso_packet_desc[i];
// print_bytes((char*) desc, sizeof(struct libusb_iso_packet_descriptor));
// printf("\n");
#if 0
unsigned char *pbuf = transfer->buffer + buf_index;
buf_index+=desc->length;
printf(" desc->length=%d, desc->actual_length=%d, desc->status=%#x\n", desc->length, desc->actual_length, desc->status);
cout<<"dev_rx_handle : "<<dev_Rx_handle<<endl;
cout<<"ctx"<<ctx<<endl;
// if (desc->actual_length != 0) {
// printf("isopacket %d received %d bytes:\n", i, desc->actual_length);
// print_bytes(pbuf, desc->actual_length);
// }
#endif
}
//libusb_free_transfer(transfer);
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
the main program:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/*
* testlibusb.c
*
* Test suite program
*/
#include<cassert>
#include <stdio.h>
#include <string.h>
#include </usr/include/libusb-1.0/libusb.h>
//#include<usb.h>
#include<iostream>
#include<sys/ioctl.h>
#include "CusbReadWrite.h"
using namespace std;
int main() {
cout<<"Hello world"<<endl;
// initializing the USB devices connected to the PC
CusbReadWrite my_usb_init_elem;
//CReadDataFromUSB my_usb_init_elem;
int i=0;
//for(i=0;i<my_usb_init_elem.desc_buffer.size();i++) cout<<"Product ID :"<<my_usb_init_elem.desc_buffer.at(i).idProduct<<endl;
my_usb_init_elem.ReadWriteDataViaUSBDev();
//my_usb_init_elem.readDataFromUSBDev();
//cout<<"flag main"<<endl;
//libusb_free_device_list(my_usb_init_elem.devs, 1); //free the list, unref the devices in it
return 0;
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
the main program is same for both.
I am having errno = 2 for both of the programs.
By the way, output of Valgrind points r = libusb_init(&ctx);
Thank you for your time.
Regards,
Abdullah
On Friday, April 11, 2014 2:11 PM, Tim Roberts <ti...@pr...> wrote:
mau wrote:
> I am a newbie in libusb, have been trying to implement isochronous
> communication to acquire data continuously from an audio device.
Is there a reason why you can't use the stock system driver and the
normal system audio APIs to do this? Doing isochronous is not easy.
> When I tried interrupt mode, I got no error in real time. But while I tried
> to implement isochronous transfer, I have been getting a run time error :
Did you change the endpoint type in the descriptors? You can't do
isochronous transfers on an interrupt endpoint. The transfers have to
match the endpoint type.
> [submit_iso_transfer] submiturb failed error -1 errno:16
>
> I have been getting the libusb error enum printed: LIBUSB_ERROR_IO
>
> I tried all the end point descirptor, max packet size and bLengths groups,
> but the result does not change.
>
> Might it be related to the kernel; I saw similar problems caused by the
> kernel?
None of us has a crystal ball. Please show us your code and your
descriptors, and we'll see what you might be doing wrong.
By the way, NEVER blame the kernel first. The kernel isn't bug-free,
but if you're just starting out, the odds are infinitesimally small that
your problem is a kernel or operating system bug.
--
Tim Roberts, ti...@pr...
Providenza & Boekelheide, Inc.
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
libusb-devel mailing list
lib...@li...
https://lists.sourceforge.net/lists/listinfo/libusb-devel |