找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 925|回復(fù): 2
收起左側(cè)

#167-D: 警告問題,請問如何解決

[復(fù)制鏈接]
ID:929517 發(fā)表于 2025-2-16 06:53 | 顯示全部樓層 |閱讀模式
100黑幣
編譯后出現(xiàn)User\main.c(57): warning:  #167-D: argument of type "char" is incompatible with parameter of type "char *"

強(qiáng)制類型轉(zhuǎn)換還是無法消除,請大佬指點(diǎn)

相關(guān)代碼如下:


NEMA_MSG gps;


while(1)
        {   
   if(DMA_RxFlag)
   {
     DMA_RxFlag = 0;

     GNRMC_Analysis(&gps,(uint8_t*)usart3_dma_buf);
     HMI_Send_TxtIntVar("page0.t0",gps.utc.year);
     HMI_Send_TxtIntVar("page0.t2",gps.utc.month);     
     HMI_Send_TxtIntVar("page0.t4",gps.utc.date);     
     HMI_Send_TxtIntVar("page0.t18",gps.utc.hour);
     HMI_Send_TxtIntVar("page0.t19",gps.utc.min);     
     HMI_Send_TxtIntVar("page0.t20",gps.utc.sec);


     HMI_SendTxDblvar("page0.t10", gps.longtitude/100000);

     HMI_SendTxtStrVar("page0.t12",gps.E_W);    //這句有警告

     HMI_SendTxDblvar("page0.t13",gps.latitude/100000);

     HMI_SendTxtStrVar("page0.t15",gps.N_S);  // 這句有警告

     HMI_SendTxDblvar("page0.t23",gps.speed/10000);     
     HMI_SendTxDblvar("page0.t25",gps.course/100);            
   }  
  }

/*GNRMC解析程序
gpsx:數(shù)據(jù)結(jié)構(gòu)體
buf: 接收到是數(shù)據(jù)幀首地址指針
*/
void GNRMC_Analysis(NEMA_MSG *gpsx,uint8_t *buf)
{
   uint8_t *p1,dx;
   uint8_t posx; //第幾個逗號
   uint32_t temp;
   float rs;

   p1 = (uint8_t*)strstr((const char *)buf,"GNRMC"); //獲取GNRMC數(shù)據(jù)幀幀頭指針

   posx = NMEA_GetComma(p1,1);            
   if(posx != 0xff)
   {
     temp = NMEA_Str2Num(p1+posx,&dx)/NMEA_Pow(10,dx);  //獲取UTC時間,去掉.后毫秒
     gpsx->utc.hour = temp/10000;
   gpsx->utc.min = (temp/100)%100;
   gpsx->utc.sec =  temp%100;
   }

   posx = NMEA_GetComma(p1,3);              //緯度
   if(posx != 0xff)
   {
    temp = NMEA_Str2Num(p1+posx,&dx);
    gpsx->latitude = temp/NMEA_Pow(10,dx+2);//得到°
    rs = temp%NMEA_Pow(10,dx+2);//得到 '
    gpsx->latitude = gpsx->latitude*NMEA_Pow(10,5)+ (rs*NMEA_Pow(10,5-dx))/60;//轉(zhuǎn)換為°
   }
   posx = NMEA_GetComma(p1,4);   
   if(posx != 0xff)    gpsx->N_S = *(p1+posx);   //南緯北緯

   posx = NMEA_GetComma(p1,5);            //經(jīng)度
   if(posx != 0xff)
   {
     temp = NMEA_Str2Num(p1+posx,&dx);  //獲取UTC時間,去掉.后毫秒
     gpsx->longtitude = temp/NMEA_Pow(10,dx+2);//得到°
     rs = temp%NMEA_Pow(10,dx+2);//得到 '
     gpsx->longtitude = gpsx->longtitude*NMEA_Pow(10,5)+ (rs*NMEA_Pow(10,5-dx))/60;//轉(zhuǎn)換為°
   }
   posx = NMEA_GetComma(p1,6);   
   if(posx != 0xff)    gpsx->E_W = *(char*)(p1+posx);   //東經(jīng)西經(jīng)

   posx=NMEA_GetComma(p1,7);                                                                //得到地面速率
   if(posx!=0XFF)
   {
     gpsx->speed = NMEA_Str2Num(p1+posx,&dx);
     if(dx<3)  gpsx->speed*=NMEA_Pow(10,3-dx);                                  //確保擴(kuò)大1000倍
   }

   posx=NMEA_GetComma(p1,8);                                                                //得到航向
   if(posx!=0XFF)
   {
     gpsx->course = NMEA_Str2Num(p1+posx,&dx);
     if(dx<3)  gpsx->speed*=NMEA_Pow(10,3-dx);                                  //確保擴(kuò)大1000倍
   }  

   posx=NMEA_GetComma(p1,9);                                                                //得到UTC日期
   if(posx!=0XFF)
   {
     temp=NMEA_Str2Num(p1+posx,&dx);                                                 //得到UTC日期
     gpsx->utc.date=temp/10000;
     gpsx->utc.month=(temp/100)%100;
     gpsx->utc.year=2000+temp%100;                  
   }

}



__packed typedef struct
{
  DATE_TIME   utc;
  uint8_t     N_S;             //南緯北緯
  double      latitude;        //緯度
  char        E_W;             //東經(jīng)西經(jīng)
  double      longtitude;      //經(jīng)度
  int16_t     atitude;         //海拔高度
  double      speed;           //速度
  double      course;          //航向
}NEMA_MSG;


GPS_DMA _V4.zip

344.29 KB, 下載次數(shù): 0

回復(fù)

使用道具 舉報(bào)

ID:929517 發(fā)表于 2025-2-16 06:54 | 顯示全部樓層
/*   向HMI發(fā)送字符串變量,文本控件顯示   txtBox 文本控件名稱  strVar 字符串變量 */ void HMI_SendTxtStrVar(char *txtBox,char *strVar) {   char str[50] = "";    //定義字符串變量      memset(str,'\0',sizeof(str));//使用之前先清空字符串   strcat(str,txtBox);  //拼接字符串   strcat(str,".txt=\""); //拼接上.txt=   strcat(str,strVar);    //HMI控件要顯示的字符串   strcat(str,"\"");      //HMI控件要顯示的字符串   Serial_SendString(USART3,str);   HMI_Send_EndFlag(); }
回復(fù)

使用道具 舉報(bào)

ID:161164 發(fā)表于 2025-2-18 16:47 | 顯示全部樓層
HMI_SendTxtStrVar的第2個傳參也是字符串
建議先用sprintf把數(shù)值轉(zhuǎn)為字符串再傳參 2025-02-18_164639.png

回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表