-3

我如何从用户应用程序中读取 sysfs 属性。它与 cat 命令的内容相似。比如我有一个标签是亮度。如何获得亮度标签的值?因为我需要从我的应用程序中读取 USB 信息,并且我看到它们被导出到 sysfs,如下面的拓扑:

ls /sys/bus/usb/devices/1-1
1-1:1.0              busnum               port
authorized           configuration        power
avoid_reset_quirk    descriptors          product
bConfigurationValue  dev                  quirks
bDeviceClass         devnum               removable
bDeviceProtocol      devpath              remove
bDeviceSubClass      driver               serial
bMaxPacketSize0      ep_00                speed
bMaxPower            idProduct            subsystem
bNumConfigurations   idVendor             uevent
bNumInterfaces       ltm_capable          urbnum
bcdDevice            manufacturer         version
bmAttributes         maxchild
4

1 回答 1

2

使用 eg 打开文件fopen("//sys/bus/usb/devices/1-1/version", "rt")并像读取任何其他文件一样读取其内容。不确定亮度,你没有提到它在哪个文件中,也没有那个名字的文件。

于 2015-10-28T13:08:52.840 回答