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.
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_name | The title of the module of supporting |
| gsensor_direct_x | X-direction |
| gsensor_direct_y | Y direction |
| gsensor_direct_z | Z-direction |
| gsensor_xy_revert | Whether 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.