CN101409731A - Remote control method for household electrical equipment through IE - Google Patents

Remote control method for household electrical equipment through IE Download PDF

Info

Publication number
CN101409731A
CN101409731A CNA2008102009791A CN200810200979A CN101409731A CN 101409731 A CN101409731 A CN 101409731A CN A2008102009791 A CNA2008102009791 A CN A2008102009791A CN 200810200979 A CN200810200979 A CN 200810200979A CN 101409731 A CN101409731 A CN 101409731A
Authority
CN
China
Prior art keywords
cgi
parameter
client
webpage
embedded
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CNA2008102009791A
Other languages
Chinese (zh)
Inventor
王真星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Polytechnic University
Original Assignee
Shanghai Polytechnic University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Polytechnic University filed Critical Shanghai Polytechnic University
Priority to CNA2008102009791A priority Critical patent/CN101409731A/en
Publication of CN101409731A publication Critical patent/CN101409731A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention relates to a method for remote control of household electric appliances and devices by an IE, which comprises the following steps: a client logs in an embedded network server by the IE; a CGI script in the embedded network server reads an HTML page till the cache; the CGI script sends the page P1 to the IE at the client; the CGI reads parameters from Shell of Linux, embedded data or a drive; the CGI carries out the data conversion of the parameters and then sends to the IE at the client; the client is embedded in a script program in the page P1 to read the parameters and gives values to variables at the corresponding positions on the page; the client sends new parameters which are input by a user to the CGI by a POST method of an HTML form; the CGI receives the parameters and calls an application program, and the parameters obtained by the application program are transmitted to the Shell of the Linux by a system function of the Linux; and the application program uses the parameters which are sent by the CGI to call a drive program and finally controls hardware. The method separates the CGI, the drive program and the application program which uses the drive, and the parameters are transferred between the CGI and the application program through the Linux shell, thereby improving the development efficiency.

Description

By the long-range method of IE to the household appliances Equipment Control
Technical field
The present invention relates to a kind of by the long-range method of IE to the household appliances Equipment Control.
Background technology
At present, built-in Linux is in consumer electronics and set-top box, remote measuring and controlling system, and aspects such as digital television receiver obtain to use widely.A lot of products provide network access facility, can insert by WiFi or wired mode.For example: Household intelligent gateway just can come system's setting, control and monitoring by web interface by the webpage above the remote computer visit.At present, the realization of main flow has following two kinds:
A kind of is by needing mutual interface to realize with ActiveX, ActiveX (referring to operate in the assembly in the service processes) is packaged into the CAB file, and realizing by being embedded in the webpage the inside.This mode has individual shortcoming: client must be used on the platform of Microsoft, if just problem is arranged with the Netscape network flow browser of Linux, has said nothing of with mobile phone.
The another kind of CGI (Common Gateway Interface, gateway interface usually) that adopts realizes, CGI is a kind of input based on browser, go up the program technic of operation at the webserver (Webserver).But the problem that CGI realizes is that the interface is not allowed to be easy to do attractive in appearance, because consider performance issue, selected embedded Web server can not support the web server of this class complexity of Apache, so CGI can not adopt realizations such as ASP, PHP, can only realize with the C language, and must be compiled.Like this, webpage is just very dull, can't be at the position display result parameter of regulation.For example, submit to CGI after the parameter of submitting to by list is received by the web server and handle, CGI outputs to webpage with the result, but the webpage before submitting to disappears, and what show now is the webpage of CGI output.How webpage is remained the preceding pattern of submission, the parameter that while CGI returns only is presented at the fixing position of webpage, at this moment can select to adopt Javascript (java script) to realize.CGI can print to result data the end of webpage, extracts the parameter at end by the Javascript script on the webpage, and the position display of stipulating.In addition, system need be provided with the state of hardware I/O (I/0) by the web page, for example light a lamp, perhaps obtain the A/D translation data of hardware current detection, at this time just need application program and driver cooperating by webpage by webpage.Can will use the application code of driver directly to be put into a certain section of cgi script, the shortcoming of doing like this is that the independence of program is not enough, cgi script will be handled the parameter of reception on the one hand, to go on the other hand and UDI, operation flow and driving interface part close-coupled also are unfavorable for debugging.
Summary of the invention
Handle closely-coupled problem at present home gateway cgi script operation flow and system parameters, the invention provides a kind of by the long-range method of IE to the household appliances Equipment Control.
The present invention adopts following technical scheme:
A kind of by the long-range method of IE to the household appliances Equipment Control, may further comprise the steps:
Step 1, client are logined embedded web server by IE;
CGI scripting in step 2, the embedded web server reads html web page to its buffer memory;
Step 3, CGI scripting send the IE of webpage P1 to client;
Step 4, CGI read parameter from Shell, embedded data or the driving of Linux;
After step 5, CGI carry out data transaction with parameter, issue the IE of client;
Step 6, in client, be embedded in that shell script in the webpage P1 reads parameter and to the variable assignments on the webpage;
Step 7, client send the new parameter of user's input to CGI by the POST method of HTML list;
Step 8, CGI receive parameter and invokes application, and the parameter that application program is obtained is the Shell that is transferred to Linux by CGI scripting by the system function of linux;
Parameter call driver and final control hardware that step 9, application program transmit with CGI.
Further, in the described step 6, be embedded in after shell script in the webpage P1 reads parameter, to the variable assignments of correspondence position on the webpage, webpage will guarantee the consistency of web displaying in the position display parameter of stipulating like this.
The application program that the present invention drives CGI and driver, use is separately transmitted parameter by Linux shell (Shell) between CGI and the application program.This can be with driving, and application program and CGI exploitation is independently opened, CGI need not be directly and driving come into contacts with, improved development efficiency.
Description of drawings
Fig. 1 to Fig. 4 is a webpage example relevant among the inventive method embodiment;
Fig. 5 is the inventive method embodiment schematic diagram.
Embodiment
CGI is to the processing of list
How the CGI that traditional embedded system at first is described receives data that webpage submits to.Supposing has individual webpage as shown in Figure 1.Do a very simple test, when the user imports username and password, CGI receives and regenerates a page, and the page shows the username and password of input.Here the list technology of Cai Yonging, see first with code with webpage:
<form?id=″form1″name=″form1″method=″Post″action=″CGI-bin/usrlogin.CGI″>
<p align=" center "〉user name
<input?name=″username″type=″text″id=″username″/></p>
<p align=" center "〉password
<input?name=″password″type=″password″id=″password″/></p>
<p?align=″center″>
<input name=" confirm_login " type=" submit " id=" confirm_login " value=" login "/〉
</p></form>
Wherein,<form〉</form between be list, in the middle of parameter just is placed on.
<form id=" form1 " name=" form1 " method=" Post " action=" CGI-bin/usrlogin.CGI "〉represent when submitting to, adopt the Post method to send parameter, and this program of the CGI-bin/usrlogin.CGI on the request server is handled the parameter of submission.After the Post method sent to server, the name/value that need parse submission was right.Here adopt Boa (WebServer that is suitable for Embedded Application) as embedded Web server, in Boa, adopt char**getCGIvars () function to extract.CGIvars has deposited and has extracted the data that Post submits to, and following cgi script name is usrlogin.CGI, is placed under the CGI-bin catalogue of web, and the responsible name/value that receives to the IE loopback is right.
int?main(){
char**CGIvars;
int?i;
CGIvars=getCGIvars();
printf(″Content-type:text/html\n\n″);
printf(″<html>\n″);
printf?(″<head><title>CGI?Results</title></head>\n″);
printf(″<body>\n″);
Printf ("<h1〉you are good.</h1〉n ");
Printf (" your CGI input variable is: n ");
printf(″<ul>\n″);
for(i=0;CGIvars[i];i+=2)
printf(″<li>[%s]=[%s]\n″,CGIvars[i],CGIvars[i+1]);
printf(″</ul>\n″);
printf(″</body>\n″);
printf(″</html>\n″);
for(i=0;CGIvars[i];i++)free(CGIvars[i]);
free(CGIvars);
exit(0);
}
The parameter that this cgi script receives the webpage submission is placed on the CGIvars the inside, will generate a new webpage simultaneously and the result is sent back to remote client.Owing to be newly-generated webpage, as shown in Figure 2, this interface is no longer the same with the interface among original Fig. 1.
Javascript is to the improvement of CGI
Suppose to have the webpage of Fig. 3, need the IP information of inquiry embedded device, and be presented at current page, if take above method just infeasible.Provide the main code of webpage now:
<body?onLoad=″init()″>
<tr>
<td><form?id=″form1″name=″form1″method=″Post″action=″/CGI-bin/IPsetting.CGI″>
<tr>
<td width=" 99 "〉the IP address</td 〉
<td?width=″249″><input?name=″IPaddr″type=″text″id=″IPaddr″value=″″></td>
</tr>
--------------all the other parametric representations are omitted here-------------------------
<scrIPt?language=″Javascript″>
var?injs=new?Array(10);
function?init()
{
form1.IPaddr.value=injs[0];
form1.IPmask.vaIue=injs[1];
form1.gateway.value=injs[2];
form1.macaddr.value=injs[3];
form1.dns1.value=injs[4];
form1.dns2.value=injs[5];
}
</scrIPt>
<scrIPt?language=″Javascript″>
injs[0]=′192.168.1.12′;injs[1]=′255.255.255.0′;injs[2]=′192.168.1.1′;injs[3]=′11:22:33:44:55:66′;injs[4]=′202.120.224.6′;injs[5]=′202.120.224.104′;
</scrIPt>
A list form1 is arranged in the webpage, wherein have: IP address (IPaddr), IP mask (IPmask), gateway (gateway), Media Access Control Address (macaddr), these conventional IP of domain name mapping (dns1, dns2) are provided with.Wherein,
<body onLoad=" init () "〉be used for telling IE before display web page, to move this function of init earlier;
<scrIPt language=" Javascript "〉expression employing Javascript script;
Function init () representative function name is init, and more than expression is taken out data from the injs character string array that receives.Injs is that cgi script sends over from embedded server.Be the working method of understanding above code directly perceived, can write on the webpage that comes emulating server to send below the Javascript to the injs data, as top code boldface type part.When webpage is loaded by the IE browser and is not begun to show, carry out onLoad=" init () " earlier, in the init function, read the parameter injs[that CGI sends then], and give the corresponding position of list assignment.With above file, open in this locality with IE, can see data.Then see how real return data of embedded type C GI.At first, read whole web page files among the CGI and send to long-rangely, like this, the user directly imports http: // 192.168.12.80/IPsetting.CGI at IE just can read corresponding webpage, then at the end of cgi script, following code line is arranged:
printf(″%s″,″<scrIPt?language=Javascript>″);
printf(″%s″,outjs);
printf(″%s″,″</scrIPt>″);
That outjs deposits is exactly character string outjs=<scrIPt language=" Javascript " 〉
Injs[0]=' 192.168.1.12 '; Injs[1]=' 255.255.255.0 '; Injs[2]=' 192.168.1.1 '; Injs[3]=' 11:22:33:44:55:66 '; Injs[4]=' 202.120.224.6 '; Injs[5]=' 202.120.224.104 ';</scrIPt〉by outjs being outputed to the webpage end, just result parameter has been issued IE.
CGI calls the Shell environmental variance
Above CGI be output be local IP information, but be not that environment from system's operation obtains, be given arbitrarily.The then IP information that need programme by the shell of Linux and extract embedded device.Below just need from the environment of system, take out.Here, only study simple example, the mac address of in program, reading Linux, and export at screen.
main()
{
unsigned?char?mac_str[]=″ifconfig?eth0|grep?HWaddr|cut-dr-f3|cut-d\\-f2>/tmp/mac_addr\0″;
unsigned?char?IP_str[]=″ifconfig?eth0|grep?inet|cut-d:-f2|cut-d\\-f1>/tmp/IP_addr\0″;
unsigned?char?net_str[]=″ifconfig?eth0|grep?Mask|cut-dk-f2|cut-d:-f2>/tmp/net_addr\0″;
unsigned?char?gw_str[]=″route?|grep?default?cut-dt-f2|cut-d0-f1|cut-d\\-f10>/tmp/gw_addr\0″;
unsigned?char?mac_addr[24],IP_addr[24],net_addr[24],gw_addr[24],mac_sys[80];int?error_sys=0;
FILE*mac_fp,*IP_fp,*gw_fp,*net_fp;
/*Creat?temp?mac_addr?file*/
strcpy(mac_sys,″\0″);
strcat(mac_sys,mac_str);
system(mac_sys);
if((mac_fp=fopen(″/tmp/mac_addr″,″r″))!=NULL){
fread(mac_addr,1,18,mac_fp);
}else{perror(″fread″);return?0;}
fclose(mac_fp);
printf(″###MAC?address:%s\n″,mac_addr);}
Wherein:
Unsigned char mac_str[]=ifconfig eth0|grep HWaddr in " ifconfig eth0|grep HWaddr|cut-dr-f3|cut-d-f2>/tmp/mac_addr 0 " extracts this delegation of Hwaddr from ifconfig eth0 output result, cut-dr-f3 is as decollator with character r, taking out the 3rd character string, is exactly concrete mac address date here.System (mac_sys) submits to the Linux executive system with mac_sys to call.Deposit the mac address in file/tmp/mac_addr
if((mac_fp=fopen(″/tmp/mac_addr″,″r″))!=NULL){
fread(mac_addr,1,18,mac_fp);}
Be from/tmp/mac_addr, to take out the mac address, be placed on character string mac_addr the inside.Revise this program, with itself and CGIvars[] variable carries out alternately, and becoming can be at the cgi script of Webserver operation.But the problem of this program is operation flow and concrete details to be realized not separating, if relate to driving, then program is just relatively more mixed and disorderly, is unfavorable for debugging and maintenance, has reduced development efficiency.
Operation flow and details are realized separating
From top example as can be seen, CGI operation flow and some specific implementation details mix, for example: a lot of string operations of mac address; If driving is arranged, also have a lot of driving interface functions.But what the operation flow of equipment was concerned about is not these.For example: need do the page of a remote control equipment switch, after selecting certain lamp, certain i/o of embedded device is action just, by the light on and off of relay control lamp, as Fig. 4.Look at the fragment of the application program that directly can move first:
int?main(int?argc,char**argv)
{int?led_no,on;
unsigned?char?led=0xff;
/ * checks two parameters of led control, if do not have the parameter input then withdraw from.*/
if(argc!=3||sscanf(argv[1],″%d″,&led_no)!=1||sscanf(argv[2],″%d″,&on)!=1||on<0||on>1||led_no<0||led_no>7){
fprintf(stderr,″Usage:leds?led_no?0|1\n″);
exit(1);
}
if(on)led&=~(0x1<<led_no);else?led?|=(0x1<<led_no);
fd=open(LED_DEV,O_RDWR);
if(fd<0){printf(″####XSB_EDR_8LED?test?device?open?fail####%d\n″,fd);
return(-1);}
write(fd,&led,1);}
close(fd);
return(0);
}
In the top program, some parameter errors processing, driving interface function also do not relate to whole service logic here all at a file, handle and business rule if add the parameter of CGI itself again, and it is chaotic that program just seems.For addressing this problem, can open the separate of CGI and driving, CGI passes to application program by the Shell of Linux with parameter.Suppose that webpage writes with Javascript, called after led.html, Webserver adopts Boa, and driver corresponding application program name is 8LED_test, and the CGI catalogue that is placed on the Boa.conf appointment is called for cgi script, below is cgi script:
int?main(int?argc,char**argv){
char?buffer[5000],ledno[80],**cgivars,comd[80]=″8LED_test″;
int?i,j;
FILE*fp;
cgivars=getcgivars();
fp=fopen(″../led.html″,″r″);//open?the?file?for?send?to?web?browser
if(fp==NULL){
printf(″%s″,″file?does?not?exist″);}
fread(buffer,sizeof(buffer),1,fp);//read?web?page
printf(″%s″,buffer);
strcat(comd,cgivars[1]);
strcat(comd,″″);
if(strcmp(cgivars[3],″open″))
strcat(comd,″0″);
else
strcat(comd,″1″);
system(comd);
if(fp!=NULL)fclose(fp);
return?0;}
Program at first is to send led the interface is set, and the parameter that is provided with of analyzing web page (CGIvars[1], CGIvars[3]) is then determined to realize the light on and off of certain lamp by the system function according to parameter.Comd is exactly the order that sends to application program in Shell.For example, 8LED_test 10 indication lamps 0 are closed.Here and the interface function of application program with regard to the system function, all specific implementation details have all realized that in 8LED_test the inside CGI only is concerned about oneself service logic, its reception list parameter is handled these parameters according to business demand.Whole realization as shown in Figure 5.Specifically describe as follows:
Step 1, client (PC) by IE login embedded web server (client login Webserver throughIE, http: // 192.168.1.2/CGI-bin/start.CGI);
The CGI of step 2, embedded web server reads html web page to its buffer memory (CGI read html webpage tobuffer);
Step 3, CGI send the IE (CGI send webpage to IE on client pc) of webpage P1 to client;
Step 4, CGI read parameter (CGI get parameter fromLinux shell, embedded database or driver) from Shell, embedded data or the driving of Linux;
After step 5, CGI carry out data transaction to the parameter that reads, issue the IE (CGI make necessaryconversion on parameter and send to IE) of client;
Step 6, in client, be embedded in that shell script (Javascript) in the webpage P1 reads parameter and to the variable assignments of correspondence position on the webpage, webpage will guarantee the consistency of web displaying in the position display parameter of stipulating like this; (theJavascript embedded in webpage read the parameter which will displayed on webpage);
Step 7, client send new parameter to CGI (customercomputer send new parameter to CGI by HTML table ' s POST method) by the POST method of HTML list (HTML table);
Step 8, CGI receive parameter and invokes application, and the parameter that application program is obtained is to be the Shell that system function transfers to Linux by CGI scripting by linux; (CGI receives parameters and calls the application, theparameters passed to Linux shell by system function);
Parameter call driver and final control hardware (application callsdriver with the parameter from CGI) that step 9, application program transmit with CGI.

Claims (2)

1, a kind of by the long-range method of IE to the household appliances Equipment Control, it is characterized in that may further comprise the steps:
Step 1, client are logined embedded web server by IE;
CGI scripting in step 2, the embedded web server reads html web page to its buffer memory;
Step 3, CGI scripting send the IE of webpage P1 to client;
Step 4, CGI read parameter from Shell, embedded data or the driving of Linux;
After step 5, CGI carry out data transaction with parameter, issue the IE of client;
Step 6, in client, be embedded in that shell script in the webpage P1 reads parameter and to the variable assignments on the webpage;
Step 7, client send the new parameter of user's input to CGI by the POST method of HTML list;
Step 8, CGI receive parameter and invokes application, and the parameter that application program is obtained is the Shell that is transferred to Linux by CGI scripting by the system function of Linux;
Parameter call driver and final control hardware that step 9, application program transmit with CGI.
2, according to claim 1 by the long-range method of IE to the household appliances Equipment Control, it is characterized in that: in the described step 6, be embedded in after shell script in the webpage P1 reads parameter, to the variable assignments of correspondence position on the webpage.
CNA2008102009791A 2008-10-09 2008-10-09 Remote control method for household electrical equipment through IE Pending CN101409731A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNA2008102009791A CN101409731A (en) 2008-10-09 2008-10-09 Remote control method for household electrical equipment through IE

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNA2008102009791A CN101409731A (en) 2008-10-09 2008-10-09 Remote control method for household electrical equipment through IE

Publications (1)

Publication Number Publication Date
CN101409731A true CN101409731A (en) 2009-04-15

Family

ID=40572511

Family Applications (1)

Application Number Title Priority Date Filing Date
CNA2008102009791A Pending CN101409731A (en) 2008-10-09 2008-10-09 Remote control method for household electrical equipment through IE

Country Status (1)

Country Link
CN (1) CN101409731A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102164102A (en) * 2011-04-29 2011-08-24 中山大学 Embedded type home gateway web server system
WO2016070847A1 (en) * 2014-11-06 2016-05-12 北京凌阳益辉科技有限公司 Method for performing synchronization control through external device and apparatus thereof
CN106060066A (en) * 2016-06-28 2016-10-26 积成电子股份有限公司 Embedded linux-based method for realizing terminal maintenance and information release
CN107911416A (en) * 2018-01-24 2018-04-13 天津大学 A kind of Boa server improved methods based on embedded system
WO2018090995A1 (en) * 2016-11-21 2018-05-24 深圳创维数字技术有限公司 Method and system for set-top box debugging
WO2020207032A1 (en) * 2019-04-10 2020-10-15 广州视源电子科技股份有限公司 Desktop component configuration method and device for screen transmission apparatus

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102164102A (en) * 2011-04-29 2011-08-24 中山大学 Embedded type home gateway web server system
WO2016070847A1 (en) * 2014-11-06 2016-05-12 北京凌阳益辉科技有限公司 Method for performing synchronization control through external device and apparatus thereof
CN106060066A (en) * 2016-06-28 2016-10-26 积成电子股份有限公司 Embedded linux-based method for realizing terminal maintenance and information release
WO2018090995A1 (en) * 2016-11-21 2018-05-24 深圳创维数字技术有限公司 Method and system for set-top box debugging
CN107911416A (en) * 2018-01-24 2018-04-13 天津大学 A kind of Boa server improved methods based on embedded system
CN107911416B (en) * 2018-01-24 2020-09-11 天津大学 Boa server improvement method based on embedded system
WO2020207032A1 (en) * 2019-04-10 2020-10-15 广州视源电子科技股份有限公司 Desktop component configuration method and device for screen transmission apparatus

Similar Documents

Publication Publication Date Title
CN103092581B (en) The building method of a kind of web front end this locality development environment and device
CN105450463B (en) Adjustment method, the device and system of hardware device
CN101789964A (en) Remote control and data monitoring method on embedded device
CN111343020A (en) Unified management method and device for multi-protocol Internet of things equipment
CN104268739A (en) Method and system for quickly converting enterprise information system into mobile application
CN111177617A (en) Web direct operation and maintenance method and device based on operation and maintenance management system and electronic equipment
CN101409731A (en) Remote control method for household electrical equipment through IE
CN104579822A (en) Automatic performance test system and method of mobile application based on Http protocol
CN109542427A (en) A kind of system customization method, apparatus and electronic equipment and storage medium
CN103246606B (en) The performance test methods of ESB platform and system
CN103067448B (en) device control method and mobile communication terminal
CN103577320A (en) Testing method and system of remote terminals
CN108023918A (en) A kind of information on services acquisition methods, apparatus and system
US9971636B2 (en) Methods for implementing web services and devices thereof
CN103176804A (en) User interface realization method
CN110633219B (en) Page test method and device, storage medium and electronic equipment
CN107203470B (en) Page adjustment method and device
CN100502309C (en) Embedded Web network management system and its interaction method
CN103294474A (en) Browser operation synchronizing method and device for performing browser operation synchronization
CN103051694B (en) The method and mobile communication terminal of mobile communication terminal control device
CN103533038A (en) Remote control system based on HTML(hypertext markup language)5 and remote control method of remote control system
CN109344075A (en) Configuration method, test method, configuration server and service node device
CN202799005U (en) Cloud computing based internet monitoring system of set top box and set top box
CN112306887A (en) Program test distribution method and corresponding device, equipment and medium
CN102957681A (en) Embedded browser, intelligent household appliance and intelligent system of internet of things

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Open date: 20090415