免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3486 | 回复: 5
打印 上一主题 下一主题

[WebServer] 求救:基于web的温度采集并动显示 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-06-19 19:53 |只看该作者 |倒序浏览
开发板是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. }
复制代码
我想在网页上面动态显示,谢谢大家了,如果可以的话,请给我代码,本人是新手,非常感谢!!!

论坛徽章:
0
2 [报告]
发表于 2012-06-19 20:02 |只看该作者
高手帮帮忙啊,不要让帖子沉了,第一次发帖~~

论坛徽章:
0
3 [报告]
发表于 2012-08-31 00:06 |只看该作者
DS18B20?
我也正在看这个 呵呵

论坛徽章:
0
4 [报告]
发表于 2012-12-18 16:29 |只看该作者
高手帮帮忙啊

论坛徽章:
0
5 [报告]
发表于 2012-12-31 13:43 |只看该作者
回复 3# mulegame
你的实现了没有啊?我的实现了温度在网页上动态显示

   

论坛徽章:
0
6 [报告]
发表于 2013-01-02 12:20 |只看该作者
本帖最后由 2007robot 于 2013-01-02 12:22 编辑

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

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

webserver的资料,可以参考一下。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP