Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

How to Access USB Device on Windows

by einhverfr (Pilgrim)
on Nov 17, 2013 at 06:05 UTC ( #1062973=perlquestion: print w/ replies, xml ) Need Help??
einhverfr has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks

I am looking into the question of how to access a USB device using a cross-platform approach. The specific application is for pole displays and USB receipt printers' extended functionality (like opening cash drawers).

I see there is Device::USB for *nix but it seems to have a lot of test failures and I can't find an obvious solution for Windows users. Any ideas?

Comment on How to Access USB Device on Windows
Re: How to Access USB Device on Windows
by Anonymous Monk on Nov 17, 2013 at 07:41 UTC
      According to the Device::USB documentation the windows port is not supported. So it looks like my best option would be to contribute to that CPAN module?

        Ummm.....I'm not sure that I agree with interpretation.

        From the "Limitations" section of Device::USB:

        So far, this module has only been tested on Linux. It should work on any OS that supports the libusb library. Several people have reported problems compiling the module on Windows. In theory, it should be possible to make the library work with LibUsb-Win32 http://libusb-win32.sourceforge.net/. Without access to a Windows development system, I can't make those changes.

        That doesn't sound like "the windows port is not supported". If you read carefully, what it says is there have been reported issues on Windows, but that the maintainer does not have access to a Windows system. That's not the same thing as "not being supported". Also, I happen to know the maintainer of that module via Perl Mongers and I have heard him say on more than one occasion that he does not use Windows on his personal systems at home.

        Also, the "For More Information" section of Device::USB's documentation points to Google Code for a wiki. A quick look there turns up a wiki entry on how to install this on Windows with Strawberry Perl (see here). Granted, that entry appears to be at least 3 years old and doesn't mention which version of Windows, Strawberry Perl or Device::USB used. But there's at least one person who was able to install and use the module on Windows.

        If you're having issues with installing and/or using Device:USB, you can always report a new bug. Looking at the bugs report for that module (see here), someone submitted a new bug report within the past few days and the maintainer responded within 2 hours. Since the maintainer is actively responding to new bug reports, you could potentially get help with install issues directly from the maintainer via that method.

        In summary, I would try to install it and its prerequisites. If you have problems, you can post questions here at PerlMonks or you can submit a new bug report. As for portability and the need for libusb on Windows, my initial thoughts are that you should be able to package your script into an executable (using something like pp) so that your end users on Windows don't need Perl or libusb installed. I might be wrong about the packaging, but that's my gut reaction.

Re: How to Access USB Device on Windows
by taint (Chaplain) on Nov 17, 2013 at 20:11 UTC
    Greetings, einhverfr.

    My first thought when I saw your question was IO || IO. Maybe this comes from C experience. But would IO::Socket, IO::Pipe, IO::Select, or IO::Poll give you a sufficient handle to work with across different platforms? Or is it not low level enough?

    Best wishes

    --Chris

    #!/usr/bin/perl -Tw
    use Perl::Always or die;
    my $perl_version = (5.12.5);
    print $perl_version;
Re: How to Access USB Device on Windows
by dasgar (Deacon) on Nov 18, 2013 at 13:11 UTC

    Depending on how the device(s) show up in the OS and how the device(s) are designed to be communicated with, you might be able to use Win32::SerialPort for Windows and Device::SerialPort for non-Windows systems. I believe that the syntax of the two modules is very similar.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-12-20 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls