int generate_frag_data(void){ #if !defined JF return 0; #else int index=0; int data_len=PDU_FRAG_DATA_LEN; memset(frag_data_buf,0,sizeof(frag_data_buf)); MN_printf(0, "generate_frag_data frag_num=%d\r\n",frag_num); #ifdef FIRST_FRAG_ADD_EXTRA_DATA if(FRAG_NUM_START==frag_num){ uint8_t max_min_value[2]; get_sample_data_max_min_value(max_min_value); float v_min=computeMvScale_f(max_min_value[1]); float v_max=1600;//computeMvScale_f(max_min_value[0]); uint8_t * v_max_fp=(uint8_t *)&v_max; uint8_t * v_min_fp=(uint8_t *)&v_min; index=first_frag_add_extra_data((uint8_t *)frag_data_buf,v_min_fp,v_max_fp); data_len+=FIRST_FRAG_EXTRA_DATA_LEN; } #endif int frag_src_data_num= MAX_SAMP_DATA_LEN * MAX_SAMP_BUF_NUM / FRAG_TOTAL_NUM; for(int i=0;i<frag_src_data_num;i++){ int frag_src_data_index= frag_src_data_num*(frag_num-1)+i; int sdata_item_index= frag_src_data_index/MAX_SAMP_DATA_LEN; int sdata_index=frag_src_data_index % MAX_SAMP_DATA_LEN; uint8_t data=sample_jufang_buf.sdata_item[sdata_item_index].sdata[sdata_index]; float data_f=computeMvScale_f(data); memcpy(&frag_data_buf[index+i*4],(uint8_t *)&data_f,4); /*if(i%250==0){ MN_printf(0, "generate_frag_data i=%d\r\n",i); MN_printf(0, "generate_frag_data frag_src_data_num=%d\r\n",frag_src_data_num); MN_printf(0, "generate_frag_data frag_src_data_index=%d\r\n",frag_src_data_index); MN_printf(0, "generate_frag_data sdata_item_index=%d\r\n",sdata_item_index); MN_printf(0, "generate_frag_data sdata_index=%d\r\n",sdata_index); MN_printf(0, "generate_frag_data index+i*4=%d\r\n",index+i*4); MN_printf(0, "generate_frag_data data=%2x\r\n",data); MN_printf(0, "generate_frag_data frag_data_buf[index+i*4]=%2x\r\n",frag_data_buf[index+i*4]); MN_printf(0, "generate_frag_data frag_data_buf[index+i*4+1]=%2x\r\n",frag_data_buf[index+i*4+1]); MN_printf(0, "generate_frag_data frag_data_buf[index+i*4+2]=%2x\r\n",frag_data_buf[index+i*4+2]); MN_printf(0, "generate_frag_data frag_data_buf[index+i*4+3]=%2x\r\n",frag_data_buf[index+i*4+3]); #if defined SAMPLE_DATA_FLOAT_VALUE_UPLOAD float fReceive; *((char *)(&fReceive)) = frag_data_buf[index+i*4]; *((char *)(&fReceive) + 1) = frag_data_buf[index+i*4+1]; *((char *)(&fReceive) + 2) = frag_data_buf[index+i*4+2]; *((char *)(&fReceive) + 3) = frag_data_buf[index+i*4+3]; uint32_t a = (uint32_t)(fReceive*1000); MN_printf(0, "sample_data_float_value=%ld\r\n",a); #endif }*/ } return data_len; #endif }
时间: 2024-04-05 15:33:17 浏览: 40
这段代码看起来是生成数据包的函数,其中的 #if !defined JF 和 #ifdef FIRST_FRAG_ADD_EXTRA_DATA 是用来进行条件编译的,根据宏定义的情况来决定编译哪些代码。函数主要是通过遍历采样数据的缓冲区来生成数据包,其中还包括对数据进行处理和转换的部分。有些注释可能是开发者用于调试的,不会对代码本身产生影响。
阅读全文