程序中,使用 sprintf 保留2位小数,能正常打印2次,后面就打印不了。
RS485_TXMode;
delay_xms(5);
USARTxWrite(USART1,(char *)rs485ReadHumi,8);
delay_xms(5);
RS485_RXMode;
err = xSemaphoreTake(Usart1RxSemaphore,portMAX_DELAY);//½óêÕDÅoÅá¿
if(err == pdTRUE)
{
//½aÎöêy¾Y
Humi_Real_Value = AnalysisTempHumi(Usart1_Buffer);
xSemaphoreTake(PrintMutexSemaphore,portMAX_DELAY);
sprintf(tmpBuffer,"humi=%.2f,",Humi_Real_Value);//前面2次能运行,后面就不运行了,如果改成 sprintf(tmpBuffer,"humi=%f,",Humi_Real_Value);没问题
USARTxStr(USART3,tmpBuffer);
memset(Usart1_Buffer,0,Usart1_RxLength);
Usart1_RxLength = 0;
xSemaphoreGive(PrintMutexSemaphore);
}
else
{
vTaskDelay(10);
}
输出显示:
一周热门 更多>