Sihal has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monks,
I was in the subway this morning, listenning to my minidisk, and I wondered :
First is there any way to manipulate USB devices with perl ? Haven't seen anything about that on the camel or the cookbook...
If so do you think it would be possible in your opinion to develop a script to handle content on a minidisk?
Remember I thought about that on the subway, and haven't even been on CPAN yet to have a look about what exists. And finally, if anybody is already working on this I'll be happy to join in! ;-).
Re: interface with USB and perl
by Corion (Patriarch) on Jan 15, 2003 at 09:45 UTC
|
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
| [reply] [d/l] |
|
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.
| [reply] |
|
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.
| [reply] |
|
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
| [reply] [d/l] [select] |
|
|
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 :-) )
| [reply] |
|
|
|
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.
| [reply] |
Re: interface with USB and perl
by Sihal (Pilgrim) on Jan 15, 2003 at 19:03 UTC
|
For those interested on the subject:
Minidisk FAQ: minidisc.org
Acording to this FAQ, RealPLayer, available on Linux, sems to be able to encode in ATRAC3, wich is one good new.
So we still have to find out how to write on the MD, but we can rely on other software for the encoding.
Id love to have a MinidiskEditor sitting on my Linux Box... :-)
| [reply] |
|
|