Embedded web server based on Linux accesses the implementation method of multi-platform data
Technical field
The present invention relates to a kind of method of web server access platform data, more particularly to a kind of based on the embedding of Linux
Enter the implementation method that formula web server accesses multi-platform data.
Background technology
Be used as using Linux in the embedded device of operating system, each functional module process of linux system offer it
Between and thread between communication.How to realize that accurate and efficient data acquisition turns into the emphasis in research and development under Linux environment
Place.
In the research and development of embedded device, for quick operational outfit and efficient function is provided, it will usually will be multiple flat
The framework of platform is put to be run in the same apparatus, and used data are then respectively stored in corresponding platform, Ge Geping
Platform has the data processing mechanism of oneself.Therefore, when adding web functions, it is necessary to obtain the data of each platform.Due to each flat
The data processing mechanism of platform is different, and platform can not direct access platform data, it may appear that each platform processes data load is not
Consistent situation, cause the operation that have impact on whole equipment, situation as shown in Figure 1.
In addition, in the prior art, number of the embedded device simply by httpd processes by one platform of access after parsing
According to the data of multiple platforms can not be accessed.
The content of the invention
In view of the above the shortcomings that prior art, it is an object of the invention to provide a kind of based on the embedded of Linux
Web server accesses the implementation method of multi-platform data, is realizing preferably transplanting and is not destroying the framework of current each platform
On the basis of, by the data of the multiple different platforms of httpd processes acquisition in linux system, to reach the mesh of page access
's.
In order to achieve the above objects and other related objects, the present invention provides a kind of embedded web server based on Linux
The implementation method of multi-platform data is accessed, is comprised the following steps:Step S1, it is embedded when accessing the web page of embedded device
Formula equipment calls httpd processes receive request of data, and request of data is parsed and decomposed by CGI, and acquisition is asked
The control type of message of data and corresponding decomposition data;Step S2, embedded device is according to the control report of requested data
Literary type, determine platform where data;Judge whether platform where data is current platform;If so, it is transferred to step S3;If it is not,
It is transferred to step S4;Step S3, required data are directly obtained from current platform, and return to embedded device;Step S4,
Client corresponding to platform where accessing data, client corresponding to platform where data visit again corresponding service end, corresponding
Service end required data are being obtained where data on platform, and client corresponding to platform where being back to data, number
Required data are returned into embedded device according to client corresponding to the platform of place.
The implementation method of multi-platform data is accessed according to the above-mentioned embedded web server based on Linux, wherein:With
The web page for the browser access embedded device that family end passes through equipment.
The implementation method of multi-platform data is accessed according to the above-mentioned embedded web server based on Linux, wherein:Obtain
When taking the control type of message of requested data, matched by the name of the page to determine.
The implementation method of multi-platform data is accessed according to the above-mentioned embedded web server based on Linux, wherein:Institute
State in step S1, CGI processing procedure comprises the following steps:
CGI receives the request of data that httpd processes receive;
Whether the heading for judging request of data is to set operation;
If setting operation, receive httpd and request of data is set, parsed according to the page of request of data, and by page
The given data page in face and data structure table is matched;If the page of matching be present, the function number that needs are set
According to being stored in temporal cache, by page index by the page preservation in need performance data be sent to it is corresponding flat
Platform, platform receives data and handled, and result is returned;If in the absence of the page of matching, the request of data is abandoned,
CGI sends result to httpd, then the http clients of request data are sent to by httpd;
If not setting operation, receive httpd and obtain request of data, page data is received, according to the page of request of data
Parsed, and the given data page in the page and data structure table is matched;If the page of matching be present, pass through
Page index obtains all data of page needs from the platform at place, by the data storage of acquisition in temporal cache, solution
The functional parameter needed in the analysis page, by functional parameter table, obtains data from temporal cache, and returns to httpd,
Httpd is then forwarded to the http clients of request data;If in the absence of the page of matching, the request of data is abandoned, CGI will be tied
Fruit is sent to httpd, then the http clients of request data are sent to by httpd.
The implementation method of multi-platform data is accessed according to the above-mentioned embedded web server based on Linux, wherein:Institute
State in step S4, it is required when required data are returned to embedded device by client corresponding to platform where data
Data return to the httpd processes of embedded device, and required data are returned to browser by httpd processes again, so as to
See the page info of embedded device in family.
The implementation method of multi-platform data is accessed according to the above-mentioned embedded web server based on Linux, wherein:Institute
State in step S4, the communication mechanism between client and service end is completed using Linux ipc communication mechanisms.
The implementation method of multi-platform data is accessed according to the above-mentioned embedded web server based on Linux, wherein:Institute
State in step S4, the process of client to service end is thread to process, process-to-process, thread to thread or process to line
Journey.
As described above, the embedded web server based on Linux of the present invention accesses the implementation method of multi-platform data,
Have the advantages that:
(1) realize preferably transplanting and do not destroy the framework of current each platform;
(2) access of the web server to the data message of multiple different platforms is realized;
(3) it is easy to transplant, it is easy to maintain.
Brief description of the drawings
Fig. 1 is shown as the schematic diagram that multiple platforms in the prior art each carry out data processing;
Fig. 2 is shown as the implementation method of the multi-platform data of the access of the embedded web server based on Linux of the present invention
Block flow diagram;
Fig. 3 is shown as the process chart of CGI in the present invention;
Fig. 4 is shown as the implementation method of the multi-platform data of the access of the embedded web server based on Linux of the present invention
Detail flowchart;
Fig. 5 is shown as in the present invention schematic diagram of the communication mechanism between client and service end.
Embodiment
Illustrate embodiments of the present invention below by way of specific instantiation, those skilled in the art can be by this specification
Disclosed content understands other advantages and effect of the present invention easily.The present invention can also pass through specific realities different in addition
The mode of applying is embodied or practiced, the various details in this specification can also be based on different viewpoints with application, without departing from
Various modifications or alterations are carried out under the spirit of the present invention.
It should be noted that the diagram provided in the present embodiment only illustrates the basic conception of the present invention in a schematic way,
Then the component relevant with the present invention is only shown in schema rather than is painted according to component count, shape and the size during actual implement
System, kenel, quantity and the ratio of each component can be a kind of random change during its actual implementation, and its assembly layout kenel also may be used
Can be increasingly complex.
In the present invention, web server needs cross-platform access of the realization to data, wherein it is cross-platform refer to operate in it is a variety of
Process or thread on different frameworks.
Reference picture 2, the embedded web server of the invention based on Linux access the implementation method bag of multi-platform data
Include following steps:
Step S1, when user terminal accesses the web page of embedded device, embedded device calls httpd processes to receive
Request of data, and by CGI(Common gateway interface) (Common Gateway Interface, CGI) to request of data carry out parsing and
Decompose, obtain the control type of message of requested data and corresponding decomposition data.
Specifically, the web page that user terminal passes through equipment such as PC browser access embedded device.In embedded device
The httpd processes of current platform receive the http request of data, and are parsed and decomposed by CGI, the number of request to obtain
According to control type of message.Wherein, when obtaining the control type of message of requested data, by the name of the page matched come
It is determined that.
Reference picture 3, CGI processing procedure comprise the following steps:
CGI receives the request of data that httpd processes receive.
Whether the heading for judging request of data is to set (set) to operate.
If set is operated, receive httpd and request of data is set, parsed according to the page of request of data, and by the page
Matched with the given data page in data structure table;If the page of matching be present, the performance data that needs are set
Be stored in temporal cache, by page index by the page the performance data of preservation in need be sent to corresponding platform,
Platform receives data and handled, and result is returned;If in the absence of the page of matching, the request of data, CGI are abandoned
Httpd is sent result to, then the http clients of request data are sent to by httpd.
If not set is operated, receive httpd and obtain request of data, receive page data, entered according to the page of request of data
Row parsing, and the given data page in the page and data structure table is matched;If the page of matching be present, pass through page
Face index obtains all data that the page needs from the platform at place, by the data storage of acquisition in temporal cache, parsing
The functional parameter needed in the page, by functional parameter table, data are obtained from temporal cache, and return to httpd, httpd
It is then forwarded to the http clients of request data;If in the absence of the page of matching, the request of data is abandoned, CGI sends out result
Httpd is given, then the http clients of request data are sent to by httpd.
Step S2, embedded device determines platform where data according to the control type of message of requested data;Judge number
Whether it is current platform according to place platform;If so, it is transferred to step S3;If it is not, it is transferred to step S4.
Step S3, required data are directly obtained from current platform, and return to embedded device.
Step S4, client corresponding to platform where accessing data, client corresponding to platform where data visit again pair
The service end answered, corresponding service end is obtaining required data on platform where data, and be back to platform where data
Corresponding client, client corresponding to platform where data are finally returned to embedded device.
For example, referring to Fig. 4, when being searched by the name of the page, the data of the page are matched in platform a, that
The request data into docking platform a client;When the client for docking a receives request of data, platform a can be sent to
Service end, after platform a service end receives the request of data, the data required by middle taking-up in a platforms, and data are returned
To docking platform a client, docking platform a client returns again to the httpd processes to embedded device after receiving data,
Httpd processes finally return data to web browser so that user can see the page info of embedded device.Equally,
It is same to obtain the data of b platforms, will not be repeated here.
, wherein it is desired to illustrate, the communication mechanism in step S4 between client and service end is the ipc using Linux
Communication mechanism is completed, as shown in Figure 5.Specifically, the process of client to service end can be thread to process, process to entering
Journey, thread to thread or process are to thread.The framework form of each platform is specifically dependent upon, linux system provides these sides
The communication mechanism of formula.
In summary, the embedded web server of the invention based on Linux accesses the implementation method reality of multi-platform data
Show more preferable transplanting and do not destroy the framework of current each platform;Realize data of the web server to multiple different platforms
The access of information, it is easy to transplant, it is easy to maintain.So the present invention effectively overcomes various shortcoming of the prior art and has height
Spend industrial utilization.
The above-described embodiments merely illustrate the principles and effects of the present invention, not for the limitation present invention.It is any ripe
Know the personage of this technology all can carry out modifications and changes under the spirit and scope without prejudice to the present invention to above-described embodiment.Cause
This, those of ordinary skill in the art is complete without departing from disclosed spirit and institute under technological thought such as
Into all equivalent modifications or change, should by the present invention claim be covered.