根据国家政策法规,只有实名认证用户才能在论坛回帖留言,点击去完成实名认证 >>
千寻位置
发表主题
  • 5984阅读
  • 1回复

基于stm32F103C8T6平台下,采用千寻知寸服务SDK的问题?
[复制链接]

级别: 新手上路
 
只看楼主 倒序阅读 楼主  发表于: 2018-02-02
基于STM32F103C8T6平台下,采用MC20通讯模块,没有用到ucos系统,栈内存分配为8k。
自己编写的qxwz_soc MC20_soc_create(void);函数,在调试的时候,可以接收MC20模块从串口传回的数据信息。并能正常建立起连接。
但是采用官方的SDK,即在qxwz_soc qxwz_soc_create(void);函数中调用qxwz_soc MC20_soc_create(void);函数,发现程序会一直卡在这里面。进过jlink在线调试后,发现,此时程序不能进去任何中断,接收不到串口返回的数据,卡死在socket的初始化里面了。请问大家有遇到过这种问题吗?大家有相关资料或者解决方案吗吗?谢谢啦     (相关代码,与图片均贴在下方)

/***************************************具体代码如下*****************************************************************************************/
qxwz_soc MC20_soc_create(void)
{
        qxwz_soc  socket_fd = -1;

        socket_fd = qxwz_soc_init();
        if(socket_fd >= 0){
                QXLOG(USART3,"socket create success,socket_fd = %d \r\n",socket_fd);
                qxwz_sdkTick = TRUE;
                return socket_fd;
        }else{
                QXLOG(USART3,"socket create error \r\n");
                return -1;
        }
}

/***********************************************************************************************************/
int8_t qxwz_soc_init(void){
        int8_t ret = 0;
        if(s_is_init == FALSE){
                ret = init_gsm_gprs();
                if(ret == 0){
                        s_is_init = TRUE;
                }else{
                        QXLOG(USART3,"init gsm module error....return code = %d\r\n",ret);
                        return -1;
                }
        }
        return 1;
}

/****************************************************************************************************/
static int8_t init_gsm_gprs(void)
{
        int8_t ret = 0;
        ret = wait_creg(); //等待注册成功  会卡死在这里面 没进去串口中断,接收不到返回信息

        if(ret == 0){
                QXLOG(USART3,"×¢²áÍê³É.....\r\n");
        }else{
                QXLOG(USART3,"×¢²áʧ°Ü.....\r\n");
                return -1;
        }
        if((ret = set_ate0()) != 0){
        //关闭回显
                return ret;
        }
        if((ret = send_at_command("AT","OK",AT_CMD_TIMEOUT)) != 0) {
                QXLOG(USART3,"send Command AT error...\r\n");
                return ret;
        };

        if((ret = send_at_command("AT+CREG=1","OK",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+CREG=1 error...\r\n");
                return ret;
        }

        if((ret = send_at_command("AT+CSQ","+CSQ",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+CSQ error...\r\n");
                return ret;
        }

        if((ret = send_at_command("AT+CPIN?","+CPIN: READY",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+CSQ error...\r\n");
                return ret;
        }

        if((ret = send_at_command("AT+CGREG?","+CGREG: 0,5",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+CSQ error...\r\n");
                return ret;
        }

        if((ret = send_at_command("AT+QISTAT\r\n","OK",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command IP Init Fail...\r\n");

                if((ret = send_at_command("AT+QIDEACT","OK",AT_CMD_TIMEOUT)) != 0){
                        QXLOG(USART3,"send Command AT+QIDEACT Fail...\r\n");
                }

                if((ret = send_at_command("AT+QICLOSE","OK",AT_CMD_TIMEOUT)) != 0){
                        QXLOG(USART3,"send Command AT+QICLOSE Fail...\r\n");        
                }
        }


        if((ret = send_at_command("AT+QIFGCNT=0","OK",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+QIFGCNT Fail...\r\n");
                return ret;
        }


        if((ret = send_at_command("AT+QICSGP=1,\042CMNET\042","OK",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+QICSGP Fail...\r\n");
                return ret;
        }


        if((ret = send_at_command("AT+QINDI=1\r\n","OK",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+QINDI Fail...\r\n");
                return ret;
        }


        if((ret = send_at_command("AT+QIHEAD=1\r\n","OK",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+QIHEAD=1 Fail...\r\n");
                return ret;
        }


        if((ret = send_at_command("AT+QISHOWRA=1\r\n","OK",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+QISHOWRA=1 Fail...\r\n");
                return ret;
        }


        if((ret = send_at_command("AT+QISTAT\r\n","IP INITIAL",AT_CMD_TIMEOUT)) == 0){
                QXLOG(USART3,"IP INITIAL...\r\n");

                if((ret = send_at_command("AT+QIREGAPP","OK",AT_CMD_TIMEOUT)) != 0){
                        QXLOG(USART3,"send Command AT+QIREGAPP Fail...\r\n");
                        return ret;
                }

                if((ret = send_at_command("AT+QIACT","OK",AT_CMD_TIMEOUT)) != 0){
                        QXLOG(USART3,"send Command AT+QIACT Fail...\r\n");
                        return ret;
                }
        }else{
                QXLOG(USART3,"send Command AT+QISHOWRA=1 Fail...\r\n");
                return ret;
        }


        if((ret = send_at_command("AT+QIDNSIP=1","OK",AT_CMD_TIMEOUT)) != 0){
                QXLOG(USART3,"send Command AT+QIDNSIP=1 Fail...\r\n");
                return ret;
        }
//        send_at_command("AT+QIMODE=1","OK",AT_CMD_TIMEOUT);
//        send_at_command("AT+QITCFG=3,2,512,1","OK",AT_CMD_TIMEOUT);

        return ret;
}
/****************************************************************************************************/
/**
* 等待模块注册成功
*        @param  
*
* @return
*/
int8_t wait_creg(void)
{
        uint8_t i = 0;
        uint8_t k;
        qxwz_BOOL first_command = TRUE;

        clear_buf();
        QXLOG(USART3,"注册中");
  while(i == 0)                                
        {
                clear_buf();  
                QXLOG(USART3,"Send Register Cmd");  ]//具体日志信息一直接收Send Register Cmd,程序卡在了这里,同时Jlink在线调试得时候,MC20_RxBuffer中根本接收不到数据,进不去串口中断
                printf("AT+CREG?\r\n");

                delay_ms(1000);          
                if(first_command){
                        start_at_ack_timer(WAIT_CFG_TRY_SECOND);
                        first_command = FALSE;
                }
          for(k = 0;k < BUF_MAX;k++) {
                        if(MC20_RxBuffer[k] == ':'){
                                if((MC20_RxBuffer[k+4] == '1')||(MC20_RxBuffer[k+4] == '5'))
                                {
                                        i = 1;
                                        QXLOG(USART3,"\r\n");
                                        return  0;
                                }
                        }
                }
                if(s_at_ack_timeout_flag){
                        s_restart_gsm_flag = TRUE;
                        s_timer_start_flag = FALSE;
                        s_at_ack_timeout_flag = FALSE;
                        return  GSM_ACK_TIMEOUT;
                }

        }//while(i == 0)  

        return 0;
}
级别: 新手上路
只看该作者 沙发  发表于: 01-12
我也想在stm32平台下用,能问问具体操作吗?
快速回复
限100 字节
如果您在写长篇帖子又不马上发表,建议存为草稿
 
上一个 下一个