Chris
Chris

Reputation: 991

How to read out vendor ID of CF-Card

I'm writing a bash script which fills cf cards with an image. Since only specified cards are allowed, I'd like to check if the right type of cf card is plugged in the USB cf card writer.

I know that it is possible to read out vendor id and firmware version of the cf card somehow (I saw it on an embedded system), but I don't know how to achieve that on my linux box (openSUSE 10.3) and a usb cf card writer.

Does anyone else know how?

Many thanks, Chris

Upvotes: 4

Views: 6215

Answers (4)

baol
baol

Reputation: 4358

Apart from using lsusb, you can try dbus.

Here is a sample python code that should list all scsi_host parents in the hardware hierarchy.

import dbus
bus = dbus.SystemBus()
hal = bus.get_object ('org.freedesktop.Hal',
            u'/org/freedesktop/Hal/Manager')
hal_manager = dbus.Interface(hal, u'org.freedesktop.Hal.Manager')
volume_udi_list = hal_manager.FindDeviceByCapability('scsi_host')
for udi in volume_udi_list:
    # inspect all scsi_host devices
    dev = bus.get_object ( u'org.freedesktop.Hal', udi)
    volume = dbus.Interface(dev, u'org.freedesktop.Hal.Device')
    # get their parent
    parent = volume.GetProperty('info.parent')
    dev = bus.get_object ( u'org.freedesktop.Hal', parent)
    volume = dbus.Interface(dev, u'org.freedesktop.Hal.Device')
    # Here we can find vendor id for usb-storage devices
    props = volume.GetAllProperties()
    print "\n".join(("%s: %s" % (k, props[k]) for k in props))

Upvotes: 2

Perry Lorier
Perry Lorier

Reputation: 66

hdparm -i /dev/sda

can tell you about the model, firmware revision and serial number of most ATA disks (including, I presume a CF "disk").

smartctl -a /dev/sda

will also tell you a lot about a random disk, including the model, serial, firmware, capacity, as well as some statistics as to the general health of a disk.

I believe this will work well for a CF disk, as it does for a SATA or PATA disk, although I don't have one here to check with right now.

Upvotes: 1

Dennis Williamson
Dennis Williamson

Reputation: 360065

Take a look at the output of lsusb or cat /proc/scsi/usb-storage/*

Upvotes: 0

shodanex
shodanex

Reputation: 15406

You can try to do

cat /proc/scsi/scsi

And see if you have meaningfull information. Because CF card have PID / VID does not mean it is exported by the USB card reader.

Upvotes: 1

Related Questions