遠程網頁控制家電程序_第1頁
遠程網頁控制家電程序_第2頁
遠程網頁控制家電程序_第3頁
遠程網頁控制家電程序_第4頁
遠程網頁控制家電程序_第5頁
已閱讀5頁,還剩2頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、 廣州優嵌電子科技有限公司網頁遠程控制家電第一步:建立網頁文件,目的就是給操作者一個圖形操作界面咯(不會制作網頁的人,一般修改他人的網頁即可)以下是修改他人網頁的代碼,文件名稱:home.html-家居控制網頁 主界面 控制選項:風扇電視冰箱空調 -第二步:建立CGI文件,目的就是制作一個shell文件,把網頁的內容寫到相應的管道中。代碼如下,文件名稱:home.cgi-#!/bin/shF_S=0D_S=0B_X=0K_T=0SPEED=1case $QUERY_STRING in *cb_io=f_s*) F_S=1 ;esac case $QUERY_STRING in *cb_io=d

2、_s*) D_S=1 ;esaccase $QUERY_STRING in *cb_io=b_x*) B_X=1 ;esac case $QUERY_STRING in *cb_io=k_t*) K_T=1 ;esac/bin/echo $F_S $D_S $B_X $K_T /tmp/led-control /bin/echo Content-type: text/html; charset=gb2312/bin/echo#/bin/echo $QUERY_STRING STRING/bin/cat home.templateexit 0-第三步:建立網頁提交文件,作用就是提交按鈕點擊后出現

3、的網頁的內容由其提供,然后返回到home.html,代碼如下:文件名稱:home.template-控制選項結果控制設置已經提交返回上一頁-第四步:建立啟動文件(也是模板文件),目的就是應用程序,代碼如下,文件名稱:homeqidong-#!/bin/shbase=/sbin/ledweb# See how we were called.case $1 in start)$base & ; stop)pid=/bin/pidof $baseif -n $pid ; thenkill -9 $pidfi ;esacexit 0-第五步:修改文件系統相應文件:需更改/etc/init.d/rcs文

4、件,添加一句:/etc/rc.d/init.d/ledwebqidong start第六步:在文件系統的web目錄下新建一homeweb目錄將homo.html、home.cgi、home.template文件放到這個目錄,將homeqidong放在/etc/rc.d/init.d/下。第七步:在瀏覽器欄中輸入:97/homeweb/home.html,ok搞定!應用程序附錄:-#include #include #include #include #include #include #include #include #include #includesta

5、tic int led_fd;static int leds4 = 0;static void lightleds(void)int i;for(i=0;i4;i+)ioctl(led_fd, ledsi, i);int main(void)int led_control_pipe;int null_writer_fd; / for read endpoint not blocking when control process exitled_fd = open(/dev/EmbedSky-leds, 0);if (led_fd 0) perror(open device leds);exit

6、(1);unlink(/tmp/led-control);mkfifo(/tmp/led-control, 0666);led_control_pipe = open(/tmp/led-control, O_RDONLY | O_NONBLOCK);if (led_control_pipe 0) perror(open control pipe for read);exit(1);null_writer_fd = open(/tmp/led-control, O_WRONLY | O_NONBLOCK);if (null_writer_fd 0) perror(open control pip

7、e for write);exit(1);for (;) fd_set rds;int ret;struct timeval step;step.tv_sec = 0;step.tv_usec =0.125*1000000L;FD_ZERO(&rds);FD_SET(led_control_pipe, &rds);ret = select(led_control_pipe + 1, &rds, NULL, NULL, &step);if (ret = sizeof buffer - 1) memset(buffer, 0, sizeof buffer);break;if (read(led_c

8、ontrol_pipe, &c, 1) != 1) break;if (c = r) continue;if (c = n) int tmp_leds4;if (sscanf(buffer,%d%d%d%d, &tmp_leds0, &tmp_leds1,&tmp_leds2,&tmp_leds3) = 4) leds0 = tmp_leds0; leds1 = tmp_leds1; leds2 = tmp_leds2; leds3 = tmp_leds3;int j;for(j=0;j4;j+)if(ledsj)fprintf(stderr,led%d is onn,j+1);elsefprintf(stderr,

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論