Sportica   Sportica

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






posted @ 2011-12-06 16:37  qingjoin  阅读(799)  评论(0编辑  收藏  举报
  Sportica