unsigned char rxData[50] = {0};
short rxIndex = 0;
short rx_short_Data = 0;
float rx_float_Data[12] = {0};
WPARAM ch = 0xF0;
for(int i = 0; i< 50; i ++)
rxData[rxIndex++] = ch;
if (rxIndex == 50)
{
short* p_short_data;
p_short_data = (short*)rxData;
rx_short_Data = *p_short_data;
p_short_data += 1;
float* p_float_data = (float*)p_short_data;
for (int i = 0; i < 12;i++)
rx_float_Data[i] = p_float_data[i];
rxIndex = 0;
}
char 转float(串口数据转换)
最新推荐文章于 2023-08-24 14:29:56 发布