zoukankan      html  css  js  c++  java
  • FIFO通信 htonl 和memcpy的用法

    void Fifowrite()                                       //Fifo通信
    {

    int real_wnum = 0;
    int fifo_fd = open(OSD_FIFO,O_WRONLY,0);
    printf("fifo: %d\n", fifo_fd);
    if(fifo_fd)
    {
    real_wnum = write(fifo_fd,&osd_t,sizeof(textOSD_t));
    if(real_wnum==-1)
    printf("write to fifo error; try later real_wnum=%d\n",real_wnum);
    else
    printf("real write num is %d\n",real_wnum);

    //close
    close(fifo_fd);
    }

    }
    
    
    
    
    int setfifoimage( unsigned char Fifo_ID,unsigned char imgID,int imgvalue)
    {

    wta_fifocmd_t imagefifo;
    imagefifo.Cmdhead=0x01;
    imagefifo.Cmd_ver=0x01;
    imagefifo.Cmd_ID=Fifo_ID;
    imagefifo.Cmd_Para[0]=imgID;
    imagefifo.Cmd_Para[1]=imgvalue;
    imagefifo.Cmd_check=0x00;
    int real_wnum = 0;
    int fifo_fd = open(IMAGE_FIFO,O_WRONLY,0);
    printf("fifo: %d\n", fifo_fd);
    if(fifo_fd)
    {
    real_wnum = write(fifo_fd,&imagefifo,sizeof(wta_fifocmd_t));
    if(real_wnum==-1)
    printf("write to fifo error; try later real_wnum=%d\n",real_wnum);
    else
    printf("real write num is %d\n",real_wnum);
    printf("Cmd_Para[0]:%d\n",imagefifo.Cmd_Para[0]);
    printf("Cmd_Para[1]:%d\n",imagefifo.Cmd_Para[1]);

    close(fifo_fd);
    }

    }
    simg_t.exposure_set.shutter_time_min=gatoi(pszTmp);

    nTmp = htonl(simg_t.exposure_set.shutter_time_min);  
            //htonl的用法。本函数将一个32位数从主机字节顺序转换成网络字节顺序
                memcpy(shutterTmp, &nTmp, 4);     
    nTmp = htonl(simg_t.exposure_set.shutter_time_max);
    memcpy(shutterTmp+4, &nTmp, 4);
    nTmp = htonl(simg_t.exposure_set.slow_shutter_enable);
    memcpy(shutterTmp+8, &nTmp, 4);
    shutterfifo(WTA_IMAGE_QULITY_SET, WTA_AE_SHUTTER_RANG_SET, shutterTmp,CPCOUNT);



    
    
    
    
    
    
  • 相关阅读:
    codevs1288 埃及分数
    codevs1792 分解质因数
    dp
    JAVA大数贪心
    求最长不重叠子串
    初识后缀数组
    dp
    两数相除,判断小数位是否有限位
    构造二分图匹配
    建立多个树状数组
  • 原文地址:https://www.cnblogs.com/qingjoin/p/2278173.html
Copyright © 2011-2022 走看看