Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: interface with USB and perl

by Corion (Patriarch)
on Jan 15, 2003 at 09:45 UTC ( [id://227106]=note: print w/replies, xml ) Need Help??


in reply to interface with USB and perl

First of all, look if your MiniDisk vendor has a file system driver for the player. Then you can simply use Perl to copy the tracks off and onto your player.

Most likely though, your vendor has not yet recognized, that a file system is one of the better ways to export data to the end user by leveraging what the end user already has and knows - digital cameras also took a long way until they simply provided a file system and let the file manager deal with moving, displaying and erasing images.

Connecting to a USB device is a not so easy task in any language - I would recommend you automate your vendors application. If you are using Windows, Win32::GUITest is a very good tool to automate foreign programs from within Perl. You do lose the "transparent automation" in the background though, unless you start that application (from within Perl) on another desktop though.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Replies are listed 'Best First'.
Re: Re: interface with USB and perl
by Sihal (Pilgrim) on Jan 15, 2003 at 09:48 UTC
    I guess they use a filesystem. I've been moving tracks around, erasing stuff and adding it back in different places, and so on , and that wouldn't be possible without a FS.
    I actually have a tool running on winXP to do what I need, but I'd like to be able to do it on Linux, since my boxes are mostly Linux...
    Thanx for the feedback.
Re: Re: interface with USB and perl
by Sihal (Pilgrim) on Jan 15, 2003 at 10:44 UTC
    BTW, could you please detail how I would be able to copy stuff on the MD if it has a FS driver (wich is still to be found out, cause it has a driver, but under Linux????) ? I fail to see how to copy stuff to an USB device ? Is it just like a cdrom, the device is mounted when plugged in the USB or do I need a special module to accesss to USB devices ? Thanx a lot.

      If you have a FS driver for your device, copying files to it is mostly reduced to a shell script that does :

      mount /dev/fsminidisk /mount/md cp $* /mount/md/ umount /mount/md
      In Perl, you would possibly use File::Copy to copy files, and unlink to erase files. This also assumes that the FS driver does the work of possibly converting your mp3 files to atrack format (the sound format used on minidisk players). You might have to find a way to convert mp3 to atrack unless the FS driver already does what you need.

      If there is no support for Linux, and the device dosen't use a protocol that is similar to a protocol that is already supported under Linux, then you can still resort to Wine or vmWare, install the driver under the emulation, and export it to the Linux box...

      perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
        the wine solution might be an option. I'll have a look when I get home to see if there is any drivers provided for Linux.
      ok. I know how to copy/erase stuff from a FS.
      What I don't 'know' (never used it) is how USB works. From what I seem to understand, USB is handled by the kernel, and I can access a device just as an ordinary FS if there is a kernel driver for that device, is that correct ?
      If so, it all boils down to finding the driver... or writing my own ( but I might "peter plus haut que mon cul" as we say in France :-) )
Re: Re: interface with USB and perl
by Sihal (Pilgrim) on Jan 15, 2003 at 12:11 UTC
    I realize now that this is not as much a perl question than a pure 'linux' question. I originally posted because I was wondering if there was a way to access an USB device with perl or not, but it is not the issue. Sorry to those whom I might have bothered.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://227106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2025-03-20 18:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (61 votes). Check out past polls.