Chinaunix

标题: 求救:基于web的温度采集并动显示 [打印本页]

作者: qw8990032    时间: 2012-06-19 19:53
标题: 求救:基于web的温度采集并动显示
开发板是Micro2440(mini2440也一样),已经移植了boa,通过开发板串口连接CC2530的开发板(zigbee无线模块),将采集的温度通过传到Micro2440,能在超级终端里面显示,没有用到sqlite数据库,请问如何在网页上面显示,从网上下了一个Micro2440的串口程序:
  1. #include <time.h>
  2. #include <fcntl.h>
  3. #include <stdio.h>
  4. #include <ctype.h>
  5. #include <errno.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <unistd.h>
  9. #include <signal.h>
  10. #include <termio.h>
  11. #include <syslog.h>
  12. #include <pthread.h>
  13. #include <sys/ipc.h>
  14. #include <sys/msg.h>
  15. #include <sys/wait.h>
  16. #include <sys/stat.h>
  17. #include <sys/time.h>
  18. #include <semaphore.h>
  19. #include <arpa/inet.h>
  20. #include <sys/types.h>
  21. #include <sys/socket.h>
  22. #include <bits/signum.h>
  23. #include <sys/resource.h>

  24. int uart_init(int arg, int baud)
  25. {
  26.     int fd;
  27.     char port[20];
  28.     struct termios Opt;
  29.     int uartbiit[50]= {B115200,B9600,B19200,B4800,B2400,B1200};

  30.     sprintf(port,"/dev/ttySAC%d",arg);   
  31.     printf("Use port: %s \n", port);
  32.     fd = open(port, O_RDWR);     //打开串口
  33.     if (fd<0)
  34.     {
  35.         return -1;                 //没有打开返回
  36.     }

  37.     tcgetattr(fd,&Opt);      //初始化
  38.     tcflush(fd,TCIFLUSH);
  39.     cfsetispeed(&Opt,uartbiit[baud]);    //设置波特率
  40.     cfsetospeed(&Opt,uartbiit[baud]);

  41.     Opt.c_cflag |= CS8;                          //设置数据位
  42.     Opt.c_cflag &= ~PARENB;
  43.     Opt.c_oflag &= ~(OPOST);
  44.     Opt.c_cflag &= ~CSTOPB;
  45.     Opt.c_lflag &= ~(ICANON|ISIG|ECHO|IEXTEN);
  46.     Opt.c_iflag &= ~(INPCK|BRKINT|ICRNL|ISTRIP|IXON);

  47.     Opt.c_cc[VMIN] = 64;            //最大长度
  48.     Opt.c_cc[VTIME] = 1;            //超时时间

  49.     if (tcsetattr(fd,TCSANOW,&Opt) != 0)       //装载初始化参数
  50.     {
  51.         perror("SetupSerial!\n");
  52.         close(fd);
  53.         return -1;
  54.     }
  55.     return(fd);

  56. }

  57. int main()
  58. {
  59.     int fd, len = 0, i=0;
  60.     char buf[64];

  61.     if((fd = uart_init(1, 0)) <0)   //打开串口,波特率为115200;
  62.     {
  63.         printf("Open uart err \n");
  64.         return -1;
  65.     }
  66.     sprintf(buf, "Hello world !\n");   //输出内容

  67.   while(1)
  68.           {
  69.     memset(buf, 0 ,sizeof(buf));
  70.                    while((len = read(fd,buf,64))>0)
  71.                    {
  72.                         printf("%s\n",buf);
  73.                     }
  74.           }


  75.     return 0;
  76. }
复制代码
我想在网页上面动态显示,谢谢大家了,如果可以的话,请给我代码,本人是新手,非常感谢!!!
作者: qw8990032    时间: 2012-06-19 20:02
高手帮帮忙啊,不要让帖子沉了,第一次发帖~~
作者: mulegame    时间: 2012-08-31 00:06
DS18B20?
我也正在看这个 呵呵
作者: qw8990032    时间: 2012-12-18 16:29
高手帮帮忙啊
作者: qw8990032    时间: 2012-12-31 13:43
回复 3# mulegame
你的实现了没有啊?我的实现了温度在网页上动态显示

   
作者: 2007robot    时间: 2013-01-02 12:20
本帖最后由 2007robot 于 2013-01-02 12:22 编辑

友情支持一下,呵呵!波哥,努力啊!

http://bbs.chinaunix.net/thread-4057942-1-1.html

webserver的资料,可以参考一下。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2