Summary of the invention
The invention provides the migration process method and device of the compatible multiple Sensor equipment of the same race of a kind of android system Sensor HAL layer, realize the compatibility of multiple Sensor equipment, and can judge that hardware device is to carry out the realization of the corresponding interface dynamically, such that it is able to replace Sensor equipment easily and fast, without carrying 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 system Sensor HAL layer that the present invention provides, specifically include following steps:
Drive according to the Sensors supported in linux system, Sensor HAL layer is carried out initialization process;When initializing, title and the conversion value of all modules driving platform to be supported is set;Preset Gsensor direction value path and the path of Sensor equipment, preset the identification title of Gsensor direction variable and configure corresponding direction variable configuration file;For different Sensor equipment, corresponding Sensor_t structure is set;Wherein, the title of each module of setting and the device name one_to_one corresponding in Sensor facility registration to Linux input subsystem;
After the Driver of Sensors equipment is registered to the input subsystem of Linux, the node that Sensors HAL layer is corresponding according to generating Sensors equipment, determine title and the module obtaining current registered Sensors equipment;
After Android HAL layer determines and obtains current registered Sensor device name, path according to default Sensor device orientation value, read described direction variable configuration file and resolve the Sensor direction value preset, the Sensor direction value preset described in comparison and required Sensor direction value, adjust the direction of Sensor equipment;
Obtain the Sensor_t structure information that Sensor equipment is corresponding, the module used is added in sensor list, it is achieved described module is registered to Android layer in hardware;
Described Android layer starts the poll function in corresponding thread dispatching Sensors HAL layer and obtains the data of bottom relevant device.
It is preferred that as a kind of embodiment, the described title arranging all modules driving platform to be supported and conversion value comprise the steps:
After the title determining all modules driving platform to be supported and conversion value, utilize device name and the conversion value of Sensor of structure name record module;Wherein: conversion value is the maximum 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, the direction being respectively provided with the X, Y, Z axis of corresponding module and the mark whether XY axle exchanged;The identification title of described Gsensor direction variable is for identifying the direction value of Sensor equipment;The Gsensor direction variable information configuration of setting and is preserved in direction variable configuration file Gsensor.cfg;
Described corresponding Sensor_t structure is set for different Sensor equipment, comprises the steps:
According to different Sensor equipment, the description information of corresponding Sensor_t structure is set.
It is preferred that as a kind of embodiment, described Sensors HAL layer, according to generating the node corresponding with Sensors equipment, determines title and the module of the current registered Sensors equipment of acquisition, comprises the steps:
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 described current Sensors equipment node one to one storage position, finds the input equipment storage position that described current Sensors equipment is corresponding;
Wherein: the node of described equipment is present under "/sys/class/input/inputX " catalogue, and X is positive integer, X numerical value is equal to the input sequence sequence number corresponding according to the input equipment of linux system;X numerical value carries out ascending order arrangement along with input sequence;
Utilize the title of Sensors equipment under function read reading/sys/class/input/inputX;
The title of the Sensors equipment of described reading is compared with the title of Sensors equipment driving platform to arrange, finds the consistent module of title with the Sensors equipment of described reading in hardware;
Determine node path and the value of X of current registered Sensors equipment.
It is preferred that as a kind of embodiment, described read direction variable configuration file also resolves Sensor direction value, the Sensor direction value preset described in comparison and required Sensor direction value, adjust the direction of Sensor equipment, comprise the steps:
Utilize function Gsensor_cfg read direction variable configuration file Gsensor.cfg, all modules of record determine in described Gsensor.cfg file the module mated with the Sensor device name read, and resolves the Sensor direction value that corresponding coupling module is preset;
Wherein, described Gsensor.cfg file is for recording the direction value of all modules driving platform to support;
When reading true value, default Sensor direction value is positive direction value;When reading false value, default Sensor direction value is negative direction value;Described positive direction value is positive number+1, and described negative direction value is negative-1;Judge that the direction value of required Sensor is the most consistent with the Sensor direction value preset, if it is judged that be consistent, then will need not adjust the direction of Sensor;If it is judged that be inconsistent, by the direction adjusting Sensor it is and the opposite direction presetting Sensor direction then.
It is preferred that as a kind of embodiment, the Sensor_t structure information that described acquisition Sensor equipment is corresponding, the module used is added in sensor list, comprise the steps: in hardware
The driving platform at the title place according to module stores position, obtains corresponding Sensor_t structure information, utilize get_sensors_list function to be added in sensor list by the module used in hardware;
Poll function in described startup corresponding thread dispatching Sensors HAL layer obtains the data of bottom relevant device and comprises the steps:
Utilize Poll function to report value by reading in real time, carry out corresponding data conversion according to conversion formula, and use numerically offering android system after conversion;
Described conversion formula is: numerical value=(G/ conversion value) × direction value × report value after conversion;
Wherein: G is unit value and is constant, and the G-value that different types of Sensor equipment is corresponding is different;Conversion value is constant, and the conversion value that different types of Sensor equipment is corresponding is different;
Described Sensor_t structure is used for describing Sensor equipment characteristic information;Information described by described Sensor_t structure includes the title of sensor, 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, interval of events minimum time.
Correspondingly, present invention also offers the migration process device of the compatible multiple Sensor equipment of the same race of a kind of android system Sensor HAL layer, module and data read module is added, wherein including initialization module, equipment read module, direction adjusting module, module:
Described initialization module, for driving according to the Sensors supported in linux system, carries out initialization process to SensorHAL layer;When initializing, title and the conversion value of all modules driving platform to be supported is set;Preset Gsensor direction value path and the path of Sensor equipment, preset the identification title of Gsensor direction variable and configure corresponding direction variable configuration file;For different Sensor equipment, corresponding Sensor_t structure is set;Wherein, the title of each module of setting and the device name one_to_one corresponding in Sensor facility registration to Linux input subsystem;
Described equipment read module, is used for after the Driver of Sensors equipment is registered to the input subsystem of Linux, the node that Sensors HAL layer is corresponding according to generating Sensors equipment, determines title and the module obtaining current registered Sensors equipment;
Described direction adjusting module, after determining obtain current registered Sensor device name at Android HAL layer, path according to default Sensor device orientation value, read described direction variable configuration file and resolve the Sensor direction value preset, the Sensor direction value preset described in comparison and required Sensor direction value, adjust the direction of Sensor equipment;
Described module adds module, for obtaining the Sensor_t structure information that Sensor equipment is corresponding, is added to by the module used in sensor list, it is achieved described module is registered to Android layer in hardware;
Described data read module, starts the poll function in corresponding thread dispatching Sensors HAL layer for described Android layer and obtains the data of bottom relevant device.
It is preferred that as a kind of embodiment, described initialization module includes that record sub module, direction are preset submodule and first and arranged submodule, wherein:
Record sub module, for after the title determining all modules driving platform to be supported and conversion value, utilizes device name and the conversion value of Sensor of structure name record module;Wherein: conversion value is the maximum that the Driver of Sensor equipment reports;
Submodule is preset in described direction, for the title according to different modules, the direction being respectively provided with the X, Y, Z axis of corresponding module and the mark whether exchanged by XY axle;The identification title of described Gsensor direction variable is for identifying the direction value of Sensor equipment;The Gsensor direction variable information configuration of setting and is preserved in direction variable configuration file Gsensor.cfg;
Described first arranges submodule, for according to different Sensor equipment, arranging the description information of corresponding Sensor_t structure.
It is preferred that as a kind of embodiment, described equipment read module includes searching submodule, the first reading submodule, comparer module and determining submodule, wherein:
Described lookup submodule, after being registered to the input subsystem of Linux at the Driver of current Sensors equipment, that Sensors HAL layer generates according to described input subsystem and with described current Sensors equipment node one to one storage position, finds the input equipment storage position that described current Sensors equipment is corresponding;
Wherein: the node of described equipment is present under "/sys/class/input/inputX " catalogue, and X is positive integer, X numerical value is equal to the input sequence sequence number corresponding according to the input equipment of linux system;X numerical value carries out ascending order arrangement along with input sequence;
Described first reading submodule, is used for utilizing the title of the Sensors equipment under function read reading/sys/class/input/inputX;
Described comparer module, for the title of the title of the Sensors equipment of described reading with the Sensors equipment driving platform setting being compared, finds the consistent module of title with the Sensors equipment of described reading in hardware;
Described determine submodule, for determining node path and the value of X of current registered Sensors equipment.
It is preferred that as a kind of embodiment, described direction adjusting module includes mating analyzing sub-module and adjusting submodule, wherein:
Described coupling analyzing sub-module, for utilizing function Gsensor_cfg read direction variable configuration file Gsensor.cfg, all modules of record determine in described Gsensor.cfg file the module mated with the Sensor device name read, and resolves the Sensor direction value that corresponding coupling module is preset;
Wherein, described Gsensor.cfg file is for recording the direction value of all modules driving platform to support;
Described adjustment submodule, for when reading true value, default Sensor direction value is positive direction value;When reading false value, default Sensor direction value is negative direction value;Described positive direction value is positive number+1, and described negative direction value is negative-1;Judge that the direction value of required Sensor is the most consistent with the Sensor direction value preset, if it is judged that be consistent, then will need not adjust the direction of Sensor;If it is judged that be inconsistent, by the direction adjusting Sensor it is and the opposite direction presetting Sensor direction then.
It is preferred that as a kind of embodiment, described module adds module and includes that module adds submodule, wherein:
Described module adds submodule, for according to storing position in the driving platform at the title place of module, obtaining corresponding Sensor_t structure information, utilize get_sensors_list function to be added in sensor list by the module used in hardware;
Described data read module includes that data convert and reports submodule, wherein:
Described data convert and report submodule, are used for utilizing Poll function to report value by reading in real time, carry out corresponding data conversion according to conversion formula, and use numerically offering android system after conversion;
Described conversion formula is: numerical value=(G/ conversion value) × direction value × report value after conversion;
Wherein: G is unit value and is constant, and the G-value that different types of Sensor equipment is corresponding is different;TurnChanging value is constant, and the conversion value that different types of Sensor equipment is corresponding is different.
The beneficial effect comprise that
The migration process method and device of the compatible multiple Sensor equipment of the same race of a kind of android system Sensor HAL layer that the present invention provides, wherein method includes arranging initiation parameter;Read the device name of registration in device drives, and mate with defined device name, determine the Sensor equipment used in system;Resolve configuration file, need the parameter value carrying out changing that the adjustment with direction is set according to direction value and the different Sensor of corresponding module in the title reading configuration file of module;According to the title of facility registration in the driving read, add corresponding equipment to sensor list;Android system starts the poll function in corresponding thread dispatching Sensors HAL layer and obtains the data of bottom relevant device.The migration process method and device of the compatible multiple Sensor equipment of the same race of the android system Sensor HAL layer that the present invention provides can judge that hardware device is to carry out the realization of the corresponding interface dynamically, thus replace Sensor equipment rapidly and realize the adjustment of Sensor device orientation, without carrying out new compiling and configuration operation.
Detailed description of the invention
Below in conjunction with Figure of description, the detailed description of the invention of the migration process method and device of multiple of the same race Sensor equipment compatible to the android system Sensor HAL layer in the embodiment of the present invention illustrates.
The hardware of Sensors is taken out as in layer, the structure having several key needs user to process, such as: sensors_module_t structure is used for defining sensor module, sensor_t structure is used for defining a sensors equipment, sensors_event_t is used for defining 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 system Sensor HAL layer that the embodiment of the present invention provides, for adapting to the migration process of multiple Sensor equipment of the same race.
Fig. 3 is the flow chart of the migration process method of the compatible multiple Sensor equipment of the same race of android system Sensor HAL layer of the embodiment of the present invention.As it is shown on figure 3, the method that the present embodiment is used includes following several step:
S100, according in linux system support Sensors drive, Sensor HAL layer is carried out initialization process;When initializing, title and the conversion value of all modules driving platform to be supported is set;Preset Gsensor direction value path and the path of Sensor equipment, preset the identification title of Gsensor direction variable and configure corresponding direction variable configuration file;For different Sensor equipment, corresponding Sensor_t structure is set;Wherein, the title of each module of setting and the device name one_to_one corresponding in Sensor facility registration to Linux input subsystem;
S200, after the Driver of Sensors equipment is registered to the input subsystem of Linux, Sensors HAL layer, according to generating node corresponding to Sensors equipment, determines title and the module obtaining current registered Sensors equipment.
S300, after Android HAL layer determines and obtains current registered Sensor device name, path according to default Sensor device orientation value, read described direction variable configuration file and resolve the Sensor direction value preset, the Sensor direction value preset described in comparison and required Sensor direction value, adjust the direction of Sensor equipment;
S400, the Sensor_t structure information that acquisition Sensor equipment is corresponding, add to the module used in hardware in sensor list, it is achieved described module is registered to Android layer;
S500, described Android layer start the poll function in corresponding thread dispatching Sensors HAL layer and obtain the data of bottom relevant device.
The above steps of the migration process method that the embodiment of the present invention realizes android system Sensor HAL layer compatible multiple Sensor equipment of the same race below is described in detail:
It is preferred that as a kind of embodiment, in described step S100, the described title arranging all modules driving platform to be supported and conversion value comprise the steps:
S101, after determining the title of all modules and conversion value driving platform to be supported, utilize device name and the conversion value of Sensor of structure name record module;Wherein: conversion value is the maximum that the Driver of Sensor equipment reports;
In above-mentioned steps S101, drive at array Linux Sensor and on platform, initiation parameter is set, arranging the title of the Gsensor module supported in system, this title needs consistent with the title of facility registration in driving, and purpose is for being used for the system that identifies the most chartered hardware device module.
As shown in Figure 4, Fig. 4 illustrates the related content of described Name structure definition.
In above-mentioned steps S100, preset Gsensor direction value path and the path of Sensor equipment, see Fig. 5, Fig. 5 and illustrate the fixed route (including presetting Gsensor direction value path and the path of 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 includes following steps:
S102, title according to different modules, the direction being respectively provided with the X, Y, Z axis of corresponding module and the mark whether XY axle exchanged;The identification title of described Gsensor direction variable is for identifying the direction value of Sensor equipment;The Gsensor direction variable information configuration of setting and is preserved in direction variable configuration file Gsensor.cfg;See the Gsensor direction variable information that Fig. 6, Fig. 6 illustrate to arrange.
The direction configuration of each module all only has five, shown in concrete implication such as following table (table 1):
| gsensor_name | The title of the module supported |
| gsensor_direct_x | X-direction |
| gsensor_direct_y | Y direction |
| gsensor_direct_z | Z-direction |
| gsensor_xy_revert | XY direction is the need of reversion |
Table 1
In described step S100, described corresponding Sensor_t structure is set for each Sensor equipment, specifically includes following steps:
S103, according to different Sensor equipment, the description information of corresponding Sensor_t structure is set;See Fig. 7, Fig. 7 to illustrate embodiment of the present invention migration process method and implement the description information arranging Sensor_t structure.
When configuration parameter, need to arrange Gsensor direction variable, the path of configuration parameter file;And the information such as the Sensor_t structure that respective Sensor is set.
It is preferred that as a kind of embodiment, described Sensor_t structure is used for describing Sensor equipment characteristic information;Information described by described Sensor_t structure includes the information such as the title of sensor, 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, interval of events minimum time.Any one sensor equipment being required for arranging a sensor_t structure, illustrates, Fig. 7 illustrates the particular content of above-mentioned information.Information described by Sensor_t structure includes above-mentioned information, but is not limited to this, and this is repeated by the embodiment of the present invention the most one by one.
Specifically, because the structure of Sensor_t that different module uses describes information and differs use, therefore all use Sensor_t structure to describe accordingly the module supported, describe calling of information accordingly according to the hardware device read.
It is preferred that as a kind of embodiment, in described step S200, described Sensors HAL layer, according to generating the node corresponding with Sensors equipment, determines title and the module of the current registered Sensors equipment of acquisition, comprises the steps:
S201, 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 described current Sensors equipment node one to one storage position, finds the input equipment storage position that described current Sensors equipment is corresponding;
Wherein: the node of described equipment is present under "/sys/class/input/inputX " catalogue, and X is positive integer, X numerical value is equal to the input sequence sequence number corresponding according to the input equipment of linux system;X numerical value carries out ascending order arrangement along with input sequence;Such as: the node of Input equipment is present under "/sys/class/input/inputX " catalogue, 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, the title of the Sensors equipment utilized under function read reading/sys/class/input/inputX;
S203, the title of the Sensors equipment of described reading is compared with the title of Sensors equipment driving platform to arrange, find the consistent module of title with the Sensors equipment of described reading in hardware;
S204, the node path determining current registered Sensors equipment and the value of X.
In above-mentioned steps S200, when the Driver of Sensors equipment is by input (input) subsystem being registered to linux, it will generate the node corresponding with equipment, Sensors HAL layer can find corresponding equipment according to the node generated.(operate hardware device and i.e. operate the function interface of respective nodes).
It is preferred that as a kind of embodiment, in described step S300, described read direction variable configuration file also resolves Sensor direction value, the Sensor direction value preset described in comparison and required Sensor direction value, adjust the direction of Sensor equipment, comprise the steps:
Utilize function Gsensor_cfg read direction variable configuration file Gsensor.cfg, all modules of record determine in described Gsensor.cfg file the module mated with the Sensor device name read, and resolves the Sensor direction value that corresponding coupling module is preset;
Wherein, described Gsensor.cfg file is for recording the direction value of all modules driving platform to support;
When reading true value, default Sensor direction value is positive direction value;When reading false value, default Sensor direction value is negative direction value;Described positive direction value is positive number+1, and described negative direction value is negative-1;Judge that the direction value of required Sensor is the most consistent with the Sensor direction value preset, if it is judged that be consistent, then will need not adjust the direction of Sensor;If it is judged that be inconsistent, by the direction adjusting Sensor it is and the opposite direction presetting Sensor direction then.As shown in Figure 8, Fig. 8 illustrates the reading acetonideexample of a Sensor equipment.
It is preferred that as a kind of embodiment, in described S400 step, the Sensor_t structure information that described acquisition Sensor equipment is corresponding, the module used is added in sensor list, comprise the steps: in hardware
The driving platform at the title place according to module stores position, obtains corresponding Sensor_t structure information, utilize get_sensors_list function to be added in sensor list by the module used in hardware;
In described S500 step, the poll function in described startup corresponding thread dispatching Sensors HAL layer obtains the data of bottom relevant device and comprises the steps:
Utilize Poll function to report value by reading in real time, carry out corresponding data conversion according to conversion formula, and use numerically offering android system after conversion;
Described conversion formula is: numerical value=(G/ conversion value) × direction value × report value after conversion;
Wherein: G is unit value and is constant, and the G-value that different types of Sensor equipment is corresponding is different;Conversion value is constant, and the conversion value that different types of Sensor equipment is corresponding is different.
For example, conversion formula (G/ conversion value) × direction value × report value is utilized) i.e. can get spendable numerical value in system, G is unit value, and the G-value such as Gsensor is 9.81.Conversion value is also the constant arranged, and obtain only in real time reports value different, and the most above-mentioned formula can realize the conversion operation of data.By perform conversion operation, the data that Driver is reported be converted to android system can data.
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 reported in Driver is int categorical data, and the float type used in android system, and Sensors has special unit value and numerical range, if gravity sensing sensor is with G(9.81) for maximum output valve, it is therefore desirable to the data that Driver is reported be converted to android system can data.
Generally speaking, the migration process method that the embodiment of the present invention is provided is achieved by the steps of:
The first step: initiation parameter is set;
Second step: read the device name of registration in device drives, and carry out mating so that it is determined that the Sensor equipment that uses in system with defined device name;
3rd step: resolve configuration file, reads the direction value of corresponding module in gSensor.cfg according to the title of module, and different Sensor needs the parameter value that carries out changing;Have only to when poor direction is true revise the parameter in this file;
4th step: according to reading the title of facility registration in driving, add corresponding sensor list;
5th step: android system starts the poll function in corresponding thread dispatching Sensors HAL layer and obtains the data of bottom relevant device.
The migration process method essence that the embodiment of the present invention is provided is: in being driven by reading, the device name of registration carries out calling of corresponding Gsensor interface dynamically, the direction of Gsensor is extracted one configuration file of formation, it is gsensor.cfg file by the name definition of this document, deposit in system /system/usr/ path under, the direction of all Gsensor supported in system is write wherein;By to drive in the device name that reads carry out mating and resolve configuration file and obtain the information such as transfer parameter value of the direction value of used Gsensor and the use of corresponding Sensor_t structure, module.
Wherein, the hardware abstraction layer of the Sensor that the embodiment of the present invention is provided mainly is called by poll and returns the data obtained from lower floor, changes accordingly and reports system use afterwards.Hardware abstraction layer need the structure building a Sensor_t type represent corresponding equipment module;Process for data, mainly conversion parameter and direction, the precision of different modules and resolution are all different, and the key point that therefore the multiple Sensor of hardware abstraction layer realizes is Sensor_t structure, the process of module direction and precision resolution etc..The migration process method that the embodiment of the present invention is provided can compatible multiple Gsensor equipment, by judging that hardware device carries out the realization of the corresponding interface dynamically, Sensor equipment can be replaced quickly and easily and realize the adjustment of Sensor device orientation rapidly, without carrying out new compiling and configuration.
Based on same inventive concept, the embodiment of the present invention additionally provides the migration process device of the compatible multiple Sensor equipment of the same race of a kind of android system Sensor HAL layer, owing to the migration process method of the principle of this device solution problem multiple of the same race Sensor equipment compatible to aforementioned a kind of android system Sensor HAL layer is similar, therefore the enforcement of this device may refer to the enforcement of preceding method, repeats no more in place of repetition.
The migration process device 10 of the compatible multiple Sensor equipment of the same race of a kind of android system Sensor HAL layer that the embodiment of the present invention provides, as shown in Figure 9, described migration process device 10 includes 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, for driving according to the Sensors supported in linux system, carries out initialization process to Sensor HAL layer;When initializing, title and the conversion value of all modules driving platform to be supported is set;Preset Gsensor direction value path and the path of Sensor equipment, preset the identification title of Gsensor direction variable and configure corresponding direction variable configuration file;For different Sensor equipment, corresponding Sensor_t structure is set;Wherein, the title of each module of setting and the device name one_to_one corresponding in Sensor facility registration to Linux input subsystem;
Described equipment read module 92, is used for after the Driver of Sensors equipment is registered to the input subsystem of Linux, the node that Sensors HAL layer is corresponding according to generating Sensors equipment, determines title and the module obtaining current registered Sensors equipment;
Described direction adjusting module 93, after determining obtain current registered Sensor device name at Android HAL layer, path according to default Sensor device orientation value, read described direction variable configuration file and resolve the Sensor direction value preset, the Sensor direction value preset described in comparison and required Sensor direction value, adjust the direction of Sensor equipment;
Described module adds module 94, for obtaining the Sensor_t structure information that Sensor equipment is corresponding, is added to by the module used in sensor list, it is achieved described module is registered to Android layer in hardware;
Described data read module 95, starts the poll function in corresponding thread dispatching Sensors HAL layer for described Android layer and obtains the data of bottom relevant device.
It is preferred that as a kind of embodiment, described initialization module 91 includes that record sub module, direction are preset submodule and first and arranged submodule, wherein:
Record sub module, for after the title determining all modules driving platform to be supported and conversion value, utilizes device name and the conversion value of Sensor of structure name record module;Wherein: conversion value is the maximum that the Driver of Sensor equipment reports;
Submodule is preset in described direction, for the title according to different modules, the direction being respectively provided with the X, Y, Z axis of corresponding module and the mark whether exchanged by XY axle;The identification title of described Gsensor direction variable is for identifying the direction value of Sensor equipment;The Gsensor direction variable information configuration of setting and is preserved in direction variable configuration file Gsensor.cfg;
Described first arranges submodule, for according to different Sensor equipment, arranging the description information of corresponding Sensor_t structure.
It is preferred that as a kind of embodiment, described equipment read module 92 includes searching submodule, the first reading submodule, comparer module and determining submodule, wherein:
Described lookup submodule, after the input subsystem being registered to Linux at the Driver of current Sensors equipment, that Sensors HAL layer generates according to described input subsystem and with described current Sensors equipment node one to one storage position, finds the input equipment storage position that described current Sensors equipment is corresponding;
Wherein: the node of described equipment is present under "/sys/class/input/inputX " catalogue, and X is positive integer, X numerical value is equal to the input sequence sequence number corresponding according to the input equipment of linux system;X numerical value carries out ascending order arrangement along with input sequence;
Described first reading submodule, is used for utilizing the title of the Sensors equipment under function read reading/sys/class/input/inputX;
Described comparer module, for the title of the title of the Sensors equipment of described reading with the Sensors equipment driving platform setting being compared, finds the consistent module of title with the Sensors equipment of described reading in hardware;
Described determine submodule, for determining node path and the value of X of current registered Sensors equipment.
It is preferred that as a kind of embodiment, described direction adjusting module 93 includes mating analyzing sub-module and adjusting submodule, wherein:
Described coupling analyzing sub-module, for utilizing function Gsensor_cfg read direction variable configuration file Gsensor.cfg, all modules of record determine in described Gsensor.cfg file the module mated with the Sensor device name read, and resolves the Sensor direction value that corresponding coupling module is preset;
Wherein, described Gsensor.cfg file is for recording the direction value of all modules driving platform to support;
Described adjustment submodule, for when reading true value, default Sensor direction value is positive direction value;When reading false value, default Sensor direction value is negative direction value;Described positive direction value is positive number+1, and described negative direction value is negative-1;Judge that the direction value of required Sensor is the most consistent with the Sensor direction value preset, if it is judged that be consistent, then will need not adjust the direction of Sensor;If it is judged that be inconsistent, by the direction adjusting Sensor it is and the opposite direction presetting Sensor direction then.
It is preferred that as a kind of embodiment, described module adds module 94 and includes that module adds submodule, wherein:
Described module adds submodule, for according to storing position in the driving platform at the title place of module, obtaining corresponding Sensor_t structure information, utilize get_sensors_list function to be added in sensor list by the module used in hardware;
Described data read module 95 includes that data convert and reports submodule, wherein:
Described data convert and report submodule, are used for utilizing Poll function to report value by reading in real time, carry out corresponding data conversion according to conversion formula, and use numerically offering android system after conversion;
Described conversion formula is: numerical value=(G/ conversion value) × direction value × report value after conversion;
Wherein: G is unit value and is constant, and the G-value that different types of Sensor equipment is corresponding is different;Conversion value is constant, and the conversion value that different types of Sensor equipment is corresponding is different.
The migration process method and device of the compatible multiple Sensor equipment of the same race of a kind of android system Sensor HAL layer that the embodiment of the present invention provides, wherein method includes arranging initiation parameter;Read the device name of registration in device drives, and mate with defined device name, determine the Sensor equipment used in system;Resolve configuration file, need the parameter value carrying out changing that the adjustment with direction is set according to direction value and the different Sensor of corresponding module in the title reading configuration file of module;According to the title of facility registration in the driving read, add corresponding equipment to sensor list;Android system starts the poll function in corresponding thread dispatching Sensors HAL layer and obtains the data of bottom relevant device.
The compatible multiple Sensor equipment of migration process method and device of the compatible multiple Sensor equipment of the same race of the android system Sensor HAL layer that the embodiment of the present invention provides, can judge that hardware device is to carry out the realization of the corresponding interface dynamically, thus replace Sensor equipment rapidly and realize the adjustment of Sensor device orientation, without carrying out new compiling and configuration operation.
Embodiment described above only have expressed the several embodiments of the present invention, and it describes more concrete and detailed, but therefore can not be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that, for the person of ordinary skill of the art, without departing from the inventive concept of the premise, it is also possible to make some deformation and improvement, these broadly fall into protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.