我怎样才能读取sysfs属性

时间:2015-10-28 13:02:07

标签: c linux linux-kernel sysfs

如何从用户应用程序中读取sysfs属性。它与cat命令类似。比如我有一个标签是亮度。我怎样才能获得亮度标签的价值?因为我需要从我的应用程序中读取USB infor,并且我看到它们被导出到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

1 个答案:

答案 0 :(得分:2)

使用例如打开文件<body> <div id="top"> <center> <h1>High Low Card Game</h1> </center> </div> <br> <p>the rules are simple chose if the next card is high or is the card low and try to beat your own score ! &spades; &clubs; &diams; &hearts; </p> <br> <button id="test1" type="button" onclick="setTimeout( Start(), 1000000 )"> Start Game</button> <span id="welcome"></span> <p id="name"></p> <br> <span id="card"></span> <br> <span id="question"></span> <br> <span id="score"></span> <button id="test" type="button" onclick="highOrLow('high')"> Higher</button> <br> <button id="test2" type="button" onclick="highOrLow('low')"> Lower</button> <br> <span id="high"></span> </body>并与其他文件一样阅读其内容。不确定亮度,你没有提到它的文件,也没有该文件的文件。