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



 
 
 
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值