• 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);



    
    
    
    
    
    
  • 相关阅读:
    C++学习笔记27,虚函数作品
    HDU
    POJ 2524 Ubiquitous Religions
    HDU-3839-Ancient Messages(DFS)
    thinkphp 删除所有缓存 Rumtime 以及 Html 静态缓存
    [AngularJS] Design Pattern: Simple Mediator
    [Javascript] Add a browser build to an npm module
    [Angular 2] ngrx/store
    [Typescript] Introduction to Generics in Typescript
    [AngularJS] angular-md-table for Angular material design
  • 原文地址:https://www.cnblogs.com/qingjoin/p/2278173.html
Copyright © 2020-2023  润新知