Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Read "device attribute" fails with error "invalid length"
    text
    copied!<p>I am working on the TI OMAP platform with Android as the operating system. For one UseCase, we have to toggle one of the LED's in the device. The LED has number of "Device Attributes" and from the Application Layer [.java], we want to read a "Device Attribute".</p> <p>When we do run the cat command on the adb prompt:</p> <pre><code># cat /sys/devices/device_name/device_attribute # device_attribute:invalid length </code></pre> <p>We get the error "invalid length". Hence, I wanted to know is there a way to read a "Device Property" such that it is accessible to the App Layer as well.</p> <p>I found a similar question on another forum <a href="http://android.modaco.com/topic/312770-possible-solution-for-lack-of-notification-light-developers-needed" rel="nofollow">http://android.modaco.com/topic/312770-possible-solution-for-lack-of-notification-light-developers-needed</a> but it was also unanswered.</p> <p>Thanks for the replies !!!</p> <p><strong>Solution</strong> The device was only having "set_device_attribute" but since "get_device_attribute" was missing, we were getting "invalid length" issue when "read" command to that device property was issued.</p> <p>I added a new API named:</p> <pre><code>static ssize_t get_device_attribute(struct device *dev, struct device_attribute *attr, char *buf) { ......................... ......................... ......................... } </code></pre> <p>and updated the device attribute</p> <pre><code>static DEVICE_ATTR(device_property, 0777,get_device_attribute, set_device_attribute); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload