加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 如何读出CF卡的供应商ID

发布时间:2020-12-13 22:59:44 所属栏目:Linux 来源:网络整理
导读:我正在写一个bash脚本,用图片填充cf卡片.由于只允许指定的卡,我想检查USB cf卡写入器中是否插入了正确类型的cf卡. 我知道有可能以某种方式读出cf卡的供应商ID和固件版本(我在嵌入式系统上看到它),但我不知道如何在我的linux盒子(openSUSE 10.3)和usb上实现它
我正在写一个bash脚本,用图片填充cf卡片.由于只允许指定的卡,我想检查USB cf卡写入器中是否插入了正确类型的cf卡.

我知道有可能以某种方式读出cf卡的供应商ID和固件版本(我在嵌入式系统上看到它),但我不知道如何在我的linux盒子(openSUSE 10.3)和usb上实现它cf卡片作家.

有谁知道怎么样?

非常感谢,
克里斯

解决方法

除了使用lsusb,你可以试试dbus.

下面是一个示例python代码,应该列出硬件层次结构中的所有scsi_host父代.

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))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读