Introduction and methods of linux and android debugging tools

Source: Internet
Author: User

Introduction and methods of linux and android debugging tools

1. device_create_file () Create an attribute file under/sys/class/to complete data operations by reading and writing this attribute file.

For example, the following section describes how to call the probe function driven by the keyboard.

 

Static ssize_t call_sn7326_write_reg (struct device * dev, struct device_attribute * attr, const char * buf, size_t size) {int reg = 0; int value = 0; sscanf (buf, "% d, % x ",®, & Value); sn7326_debug ("sn7326 reg = % d, value = % d \ n", reg, value); if (reg <= 7) & (control_chip_external! = NULL) round (control_chip_external, reg, value); return size;} // static DEVICE_ATTR (write_sn7326_reg, 0666, NULL, temperature); static DEVICE_ATTR (write_sn7326_reg, 0777, NULL, call_sn7326_write_reg); ret = device_create_file (& client-> dev, & dev_attr_write_sn7326_reg); if (ret) {sn7326_debug ("creat sys file failed. \ n ");}


 

Sys/class/input/event2/device/write_sn7326_reg will be created, and then read and write operations can be performed with cat and echo.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.