我正在使用 Android 作为操作系统的 TI OMAP 平台工作。对于一个用例,我们必须切换设备中的一个 LED。 LED 有许多“设备属性”,我们想从应用层 [.java] 读取一个“设备属性”。
当我们在 adb 提示符下运行 cat 命令时:
# cat /sys/devices/device_name/device_attribute
# device_attribute:invalid length
我们收到错误“无效长度”。因此,我想知道是否有一种方法可以读取“设备属性”,以便 App 层也可以访问它。
我在另一个论坛上发现了类似的问题http://android.modaco.com/topic/312770-possible-solution-for-lack-of-notification-light-developers-needed但也没有得到答复。
感谢回复!!!
解决方案 该设备只有“set_device_attribute”,但由于缺少“get_device_attribute”,当向该设备属性发出“读取”命令时,我们遇到“无效长度”问题。
我添加了一个名为:
的新 APIstatic ssize_t get_device_attribute(struct device *dev, struct device_attribute *attr,
char *buf)
{
.........................
.........................
.........................
}
并更新了设备属性
static DEVICE_ATTR(device_property, 0777,get_device_attribute, set_device_attribute);
最佳答案
无效长度通常表示目录。尝试 cd 到最后一个“device_attribute”。
或者您也可以在“/proc”中搜索设备信息。
关于Android - 读取 "device attribute"失败并出现错误 "invalid length",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7306202/