Accessing a USB Device?

F

Fazer

Hello,

I have a MP3 and I want to access the songs in them. I was wondering
if Python could help me do that. I understand that this can be done
using Linux by mountig it as a file system, but I am not on Linux and
this is mainly for a Windows platform. Can anyone shed some light?

Thanks,
 
S

Stephen Horne

Hello,

I have a MP3 and I want to access the songs in them. I was wondering
if Python could help me do that. I understand that this can be done
using Linux by mountig it as a file system, but I am not on Linux and
this is mainly for a Windows platform. Can anyone shed some light?

Thanks,

Assuming it is a USB device, if the included drivers do not allow
mounting it as a filesystem (my own MP3 player does not, but flash
readers seem to do this as standard) you probably have an extreme
uphill battle accessing it from Python.

Basically, while USB is a serial bus, it isn't like the old serial
ports. It isn't something that's easily handled in a high level
language. If you want to access a USB MP3 device from Python, you will
need...

1. A good understanding of how USB works at a low level.

2. Documentation of the probably proprietary protocol that the MP3
player uses.

3. A driver development kit and C compiler.

Basically, you'd probably need to write an alternate driver for your
device (which would probably block out the original one) and a Python
extension which communicates with that driver.
 
M

Miki Tebeka

Hello Fazer,
I have a MP3 and I want to access the songs in them. I was wondering
if Python could help me do that. I understand that this can be done
using Linux by mountig it as a file system, but I am not on Linux and
this is mainly for a Windows platform. Can anyone shed some light?
I think it's configured just like a serial port. If I'm right try pyserial.

HTH.
Miki
 
A

Andrew MacIntyre

I have a MP3 and I want to access the songs in them. I was wondering
if Python could help me do that. I understand that this can be done
using Linux by mountig it as a file system, but I am not on Linux and
this is mainly for a Windows platform. Can anyone shed some light?

Just plug the thing in and access it as a removable drive (which is all
mounting it as a filesystem really is). You should be able to view the
MP3s with Windows Explorer
 
S

Stephen Horne

Just plug the thing in and access it as a removable drive (which is all
mounting it as a filesystem really is). You should be able to view the
MP3s with Windows Explorer

That depends on how the PC connectivity for the MP3 player works.
Mine, for one, doesn't work that way. It provides an application which
looks a bit like explorer, but you don't get a drive letter - you just
get two listview panes in the application listing the MP3s in the
built-in flash and the extension flash of the device.
 
F

Fazer

Stephen Horne said:
That depends on how the PC connectivity for the MP3 player works.
Mine, for one, doesn't work that way. It provides an application which
looks a bit like explorer, but you don't get a drive letter - you just
get two listview panes in the application listing the MP3s in the
built-in flash and the extension flash of the device.

That's exactly right. I hoped that I could mount it as a drive, but I
can't. However, in Linux, is it possible to mount such a MP3 Player
as a mountable drive?
 
S

Stephen Horne

That's exactly right. I hoped that I could mount it as a drive, but I
can't. However, in Linux, is it possible to mount such a MP3 Player
as a mountable drive?

Good question. In fact, better question - can you access the device at
all in linux?

AFAIK there is no standard protocol for accessing MP3 players, so
unless someone has written a specific driver for your specific device
you will probably be out of luck.

All I can suggest is that you google for "linux driver" and the make
and model of your MP3 player.
 
A

Andrew MacIntyre

That's exactly right. I hoped that I could mount it as a drive, but I
can't. However, in Linux, is it possible to mount such a MP3 Player
as a mountable drive?

What filesystem is reported for the mount in Linux?? If it is FAT or
FAT32, I would suggest that the Windows application is getting its mitts
on the device before explorer attempts a removable device mount. In this
case you might try uninstalling the application and any drivers it may
have loaded.
 
J

Josef Meile

I have a MP3 and I want to access the songs in them. I was wondering
I think it's configured just like a serial port. If I'm right try
pyserial.

I'm also interested, but instead of an MP3 device, I want to connect two
PCs. The problem is that one of the PCs has only a serial port, which must
be
used by another application. However, it has lots of USB ports, so I could
use
either one USB adapter to RS-232 or a USB to USB cable. As suggested in a
message from this newsgroup, I tried COM3, which was supposed to be the usb
port, but it fails, it shows:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python23\Lib\site-packages\serial\serialwin32.py", line 70, in
__init__
raise serialutil.SerialException, "could not open port: %s" %
msg serial.serialutil.SerialException: could not open port:
(2, 'CreateFile', 'The system cannot find the file specified.')

Then I tried the scan example from the pyserial site, but it only shows:
(0) COM1
(1) COM2

So I guess it's either not possible or you have to do something else.

Does anybody have a clue?

Thanks in advanced,
Josef
 
J

Josef Meile

Sory for the early reply. Now I think I know why it doesn't works. From the
readme I saw:

"But be aware that the (USB) device file disappears as soon as you unplug
the USB
adapter."

So I guess it doesn't recognize the port if you don't have anything
connected to it
(Serial ports are listed even if nothing is connected to them).

First I have to get the cables, then if it still doesn't work, I will reply
again.

Thanks,
Josef
 
S

Stephen Horne

I'm also interested, but instead of an MP3 device, I want to connect two
PCs. The problem is that one of the PCs has only a serial port, which must
be
used by another application. However, it has lots of USB ports, so I could
use
either one USB adapter to RS-232 or a USB to USB cable. As suggested in a
message from this newsgroup, I tried COM3, which was supposed to be the usb
port, but it fails, it shows:

Although in hardware terms a USB port is a kind of serial connection,
in software terms there will be a world of difference. There is an
assumption of layers of protocols and indirection which are very hard
to opt out of. USB simply doesn't allow for the
10-minutes-with-a-soldering-iron and a couple of OS calls in the code
approach to custom serial communication.

The reason is that a USB port is primarily because a USB port is
shared resource - you may have it plugged into a hub with several more
devices attached. Ensuring that works correctly means ensuring a rogue
program cannot just hijack the USB port and tell it to do nonstandard
stuff.

A USB port is therefore not going to be visible as a COM port.

You may be able to get a USB device which provides extra serial ports.
It will achieve that by having an installed driver which effectively
creates a virtual COM device in the PC, and transfers the information
from it via the USB cable to the real COM device.

Failing that, I suspect you need to write a driver which fits in with
the OSs way of managing USB, and make a cable with some kind of relay
device that can tell both PCs what the USB cable is doing (so the
correct driver can be identified, installed, and can be given data
recieved from that cable). That doesn't sound to me like a practical
job for most people.

The price of power and flexibility is a loss of simplicity and direct
control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top