基于Z301P摄像头 H.264OK6410的远程视频web监控 项目笔记5(CGI)

转载请注明转自 http://blog.csdn.net/jinatom/article/details/7759589


#include <stdio.h>
#include "cgic.h"
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/fs.h>
#include "cardev.h"
#include <errno.h>

int set_car(){

    int fd;
    fd = open("/dev/cardev", 0);
    if (fd < 0) {
        fprintf(cgiOut, "open device car erro<BR>\n");
        exit(1);
    }

    fprintf(cgiOut, "open device car success<BR>\n");
    if (cgiFormCheckboxSingle("ON") == cgiFormSuccess) {
//handle checkbox
    fprintf(cgiOut, "ON!<BR>\n");
    ioctl(fd,CAR_CMD_ON,0);
    ioctl(fd,CAR_CMD_ON,1);
    }
    if (cgiFormCheckboxSingle("OFF") == cgiFormSuccess) {
//handle checkbox
    fprintf(cgiOut, "OFF!<BR>\n");
    ioctl(fd, CAR_CMD_OFF,0);
    ioctl(fd, CAR_CMD_OFF,1);
    }
    if (cgiFormCheckboxSingle("LEFT") == cgiFormSuccess) {
//handle checkbox
    fprintf(cgiOut, "LEFT!<BR>\n");
    ioctl(fd, CAR_CMD_ON,0);
    ioctl(fd, CAR_CMD_OFF,1);
    }


    if (cgiFormCheckboxSingle("RIGHT") == cgiFormSuccess) {
//handle checkbox
    fprintf(cgiOut, "RIGHT!<BR>\n");
    ioctl(fd, CAR_CMD_ON,1);
    ioctl(fd, CAR_CMD_OFF,0);
    }
    close(fd);
    return 0;
}

void Name() {
    char name[81];
    cgiFormStringNoNewlines("name", name, 81);
//handle text field   containing a string
    fprintf(cgiOut, "Name: ");
    cgiHtmlEscape(name);
    fprintf(cgiOut, "<BR>\n");
}


void ShowForm()
{
    fprintf(cgiOut, "<!-- 2.0: multipart/form-data is required for file uploads. -->");

    fprintf(cgiOut, "<form name=\"form1\" method=\"POST\" enctype=\"multipart/form-data\" ");
    fprintf(cgiOut, "    action=\"");
    cgiValueEscape(cgiScriptName);
    fprintf(cgiOut, "\">\n");
    fprintf(cgiOut, "<input type=\"checkbox\" name=\"ON\">ON\n");
    fprintf(cgiOut, "<p>\n");
    fprintf(cgiOut, "<input type=\"checkbox\" name=\"OFF\" >OFF\n");
    fprintf(cgiOut, "<p>\n");
    fprintf(cgiOut, "<input type=\"checkbox\" name=\"RIGHT\" >RIGHT\n");
    fprintf(cgiOut, "<p>\n");
    fprintf(cgiOut, "<input type=\"checkbox\" name=\"LEFT\" >LEFT\n");
    fprintf(cgiOut, "<p>\n");

    fprintf(cgiOut, "<input type=\"submit\" name=\"testcgic\" value=\"Submit \">\n");

    fprintf(cgiOut, "</form>\n");


}



int cgiMain() {
    
    int adc_value;
    cgiHeaderContentType("text/html");
    fprintf(cgiOut, "<HTML><HEAD>\n");
    fprintf(cgiOut, "<TITLE>cgic song1 test</TITLE></HEAD>\n");
    fprintf(cgiOut, "<BODY><H1>car control</H1>\n");


    set_car();
    ShowForm();

    fprintf(cgiOut, "</BODY></HTML>\n");
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值