Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Device::USB ubuntu 13.10 and bulk read write problem

by AlexSH (Initiate)
on Mar 14, 2014 at 12:51 UTC ( [id://1078323]=perlquestion: print w/replies, xml ) Need Help??

AlexSH has asked for the wisdom of the Perl Monks concerning the following question:

Hello

I'm install Device::USB from apt-get on my Ubuntu machine. I have usb device. With wireshark i get protocol from anower software. The protocol used to communicate bulktransfer

but when i try implement it with Device::USB i have no luck

#!/usr/bin/perl -w use strict; use Device::USB; my $usb = Device::USB->new(); my $dev = $usb->find_device( 0x2642,0x0669); printf "Device: %04X:%04X\n", $dev->idVendor(), $dev->idProduct(); $dev->open (); $dev->claim_interface(); $dev->set_configuration (0); my $cmd = $dev->{config}->[0]->{interfaces}->[0]->[0]->{endpoints}->[0 +]->{bEndpointAddress}; my $string = $dev->{config}->[0]->{interfaces}->[0]->[0]->{endpoints}- +>[1]->{bEndpointAddress}; my $data = $dev->{config}->[0]->{interfaces}->[0]->[0]->{endpoints}->[ +3]->{bEndpointAddress}; my $send = $dev->bulk_write($cmd,hex('dd'),1000); my $data; my $read = $dev->bulk_read($string,$data,64,1000); $read = $dev->bulk_read($string,$data,64,1000);

I can't see any output in wireshark. And i have $send =-1 and read='-1'

What i'm missing ?

PS sorry for English

Replies are listed 'Best First'.
Re: Device::USB ubuntu 13.10 and bulk read write problem
by jfroebe (Parson) on Mar 14, 2014 at 19:56 UTC

    Turn on debug mode to determine what if anything is happening:

    debug_mode This class method enables low-level debugging messages from the library interface code. level 0 disables debugging, 1 enables some debug messages, and 2 enables verbose debug messages Any other values are forced to the nearest endpoint. -- From Device::USB

    When dealing with USB devices directly, I would suspect permissions on the device file as the culprit in most cases.

    Jason L. Froebe

    Blog, Tech Blog

Re: Device::USB ubuntu 13.10 and bulk read write problem
by zentara (Archbishop) on Mar 15, 2014 at 11:32 UTC
    Update: see libusb and sync/asyc IO .

    I am happy to see this code, as I figure USB devices are going to proliferate. With only a small knowledge of how sockets work, and assuming USB would use a similar protocol, I'm guessing that you have a classic lockup condition, where both ends of the connection are trying to read, or trying to write, at the same time. Nothing gets thru.

    You need to get some sort of synchronization going, a protocol, like "over and out", means you are switching to listening, so the other end should now send.

    Possibly, just printing a few newlines on a line by themselves, would signal a protocol shift, by flushing the buffers, or whatever it is doing. I notice in the module's example code, they use alot of newlines. :-)


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Device::USB ubuntu 13.10 and bulk read write problem
by dasgar (Priest) on Mar 15, 2014 at 13:08 UTC

    I'm wondering if there may be an issue with the version of libusb installed on your system and Device::USB.

    Looking at Bug #90439 for Device::USB, someone was encountering "segfaults" and the module's maintainer suggested a possible work around of installing libusb 0.1. I realize that you're not hitting the exact same issue, but I'm just wondering if you might still be hitting an incompatibility between the code in Device::USB and your system's libusb.

Re: Device::USB ubuntu 13.10 and bulk read write problem
by AlexSH (Initiate) on Mar 15, 2014 at 19:41 UTC
    Thanks for all. I'm was stupid, it was permission error.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1078323]
Approved by vinoth.ree
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 19:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found