Android - Reading "device attribute" fails with error "invalid length"

I am working on the TI OMAP platform with Android as the operating system. For one UseCase, we must switch one of the LEDs in the device. The LED has the number "Device Attributes" and from the application level [.java], we want to read "Device Attribute".

When we run the cat command at the adb prompt:

# cat /sys/devices/device_name/device_attribute # device_attribute:invalid length 

We get an "invalid length" error. Therefore, I wanted to know if there is a way to read β€œDevice Property” so that it is available at the application level.

I found a similar question on another forum http://android.modaco.com/topic/312770-possible-solution-for-lack-of-notification-light-developers-needed , but it also went unanswered.

Thanks for answers!!!

Solution The device had only "set_device_attribute", but since there was no "get_device_attribute", we received an "invalid length" error when the "read" command was issued on this device property.

I added a new API named:

 static ssize_t get_device_attribute(struct device *dev, struct device_attribute *attr, char *buf) { ......................... ......................... ......................... } 

and updated device attribute

 static DEVICE_ATTR(device_property, 0777,get_device_attribute, set_device_attribute); 
+4
source share
2 answers

An invalid length often indicates a directory. Try writing the last device_attribute attribute.

Alternativeley you can also find device information in "/ proc".

+2
source

You probably have the source code for the Linux kernel, find the specific implementation of the sysfs device, see how it was programmed.

0
source

All Articles