Movatterモバイル変換


[0]ホーム

URL:


CN103353835A - Migration processing method and device of Android system SensorHal layer compatible kinds of same Sensor devices - Google Patents

Migration processing method and device of Android system SensorHal layer compatible kinds of same Sensor devices
Download PDF

Info

Publication number
CN103353835A
CN103353835ACN2013100168313ACN201310016831ACN103353835ACN 103353835 ACN103353835 ACN 103353835ACN 2013100168313 ACN2013100168313 ACN 2013100168313ACN 201310016831 ACN201310016831 ACN 201310016831ACN 103353835 ACN103353835 ACN 103353835A
Authority
CN
China
Prior art keywords
sensor
value
module
equipment
sensors
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN2013100168313A
Other languages
Chinese (zh)
Other versions
CN103353835B (en
Inventor
银兰凤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Allwinner Technology Co Ltd
Original Assignee
Allwinner Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Allwinner Technology Co LtdfiledCriticalAllwinner Technology Co Ltd
Priority to CN201310016831.3ApriorityCriticalpatent/CN103353835B/en
Publication of CN103353835ApublicationCriticalpatent/CN103353835A/en
Application grantedgrantedCritical
Publication of CN103353835BpublicationCriticalpatent/CN103353835B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Landscapes

Abstract

The invention discloses a migration processing method and device of an Android system SensorHal layer compatible a plurality kinds of same Sensor devices. The method comprises the following steps: setting initial parameters; reading the registered device name of the device driver, conducting matching with the defined device name, and determining the Sensor device used in the system; analyzing the configured file, reading corresponding module direction and parameter value arranging and direction adjusting required by different Sensors according to the name of the module; adding corresponding devices to the sensor list according to the read device register name in the driver; obtaining corresponding device data by starting corresponding thread calling poll function of Sensor system SensorHal layer of the Android system. The migration processing method and device of the Android system SensorHal layer compatible a plurality kinds of same Sensor devices provided by the invention are capable of conducting corresponding interface realization by mobile judging of the hardware device, so as to replace Sensor device quickly and realize Sensor direction adjusting without new compiling and configuration operation.

Description

Migration process method and the device of the compatible multiple Sensor equipment of the same race of the Sensor HAL of Android system layer
Technical field
The hardware that the present invention relates to Sensors is taken out picture layer processing technology field, particularly relates to migration process method and the device of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of system layer.
Background technology
Hardware abstraction layer HAL(Hardware Abstraction Layer), hardware abstraction layer is the interface layer between operating system nucleus and hardware circuit, and its purpose is hardware abstraction.It has hidden the hardware interface details of particular platform, for operating system provides the virtual hardware platform, makes it have hardware independence, can transplant in kinds of platform.The Sensor hardware abstraction layer is effectively isolated the hardware of bottom and the application on upper strata, and conduct tie wherein, reads the data of bottom hardware, submits to system after changing accordingly and uses.The realization of hardware abstraction layer is fairly simple, and main task is for describing the processing of corresponding equipment and data, and each side realizes neither a standard, because implement flexible and changeable.
From the angle of software and hardware test, the test job of software and hardware all can be finished based on hardware abstraction layer respectively, so that the parallel possibility that becomes of software and hardware test job.
Sensors Hardware Module is the Sensor hardware abstraction layer namely, generally is called the HAL layer of Sensors.The HAL layer is effectively isolated the hardware of bottom and the application on upper strata, and conduct tie wherein, reads the data of bottom hardware, submits to system after changing accordingly and uses.The realization of hardware abstraction layer is fairly simple, in the migration process, needs to pay close attention to three place's key points, is illustrated in fig. 1 shown below: the sensing system structure of Android.
One, fills the relevant information of using Sensor in the hardware.
The relevant information of Sensors is described by the Sensor_t structure, and this structure is mainly used among the function get_Sensors_list (), is used for obtaining the sensor tabulation.
Two, the realization of SetDelay and enable function in the HAL layer.
The SetDelay function mainly is the speed of control hardware equipment reported data; The enable function mainly is enabling of control hardware equipment, the switch of namely whether working.The key point one that function is realized realizes reported data time and the enable switch of the interface opertaing device of corresponding SetDelay and enable for Kernel driver; Two for needing to find the interface path of Kernel driver function in the HAL layer, carries out corresponding read-write, and then realize SetDelay and enable function.
Three, reading of data mainly is to find the equipment of registering among the Driver, and opens it and then read wherein data.The processing of data mainly is the direction of deal with data and data is converted to the spendable data layout of system.
The numerical value direction of some Sensor also can be subject to the impact of hardware design, and take mma7660 gravity sensor (GSensor) as example, the direction in the hardware device will affect the directivity of data, be illustrated in fig. 2 shown below:
In the prior art, the module title that the different module of method definition configuration of service condition compiling uses, the Sensor_t structure of direction value and corresponding Sensor.
The shortcoming of the common method of prior art is: when the poor direction of the module of finding configuration is true and when using another module instead, need again configuration and compiling; When revising the direction parameter of module in compiled firmware, need to arrive the order of carrying out once renewal under the catalogue in the source file and compile afterwards, the direction value of modification just can come into force.
Summary of the invention
The invention provides migration process method and the device of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of system layer, realize the compatibility of multiple Sensor equipment, and can judge dynamically that hardware device carries out the realization of the corresponding interface, thereby can replace easily and fast Sensor equipment, and not need to carry out new compiling and configuration.
Based on the problems referred to above, the migration process method of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of system layer provided by the invention specifically comprises the steps:
Drive according to the Sensors that supports in the linux system, Sensor HAL layer is carried out initialization process; When initialization, the title and the conversion value that drive all modules that platform supports are set; The path of default Gsensor direction value path and Sensor equipment, the identification title of default Gsensor direction variable also configures corresponding direction variable configuration file; For different Sensor equipment corresponding Sensor_t structure is set; Wherein, the title of each module of setting is corresponding one by one to the device name in the Linux input subsystem with the Sensor facility registration;
Be registered to the input subsystem of Linux at the Driver of Sensors equipment after, Sensors HAL layer determines to obtain title and the module of current registered Sensors equipment according to generating node corresponding to Sensors equipment;
After Android HAL layer determines to obtain current registered Sensor device name, path according to default Sensor device orientation value, read described direction variable configuration file and resolve default Sensor direction value, compare described default Sensor direction value and required Sensor direction value, adjust the direction of Sensor equipment;
Obtain Sensor_t structure information corresponding to Sensor equipment, the module that uses in the hardware is added in the sensor tabulation, realize described module is registered to the Android layer;
Described Android layer starts the data that poll function in the corresponding thread dispatching Sensors HAL layer obtains the bottom relevant device.
Preferably, as a kind of embodiment, the described title and the conversion value that drive all modules that platform supports of arranging comprises the steps:
After the title and conversion value of determining all modules that the driving platform is supported, utilize the device name of structure name record module and the conversion value of Sensor; Wherein: conversion value is the maximal value that the Driver of Sensor equipment reports;
The identification title of described default Gsensor direction variable also configures corresponding direction variable configuration file, comprises the steps:
According to the title of different modules, arrange respectively corresponding module X, Y, Z axis direction and whether with the sign of XY axle exchange; The identification title of described Gsensor direction variable is used for the direction value of identification Sensor equipment; The Gsensor direction variable information configuration that arranges is also preserved in direction variable configuration file Gsensor.cfg;
Describedly for different Sensor equipment corresponding Sensor_t structure is set, comprises the steps:
According to different Sensor equipment, the descriptor of corresponding Sensor_t structure is set.
Preferably, as a kind of embodiment, described Sensors HAL layer is according to generating the node corresponding with Sensors equipment, determines title and the module of the current registered Sensors equipment that obtains, comprises the steps:
Be registered to the input subsystem of Linux at the Driver of current Sensors equipment after, that Sensors HAL layer generates according to described input subsystem and with the described current Sensors equipment memory location of node one to one, find input device storage position corresponding to described current Sensors equipment;
Wherein: the node of described equipment is present under "/sys/class/input/inputX " catalogue, and X is positive integer, and X numerical value equals the input sequence sequence number corresponding according to the input equipment of linux system; X numerical value is arranged along with input sequence carries out ascending order;
Utilize function read to read/title of Sensors equipment under the sys/class/input/inputX;
The title of the described Sensors equipment that the reads title with the Sensors equipment that drives the platform setting is compared, find in the hardware the consistent module of title with the described Sensors equipment that reads;
Determine the value of node path and the X of current registered Sensors equipment.
Preferably, as a kind of embodiment, described read direction variable configuration file is also resolved Sensor direction value, compares described default Sensor direction value and required Sensor direction value, adjusts the direction of Sensor equipment, comprises the steps:
Utilize function G sensor_cfg read direction variable configuration file Gsensor.cfg, the module of the Sensor device name coupling of determining in all modules that in described Gsensor.cfg file, record and reading, and resolve the default Sensor direction value of corresponding coupling module;
Wherein, described Gsensor.cfg file is used for the direction value that record drives all modules of platform support;
When reading the true value, default Sensor direction value is the positive dirction value; When reading the false value, default Sensor direction value is the negative direction value; Described positive dirction value is positive number+1, and described negative direction value is negative-1; Whether the direction value of judging required Sensor is consistent with default Sensor direction value, if judged result is consistent, then will not need to adjust the direction of Sensor; If judged result is inconsistent, the direction that then will adjust Sensor is and the opposite direction of presetting the Sensor direction.
Preferably, as a kind of embodiment, described Sensor_t structure information corresponding to Sensor equipment of obtaining is added the module that uses in the hardware in the sensor tabulation to, comprises the steps:
According to memory location in the driving platform at the title place of module, obtain corresponding Sensor_t structure information, utilize the get_sensors_list function that the module that uses in the hardware is added in the sensor tabulation;
The data that poll function in the corresponding thread dispatching Sensors of the described startup HAL layer obtains the bottom relevant device comprise the steps:
Utilize the Poll function will read in real time the value of reporting, carry out corresponding data-switching according to conversion formula, and numerical value reports the use of Android system after will changing;
Described conversion formula is: numerical value after the conversion=(G/ conversion value) * direction value * value of reporting;
Wherein: G is unit value and is constant, the G value difference that dissimilar Sensor equipment is corresponding; Conversion value is constant, and the conversion value that dissimilar Sensor equipment is corresponding is different;
Described Sensor_t structure is used for describing the Sensor equipment characteristic information; Described Sensor_t structure institute descriptor comprises title, the version of sensor, the handle of sensor, the type of sensor, the maximum magnitude of sensor, the resolution of sensor, the consumption energy of sensor, the interval of events minimum time of sensor.
Correspondingly, the present invention also provides the migration process device of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of system layer, comprise that initialization module, equipment read module, direction adjusting module, module add module and data read module, wherein:
Described initialization module, the Sensors that is used for supporting according to linux system drives, and the SensorHAL layer is carried out initialization process; When initialization, the title and the conversion value that drive all modules that platform supports are set; The path of default Gsensor direction value path and Sensor equipment, the identification title of default Gsensor direction variable also configures corresponding direction variable configuration file; For different Sensor equipment corresponding Sensor_t structure is set; Wherein, the title of each module of setting is corresponding one by one to the device name in the Linux input subsystem with the Sensor facility registration;
Described equipment read module is used for after the Driver of Sensors equipment is registered to the input subsystem of Linux, and Sensors HAL layer determines to obtain title and the module of current registered Sensors equipment according to generating node corresponding to Sensors equipment;
Described direction adjusting module, be used for after Android HAL layer determines to obtain current registered Sensor device name, path according to default Sensor device orientation value, read described direction variable configuration file and resolve default Sensor direction value, compare described default Sensor direction value and required Sensor direction value, adjust the direction of Sensor equipment;
Described module adds module, is used for obtaining Sensor_t structure information corresponding to Sensor equipment, and the module that uses in the hardware is added in the sensor tabulation, realizes described module is registered to the Android layer;
Described data read module is used for the data that poll function that described Android layer starts corresponding thread dispatching Sensors HAL layer obtains the bottom relevant device.
Preferably, as a kind of embodiment, described initialization module comprises that record sub module, the default submodule and first of direction arrange submodule, wherein:
Record sub module is used for after the title and conversion value of determining all modules that the driving platform is supported, utilizes the device name of structure name record module and the conversion value of Sensor; Wherein: conversion value is the maximal value that the Driver of Sensor equipment reports;
Described direction is preset submodule, is used for the title according to different modules, arrange respectively corresponding module X, Y, Z axis direction and whether with the sign of XY axle exchange; The identification title of described Gsensor direction variable is used for the direction value of identification Sensor equipment; The Gsensor direction variable information configuration that arranges is also preserved in direction variable configuration file Gsensor.cfg;
Described first arranges submodule, is used for according to different Sensor equipment, and the descriptor of corresponding Sensor_t structure is set.
Preferably, as a kind of embodiment, described equipment read module comprises searches submodule, the first reading submodule, comparer module and definite submodule, wherein:
The described submodule of searching, the Driver of current Sensors equipment is used for after will be registered to the input subsystem of Linux, that Sensors HAL layer generates according to described input subsystem and with the described current Sensors equipment memory location of node one to one, find input device storage position corresponding to described current Sensors equipment;
Wherein: the node of described equipment is present under "/sys/class/input/inputX " catalogue, and X is positive integer, and X numerical value equals the input sequence sequence number corresponding according to the input equipment of linux system; X numerical value is arranged along with input sequence carries out ascending order;
Described the first reading submodule is used for utilizing function read to read/title of Sensors equipment under the sys/class/input/inputX;
Described comparer module, the title that is used for title and the Sensors equipment of driving platform setting that will the described Sensors equipment that reads compares, and finds in the hardware the consistent module of title with the described Sensors equipment that reads;
Described definite submodule is used for determining the node path of current registered Sensors equipment and the value of X.
Preferably, as a kind of embodiment, described direction adjusting module comprises coupling analyzing sub-module and adjustment submodule, wherein:
Described coupling analyzing sub-module, be used for utilizing function G sensor_cfg read direction variable configuration file Gsensor.cfg, the module of the Sensor device name coupling of determining in all modules that in described Gsensor.cfg file, record and reading, and resolve the default Sensor direction value of corresponding coupling module;
Wherein, described Gsensor.cfg file is used for the direction value that record drives all modules of platform support;
Described adjustment submodule is used for when reading the true value, and default Sensor direction value is the positive dirction value; When reading the false value, default Sensor direction value is the negative direction value; Described positive dirction value is positive number+1, and described negative direction value is negative-1; Whether the direction value of judging required Sensor is consistent with default Sensor direction value, if judged result is consistent, then will not need to adjust the direction of Sensor; If judged result is inconsistent, the direction that then will adjust Sensor is and the opposite direction of presetting the Sensor direction.
Preferably, as a kind of embodiment, described module adds module and comprises that module adds submodule, wherein:
Described module adds submodule, is used for the driving platform memory location according to the title place of module, obtains corresponding Sensor_t structure information, utilizes the get_sensors_list function that the module that uses in the hardware is added in the sensor tabulation;
Described data read module comprises that the data conversion reports submodule, wherein:
Described data transform and report submodule, are used for utilizing the Poll function will read in real time the value of reporting, and carry out corresponding data-switching according to conversion formula, and numerical value reports the use of Android system after will changing;
Described conversion formula is: numerical value after the conversion=(G/ conversion value) * direction value * value of reporting;
Wherein: G is unit value and is constant, the G value difference that dissimilar Sensor equipment is corresponding; Conversion value is constant, and the conversion value that dissimilar Sensor equipment is corresponding is different.
Beneficial effect of the present invention comprises:
Migration process method and the device of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of system layer provided by the invention, wherein method comprises initiation parameter is set; The device name of registration during fetch equipment drives, and mate with defined device name, determine the Sensor equipment that uses in the system; Resolve configuration file, read the direction value of corresponding module in the configuration file and parameter value setting that different Sensor needs are changed and the adjustment of direction according to the title of module; According to the title of facility registration in the driving that reads, add corresponding equipment to the sensor tabulation; The Android system starts the data that poll function in the corresponding thread dispatching Sensors HAL layer obtains the bottom relevant device.Migration process method and the device of the compatible multiple Sensor equipment of the same race of the Android Sensor HAL of system layer provided by the invention can judge dynamically that hardware device carries out the realization of the corresponding interface, thereby the adjustment of replacing rapidly Sensor equipment and realizing the Sensor device orientation, and do not need to carry out new compiling and configuration operation.
Description of drawings
Fig. 1 is the sensing system structural representation of Android in the prior art;
Fig. 2 is the schematic diagram of directivity of the numerical value aspect effect data of Sensor equipment in the prior art;
Fig. 3 is the schematic flow sheet of an embodiment of migration process method of the present invention;
Fig. 4 is the related content of Name structure definition among the embodiment of migration process method of the present invention;
Fig. 5 is the related content of definition fixed route among the embodiment of migration process method of the present invention;
Fig. 6 is the Gsensor direction variable information that arranges among the embodiment of migration process method of the present invention;
Fig. 7 is the descriptor of the Sensor_t structure definition that arranges among the embodiment of migration process method of the present invention;
Fig. 8 is the reading result of Sensor equipment among the embodiment of migration process method of the present invention;
Fig. 9 is the structural representation of an embodiment of migration process device of the present invention.
Embodiment
Below in conjunction with Figure of description, the migration process method of the compatible multiple Sensor equipment of the same race of the Sensor HAL of the Android system layer in the embodiment of the invention and the embodiment of device are described.
The hardware of Sensors is taken out in the picture layer, there is the structure of several keys to need the user to process, for example: the sensors_module_t structure is used for defining the sensor module, the sensor_t structure is used for defining a sensors equipment, sensors_event_t is used for defining the sensor data, and sensors_poll_device_t is used for defining the control of sensor.
The migration process method of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of system layer that the embodiment of the invention provides is for the migration process that adapts to multiple Sensor equipment of the same race.
Fig. 3 is the process flow diagram of the migration process method of the compatible multiple Sensor equipment of the same race of the Sensor HAL of the Android system layer of the embodiment of the invention.As shown in Figure 3, the employed method of the present embodiment comprises following several step:
S100, drive according to the Sensors that supports in the linux system, Sensor HAL layer is carried out initialization process; When initialization, the title and the conversion value that drive all modules that platform supports are set; The path of default Gsensor direction value path and Sensor equipment, the identification title of default Gsensor direction variable also configures corresponding direction variable configuration file; For different Sensor equipment corresponding Sensor_t structure is set; Wherein, the title of each module of setting is corresponding one by one to the device name in the Linux input subsystem with the Sensor facility registration;
S200, be registered to the input subsystem of Linux at the Driver of Sensors equipment after, Sensors HAL layer determines to obtain title and the module of current registered Sensors equipment according to generating node corresponding to Sensors equipment.
S300, after Android HAL layer determines to obtain current registered Sensor device name, path according to default Sensor device orientation value, read described direction variable configuration file and resolve default Sensor direction value, compare described default Sensor direction value and required Sensor direction value, adjust the direction of Sensor equipment;
S400, obtain Sensor_t structure information corresponding to Sensor equipment, the module that uses in the hardware is added in the sensor tabulation, realize described module is registered to the Android layer;
S500, described Android layer start the data that poll function in the corresponding thread dispatching Sensors HAL layer obtains the bottom relevant device.
The below realizes that to the embodiment of the invention above steps of the migration process method of the compatible multiple Sensor equipment of the same race of the Android Sensor HAL of system layer is elaborated:
Preferably, as a kind of embodiment, in described step S100, the described title and the conversion value that drive all modules that platform supports of arranging comprises the steps:
S101, after the title and conversion value that determine to drive all modules that platform supports, utilize the device name of structure name record module and the conversion value of Sensor; Wherein: conversion value is the maximal value that the Driver of Sensor equipment reports;
In above-mentioned steps S101, drive platform at array Linux Sensor initiation parameter is set, the title of the Gsensor module of supporting in the system is set, and this title need to be consistent with the title of facility registration in the driving, and purpose is for being used for the chartered hardware device module of recognition system.
As shown in Figure 4, Fig. 4 has illustrated the related content of described Name structure definition.
In above-mentioned steps S100, the path of default Gsensor direction value path and Sensor equipment, referring to Fig. 5, Fig. 5 has illustrated the fixed route (path that comprises default Gsensor direction value path and Sensor equipment) of definition.
In above-mentioned steps S100, the identification title of described default Gsensor direction variable also configures corresponding direction variable configuration file, specifically comprises the steps:
S102, according to the title of different modules, arrange respectively corresponding module X, Y, Z axis direction and whether with the sign of XY axle exchange; The identification title of described Gsensor direction variable is used for the direction value of identification Sensor equipment; The Gsensor direction variable information configuration that arranges is also preserved in direction variable configuration file Gsensor.cfg; Referring to Fig. 6, Fig. 6 has illustrated the Gsensor direction variable information that arranges.
The direction configuration of each module all only has five, and concrete implication is shown in following table (table 1):
gsensor_nameThe title of the module of supporting
gsensor_direct_xX-direction
gsensor_direct_yY direction
gsensor_direct_zZ-direction
gsensor_xy_revertWhether the XY direction needs counter-rotating
Table 1
In described step S100, describedly for each Sensor equipment corresponding Sensor_t structure is set, specifically comprise the steps:
S103, according to different Sensor equipment, the descriptor of corresponding Sensor_t structure is set; Referring to Fig. 7, Fig. 7 has illustrated embodiment of the invention migration process method specific implementation that the descriptor of Sensor_t structure is set.
When configuration parameter, the Gsensor direction variable need to be set, the path of configuration parameter file; And the separately information such as Sensor_t structure of Sensor are set.
Preferably, as a kind of embodiment, described Sensor_t structure is used for describing the Sensor equipment characteristic information; Described Sensor_t structure institute descriptor comprises the information such as the consumption energy, interval of events minimum time of resolution, the sensor of maximum magnitude, the sensor of type, the sensor of handle, the sensor of version, the sensor of title, the sensor of sensor.Any one sensor equipment is all needed to arrange a sensor_t structure, illustrate, Fig. 7 has illustrated the particular content of above-mentioned information.Sensor_t structure institute descriptor comprises above-mentioned information, but is not limited to this, and the embodiment of the invention is given unnecessary details no longer one by one to this.
Particularly, therefore the usefulness because the structure descriptor of the Sensor_t that different modules uses differs all use the Sensor_t structure to describe accordingly the module of supporting, carries out calling of corresponding descriptor according to the hardware device that reads.
Preferably, as a kind of embodiment, in described step S200, described Sensors HAL layer is according to generating the node corresponding with Sensors equipment, determines title and the module of the current registered Sensors equipment that obtains, comprises the steps:
S201, be registered to the input subsystem of Linux at the Driver of current Sensors equipment after, that Sensors HAL layer generates according to described input subsystem and with the described current Sensors equipment memory location of node one to one, find input device storage position corresponding to described current Sensors equipment;
Wherein: the node of described equipment is present under "/sys/class/input/inputX " catalogue, and X is positive integer, and X numerical value equals the input sequence sequence number corresponding according to the input equipment of linux system; X numerical value is arranged along with input sequence carries out ascending order; For example: the node of Input equipment is present under "/sys/class/input/inputX " catalogue, and X is the numerical value such as 1,2,3,4, carries out the increase of ascending order according to the input equipment of system.
S202, utilize function read to read/title of Sensors equipment under the sys/class/input/inputX;
S203, the title of the described Sensors equipment that the reads title with the Sensors equipment that drives the platform setting is compared, find in the hardware the consistent module of title with the described Sensors equipment that reads;
S204, determine the value of node path and the X of current registered Sensors equipment.
In above-mentioned steps S200, when the Driver of Sensors equipment will be registered in input (input) subsystem of linux, will generate the node corresponding with equipment, Sensors HAL layer can find corresponding equipment according to the node that generates.(function interface that operational hardware equipment namely operates respective nodes gets final product).
Preferably, as a kind of embodiment, in described step S300, described read direction variable configuration file is also resolved Sensor direction value, compare described default Sensor direction value and required Sensor direction value, adjust the direction of Sensor equipment, comprise the steps:
Utilize function G sensor_cfg read direction variable configuration file Gsensor.cfg, the module of the Sensor device name coupling of determining in all modules that in described Gsensor.cfg file, record and reading, and resolve the default Sensor direction value of corresponding coupling module;
Wherein, described Gsensor.cfg file is used for the direction value that record drives all modules of platform support;
When reading the true value, default Sensor direction value is the positive dirction value; When reading the false value, default Sensor direction value is the negative direction value; Described positive dirction value is positive number+1, and described negative direction value is negative-1; Whether the direction value of judging required Sensor is consistent with default Sensor direction value, if judged result is consistent, then will not need to adjust the direction of Sensor; If judged result is inconsistent, the direction that then will adjust Sensor is and the opposite direction of presetting the Sensor direction.As shown in Figure 8, Fig. 8 has illustrated the reading result embodiment of a Sensor equipment.
Preferably, as a kind of embodiment, in described S400 step, described Sensor_t structure information corresponding to Sensor equipment of obtaining is added the module that uses in the hardware in the sensor tabulation to, comprises the steps:
According to memory location in the driving platform at the title place of module, obtain corresponding Sensor_t structure information, utilize the get_sensors_list function that the module that uses in the hardware is added in the sensor tabulation;
In described S500 step, the data that the poll function in the corresponding thread dispatching Sensors of the described startup HAL layer obtains the bottom relevant device comprise the steps:
Utilize the Poll function will read in real time the value of reporting, carry out corresponding data-switching according to conversion formula, and numerical value reports the use of Android system after will changing;
Described conversion formula is: numerical value after the conversion=(G/ conversion value) * direction value * value of reporting;
Wherein: G is unit value and is constant, the G value difference that dissimilar Sensor equipment is corresponding; Conversion value is constant, and the conversion value that dissimilar Sensor equipment is corresponding is different.
For instance, utilize conversion formula (G/ conversion value) * direction value * value of reporting) can obtain spendable numerical value in the system, G is unit value, is 9.81 such as the G value of Gsensor.Conversion value also is the constant that arranges, and only has the value of reporting of Real-time Obtaining different, and therefore above-mentioned formula can realize finishing the conversion operations of data.By carrying out conversion operations, the data that Driver is reported are converted to the data that the Android system can use.
Illustrate, the Sensor equipment of different manufacturers, the figure place of data output is different, some is 8, and some is ten, and the numerical value that reports among the Driver is the int categorical data, and the float type of using in the Android system, and Sensors has special unit value and numerical range, such as the gravity sensing sensor take G(9.81) be maximum output valve, the data that therefore Driver need to be reported are converted to the data that the Android system can use.
Generally speaking, the migration process method that provides of the embodiment of the invention realizes as follows:
The first step: initiation parameter is set;
Second step: the device name of registration during fetch equipment drives, thereby and mate with defined device name and to determine the Sensor equipment that uses in the system;
The 3rd step: resolve configuration file, read the direction value of corresponding module among the gSensor.cfg according to the title of module, and the parameter value that need to change of different Sensor; The parameter that only need to revise in this file when poor direction is true gets final product;
The 4th step: according to the title that reads facility registration in the driving, add corresponding sensor tabulation;
The 5th step: the Android system starts the data that poll function in the corresponding thread dispatching Sensors HAL layer obtains the bottom relevant device.
The migration process method essence that the embodiment of the invention provides is: carry out dynamically calling of corresponding Gsensor interface by reading the device name of registering in the driving, the direction of Gsensor is extracted configuration file of formation, the title of this document is defined as the gsensor.cfg file, deposit in the system/the system/usr/ path under, the direction of all Gsensor of supporting in the system is write wherein; By with drive in the device name that reads mate to resolve configuration file and obtain the direction value of employed Gsensor and the use of corresponding Sensor_t structure, the information such as transfer parameter value of module.
Wherein, the hardware abstraction layer of the Sensor that the embodiment of the invention provides mainly is to call by poll to return the data of obtaining from lower floor, and the system that reports after changing accordingly uses.The structure that needs in the hardware abstraction layer to make up a Sensor_t type represents corresponding equipment module; Processing for data, mainly be conversion parameter and direction, the precision of different modules and resolution all are different, so the key point that the multiple Sensor of hardware abstraction layer realizes is the Sensor_t structure, the processing of module direction and precision resolution etc.The migration process method that the embodiment of the invention provides can compatible multiple Gsensor equipment, carry out the realization of the corresponding interface by dynamic judgement hardware device, can replace quickly and easily Sensor equipment and realize rapidly the adjustment of Sensor device orientation, and not need to carry out new compiling and configuration.
Based on same inventive concept, the embodiment of the invention also provides the migration process device of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of system layer, because the principle of this device solves problem is similar to the migration process method of the compatible multiple Sensor equipment of the same race of the aforementioned a kind of Android Sensor HAL of system layer, therefore the enforcement of this device can referring to the enforcement of preceding method, repeat part and repeat no more.
The migration process device 10 of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of system layer that the embodiment of the invention provides, as shown in Figure 9, described migration process device 10 comprises that initialization module 91, equipment read module 92, direction adjusting module 93, module add module 94 and data read module 95, wherein:
Described initialization module 91, the Sensors that is used for supporting according to linux system drives, and Sensor HAL layer is carried out initialization process; When initialization, the title and the conversion value that drive all modules that platform supports are set; The path of default Gsensor direction value path and Sensor equipment, the identification title of default Gsensor direction variable also configures corresponding direction variable configuration file; For different Sensor equipment corresponding Sensor_t structure is set; Wherein, the title of each module of setting is corresponding one by one to the device name in the Linux input subsystem with the Sensor facility registration;
Described equipment read module 92 is used for after the Driver of Sensors equipment is registered to the input subsystem of Linux, and Sensors HAL layer determines to obtain title and the module of current registered Sensors equipment according to generating node corresponding to Sensors equipment;
Described direction adjusting module 93, be used for after Android HAL layer determines to obtain current registered Sensor device name, path according to default Sensor device orientation value, read described direction variable configuration file and resolve default Sensor direction value, compare described default Sensor direction value and required Sensor direction value, adjust the direction of Sensor equipment;
Described module adds module 94, is used for obtaining Sensor_t structure information corresponding to Sensor equipment, and the module that uses in the hardware is added in the sensor tabulation, realizes described module is registered to the Android layer;
Described data read module 95 is used for the data that poll function that described Android layer starts corresponding thread dispatching Sensors HAL layer obtains the bottom relevant device.
Preferably, as a kind of embodiment, described initialization module 91 comprises that record sub module, the default submodule and first of direction arrange submodule, wherein:
Record sub module is used for after the title and conversion value of determining all modules that the driving platform is supported, utilizes the device name of structure name record module and the conversion value of Sensor; Wherein: conversion value is the maximal value that the Driver of Sensor equipment reports;
Described direction is preset submodule, is used for the title according to different modules, arrange respectively corresponding module X, Y, Z axis direction and whether with the sign of XY axle exchange; The identification title of described Gsensor direction variable is used for the direction value of identification Sensor equipment; The Gsensor direction variable information configuration that arranges is also preserved in direction variable configuration file Gsensor.cfg;
Described first arranges submodule, is used for according to different Sensor equipment, and the descriptor of corresponding Sensor_t structure is set.
Preferably, as a kind of embodiment, described equipment read module 92 comprises searches submodule, the first reading submodule, comparer module and definite submodule, wherein:
The described submodule of searching, be used for after the Driver of current Sensors equipment is registered to the input subsystem of Linux, that Sensors HAL layer generates according to described input subsystem and with the described current Sensors equipment memory location of node one to one, find input device storage position corresponding to described current Sensors equipment;
Wherein: the node of described equipment is present under "/sys/class/input/inputX " catalogue, and X is positive integer, and X numerical value equals the input sequence sequence number corresponding according to the input equipment of linux system; X numerical value is arranged along with input sequence carries out ascending order;
Described the first reading submodule is used for utilizing function read to read/title of Sensors equipment under the sys/class/input/inputX;
Described comparer module, the title that is used for title and the Sensors equipment of driving platform setting that will the described Sensors equipment that reads compares, and finds in the hardware the consistent module of title with the described Sensors equipment that reads;
Described definite submodule is used for determining the node path of current registered Sensors equipment and the value of X.
Preferably, as a kind of embodiment, described direction adjusting module 93 comprises coupling analyzing sub-module and adjustment submodule, wherein:
Described coupling analyzing sub-module, be used for utilizing function G sensor_cfg read direction variable configuration file Gsensor.cfg, the module of the Sensor device name coupling of determining in all modules that in described Gsensor.cfg file, record and reading, and resolve the default Sensor direction value of corresponding coupling module;
Wherein, described Gsensor.cfg file is used for the direction value that record drives all modules of platform support;
Described adjustment submodule is used for when reading the true value, and default Sensor direction value is the positive dirction value; When reading the false value, default Sensor direction value is the negative direction value; Described positive dirction value is positive number+1, and described negative direction value is negative-1; Whether the direction value of judging required Sensor is consistent with default Sensor direction value, if judged result is consistent, then will not need to adjust the direction of Sensor; If judged result is inconsistent, the direction that then will adjust Sensor is and the opposite direction of presetting the Sensor direction.
Preferably, as a kind of embodiment, described module adds module 94 and comprises that module adds submodule, wherein:
Described module adds submodule, is used for the driving platform memory location according to the title place of module, obtains corresponding Sensor_t structure information, utilizes the get_sensors_list function that the module that uses in the hardware is added in the sensor tabulation;
Described data read module 95 comprises that the data conversion reports submodule, wherein:
Described data transform and report submodule, are used for utilizing the Poll function will read in real time the value of reporting, and carry out corresponding data-switching according to conversion formula, and numerical value reports the use of Android system after will changing;
Described conversion formula is: numerical value after the conversion=(G/ conversion value) * direction value * value of reporting;
Wherein: G is unit value and is constant, the G value difference that dissimilar Sensor equipment is corresponding; Conversion value is constant, and the conversion value that dissimilar Sensor equipment is corresponding is different.
Migration process method and the device of the compatible multiple Sensor equipment of the same race of a kind of Android Sensor HAL of the system layer that the embodiment of the invention provides, wherein method comprises initiation parameter is set; The device name of registration during fetch equipment drives, and mate with defined device name, determine the Sensor equipment that uses in the system; Resolve configuration file, read the direction value of corresponding module in the configuration file and parameter value setting that different Sensor needs are changed and the adjustment of direction according to the title of module; According to the title of facility registration in the driving that reads, add corresponding equipment to the sensor tabulation; The Android system starts the data that poll function in the corresponding thread dispatching Sensors HAL layer obtains the bottom relevant device.
The migration process method of the compatible multiple Sensor equipment of the same race of the Sensor HAL of Android system layer that the embodiment of the invention provides and device can compatible multiple Sensor equipment, can judge dynamically that hardware device carries out the realization of the corresponding interface, thereby the adjustment of replacing rapidly Sensor equipment and realizing the Sensor device orientation, and do not need to carry out new compiling and configuration operation.
The above embodiment has only expressed several embodiment of the present invention, and it describes comparatively concrete and detailed, but can not therefore be interpreted as the restriction to claim of the present invention.Should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.

Claims (10)

CN201310016831.3A2013-01-172013-01-17The migration process method and device of the compatible multiple Sensor equipment of the same race of android system Sensor HAL layerActiveCN103353835B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201310016831.3ACN103353835B (en)2013-01-172013-01-17The migration process method and device of the compatible multiple Sensor equipment of the same race of android system Sensor HAL layer

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201310016831.3ACN103353835B (en)2013-01-172013-01-17The migration process method and device of the compatible multiple Sensor equipment of the same race of android system Sensor HAL layer

Publications (2)

Publication NumberPublication Date
CN103353835Atrue CN103353835A (en)2013-10-16
CN103353835B CN103353835B (en)2016-08-10

Family

ID=49310209

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201310016831.3AActiveCN103353835B (en)2013-01-172013-01-17The migration process method and device of the compatible multiple Sensor equipment of the same race of android system Sensor HAL layer

Country Status (1)

CountryLink
CN (1)CN103353835B (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN104506902A (en)*2014-12-052015-04-08惠州Tcl移动通信有限公司Device compatible method and device and mobile terminal
CN105893283A (en)*2015-11-202016-08-24乐视移动智能信息技术(北京)有限公司Camera parameter reading-writing method and apparatus as well as terminal device
CN106502681A (en)*2016-10-312017-03-15广东欧珀移动通信有限公司 A sensor registration method, device and mobile terminal
CN107239283A (en)*2017-05-312017-10-10郑州云海信息技术有限公司A kind of system management memory software adaptation method and device
CN107423075A (en)*2017-08-282017-12-01深圳传音控股有限公司The register method and user terminal of driving
CN107911541A (en)*2017-11-092018-04-13广州视源电子科技股份有限公司Multi-camera switching use method and device based on Android system
CN113032018A (en)*2019-12-252021-06-25上海博泰悦臻电子设备制造有限公司Improved method for reading command and related device
CN113034873A (en)*2019-12-252021-06-25西安诺瓦星云科技股份有限公司Sensor communication method, device and system
CN114020364A (en)*2021-11-162022-02-08北京鲸鲮信息系统技术有限公司Sensor device adapting method and device, electronic device and storage medium
CN116028392A (en)*2022-12-232023-04-28中科驭数(北京)科技有限公司General drive management method, system and equipment oriented to hardware based on KPU architecture
CN116708615A (en)*2022-11-152023-09-05荣耀终端有限公司Device registration method, device registration apparatus and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101833452A (en)*2010-04-302010-09-15中国海洋大学Monitor software design method based on sensor
CN102279746A (en)*2011-08-212011-12-14中国海洋大学Sensor-based monitoring software development platform system and method
CN102314348A (en)*2011-09-152012-01-11Tcl集团股份有限公司Android system development framework and development device
CN102662665A (en)*2012-03-292012-09-12福州瑞芯微电子有限公司Input subsystem enabling Android to support various sensors

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101833452A (en)*2010-04-302010-09-15中国海洋大学Monitor software design method based on sensor
CN102279746A (en)*2011-08-212011-12-14中国海洋大学Sensor-based monitoring software development platform system and method
CN102314348A (en)*2011-09-152012-01-11Tcl集团股份有限公司Android system development framework and development device
CN102662665A (en)*2012-03-292012-09-12福州瑞芯微电子有限公司Input subsystem enabling Android to support various sensors

Cited By (18)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN104506902B (en)*2014-12-052018-11-06惠州Tcl移动通信有限公司A kind of method, device and mobile terminal of device compatibility
CN104506902A (en)*2014-12-052015-04-08惠州Tcl移动通信有限公司Device compatible method and device and mobile terminal
CN105893283A (en)*2015-11-202016-08-24乐视移动智能信息技术(北京)有限公司Camera parameter reading-writing method and apparatus as well as terminal device
WO2017084358A1 (en)*2015-11-202017-05-26乐视控股(北京)有限公司Camera parameter read-write method and apparatus, and terminal device
CN106502681A (en)*2016-10-312017-03-15广东欧珀移动通信有限公司 A sensor registration method, device and mobile terminal
CN106502681B (en)*2016-10-312019-07-16Oppo广东移动通信有限公司Sensor registration method and device and mobile terminal
CN107239283A (en)*2017-05-312017-10-10郑州云海信息技术有限公司A kind of system management memory software adaptation method and device
CN107423075A (en)*2017-08-282017-12-01深圳传音控股有限公司The register method and user terminal of driving
CN107911541A (en)*2017-11-092018-04-13广州视源电子科技股份有限公司Multi-camera switching use method and device based on Android system
CN113032018A (en)*2019-12-252021-06-25上海博泰悦臻电子设备制造有限公司Improved method for reading command and related device
CN113034873A (en)*2019-12-252021-06-25西安诺瓦星云科技股份有限公司Sensor communication method, device and system
CN113032018B (en)*2019-12-252024-03-01博泰车联网科技(上海)股份有限公司Improved method for read command and related device
CN114020364A (en)*2021-11-162022-02-08北京鲸鲮信息系统技术有限公司Sensor device adapting method and device, electronic device and storage medium
CN114020364B (en)*2021-11-162024-04-26北京字节跳动网络技术有限公司Sensor device adaptation method, device, electronic device and storage medium
CN116708615A (en)*2022-11-152023-09-05荣耀终端有限公司Device registration method, device registration apparatus and storage medium
CN116708615B (en)*2022-11-152024-04-09荣耀终端有限公司Device registration method, device registration apparatus and storage medium
CN116028392A (en)*2022-12-232023-04-28中科驭数(北京)科技有限公司General drive management method, system and equipment oriented to hardware based on KPU architecture
CN116028392B (en)*2022-12-232024-01-09中科驭数(北京)科技有限公司General drive management method, system and equipment oriented to hardware based on KPU architecture

Also Published As

Publication numberPublication date
CN103353835B (en)2016-08-10

Similar Documents

PublicationPublication DateTitle
CN103353835A (en)Migration processing method and device of Android system SensorHal layer compatible kinds of same Sensor devices
CN102521412B (en)Data association device and data association method
CN107678799B (en)Application program control method and device, storage medium and electronic equipment
CN102662665B (en)Input subsystem enabling Android to support various sensors
CN102983999B (en)Method for parameter configuration, the system of a kind of monitor supervision platform system and device cluster
WO2012161435A2 (en)Social information management method and system adapted thereto
WO2020215990A1 (en)Display control method and terminal device
CN103729065A (en)System and method for mapping touch operations to entity keys
CN102843643A (en)Method and apparatus for displaying home screen in mobile terminal
CN104756051A (en)Input location correction tables for input panels
CN107886300A (en)Billboard card management method, apparatus, computer equipment and storage medium
CN114117206B (en)Recommendation model processing method and device, electronic equipment and storage medium
CN101384980A (en)Track information processor, track information processing method, information recording medium, and program
CN114282587A (en)Data processing method and device, computer equipment and storage medium
CN109992980A (en)A kind of user right multi-model management method
CN109918949A (en) Identification method, apparatus, electronic device and storage medium
CN113891270B (en) Electronic device and method for improving positioning smoothness and accuracy
CN107682691A (en)A kind of method, terminal and the computer-readable recording medium of camera focus calibration
CN107357657A (en)A kind of method and apparatus for being used to provide the sub- APP channels of target in application
KR102504325B1 (en)Method of processing touch input on in-cell type touch screen and interactive flat panel display thereof
CN104932749B (en)A kind of Coordinate calculation method of touch point, device and touch-screen equipment
CN106155674A (en)The method and device that report page represents
CN113762585B (en)Data processing method, account type identification method and device
CN101710278B (en)Method and device for generating software system interface
Vainio et al.Estimating the production time of a PCB assembly job without solving the optimised machine control

Legal Events

DateCodeTitleDescription
C06Publication
PB01Publication
C10Entry into substantive examination
SE01Entry into force of request for substantive examination
C14Grant of patent or utility model
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp