找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 864|回复: 2
打印 上一主题 下一主题
收起左侧

#167-D: 警告问题,请问如何解决

[复制链接]
跳转到指定楼层
楼主
100黑币
编译后出现User\main.c(57): warning:  #167-D: argument of type "char" is incompatible with parameter of type "char *"

强制类型转换还是无法消除,请大佬指点

相关代码如下:


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:数据结构体
buf: 接收到是数据帧首地址指针
*/
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数据帧帧头指针

   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;//转换为°
   }
   posx = NMEA_GetComma(p1,4);   
   if(posx != 0xff)    gpsx->N_S = *(p1+posx);   //南纬北纬

   posx = NMEA_GetComma(p1,5);            //经度
   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;//转换为°
   }
   posx = NMEA_GetComma(p1,6);   
   if(posx != 0xff)    gpsx->E_W = *(char*)(p1+posx);   //东经西经

   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);                                  //确保扩大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);                                  //确保扩大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;             //东经西经
  double      longtitude;      //经度
  int16_t     atitude;         //海拔高度
  double      speed;           //速度
  double      course;          //航向
}NEMA_MSG;


GPS_DMA _V4.zip

344.29 KB, 下载次数: 0

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:929517 发表于 2025-2-16 06:54 | 只看该作者
/*   向HMI发送字符串变量,文本控件显示   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(); }
回复

使用道具 举报

板凳
ID:161164 发表于 2025-2-18 16:47 | 只看该作者
HMI_SendTxtStrVar的第2个传参也是字符串
建议先用sprintf把数值转为字符串再传参

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表