你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

注释掉main函数内一行代码后程序无法启动

[复制链接]
BOEING777ER 提问时间:2024-7-10 15:10 / 未解决

主函数如下:


    while (1)
    {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
        loop_cnt++;

        //HAL_GPIO_TogglePin(LED_GPIO_Port,LED_Pin);
        if(13 == ((loop_cnt >> 4) & 0x0f))
            HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
        else if (15 == ((loop_cnt >> 4) & 0x0f))
            HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);

        HAL_IWDG_Refresh(&hiwdg);

        if(HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_13))
        {
            HAL_GPIO_WritePin(GPIOD, GPIO_PIN_6, GPIO_PIN_RESET);
        }
        else
        {
            HAL_GPIO_WritePin(GPIOD, GPIO_PIN_6, GPIO_PIN_SET);
        }

        //print_log("w5500 link STA %d\r\n", (Read_W5500_1Byte(PHYCFGR)&LINK));
        #if 1

        if((getPHYCFGR() & 0x01) != link_state)
        {
            link_state = (getPHYCFGR() & 0x01);

            if((getPHYCFGR() & 0x01) == 0)
            {
                beep_voice(1, 200);
                close(2);
                S_State[2] = 0;
                close(3);
                S_State[3] = 0;
                close(4);
                S_State[4] = 0;
                close(5);
                S_State[5] = 0;
            }
            else
            {
                beep_voice(2, 50);
                print_log("w5500 link\r\n");
            }
        }
        else if(memcmp(gSystemParam.deviceIp, gSystemParam.gateway, 3) == 0) // check gateway
        {
            //tmpTciks = g64msTicks;
            // handle webserver
            do_http(0);
            //print_log("do_http %lld\r\n", g64msTicks - tmpTciks);

            //tmpTciks = g64msTicks;
            // handle NTP services
            //ntpServices();
            //print_log("ntpServices %lld\r\n", g64msTicks - tmpTciks);

            //tmpTciks = g64msTicks;
            netAppServices();
            //read_net_app();
            //print_log("netAppServices %lld\r\n", g64msTicks - tmpTciks);
        }

        // handle uart message, include uart1 uart2 uart3
        cmdMachine();

        #endif

    }

在注释掉do_http(0)后程序无法启动,请问是什么问题?

do_http的函数定义如下:

char rx_buf[MAX_URI_SIZE] = {0};


void do_http(uint8_t sn)
{
  unsigned short len;

  st_http_request *http_request;
  memset(rx_buf,0x00,MAX_URI_SIZE);
  http_request = (st_http_request*)rx_buf;      // struct of http request  
  /* http service start */
  switch(getSn_SR(sn))
  {
    case SOCK_INIT:
      //listen(sn);
      break;
    case SOCK_LISTEN:
      break;
    case SOCK_ESTABLISHED:
    //case SOCK_CLOSE_WAIT:
      if(getSn_IR(sn) & Sn_IR_CON)
      {
        setSn_IR(sn, Sn_IR_CON);
      }
      if ((len = getSn_RX_RSR(sn)) > 0) 
      {
        len = recv(sn, (unsigned char*)http_request, len); 
        *(((unsigned char*)http_request)+len) = 0;
        //proc_http(sn, (unsigned char*)http_request); // request is processed
        disconnect(sn);
                //printf("SOCK_ESTABLISHED %04x\r\n", len);
      }
      break;
    case SOCK_CLOSE_WAIT:   
      if ((len = getSn_RX_RSR(sn)) > 0)
      {
        //printf("close wait: %d\r\n",len);
        len = recv(sn, (unsigned char*)http_request, len);     
        *(((unsigned char*)http_request)+len) = 0;
        //proc_http(sn, (unsigned char*)http_request); // request is processed
                //printf("SOCK_CLOSE_WAIT %04x\r\n", len);
      }
      disconnect(sn);
      break;
    case SOCK_CLOSED:
            len = gSystemParam.webServerPort[1];
            len *= 256;
            len += gSystemParam.webServerPort[0];
            socket(sn, Sn_MR_TCP, len, 0x00);    /* reinitialize the socket */
      break;
    default:
    break;
  }// end of switch
}
收藏 评论0 发布时间:2024-7-10 15:10

举报

0个回答

所属标签

相似问题

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32Cube扩展软件包
意法半导体边缘AI套件
ST - 理想汽车豪华SUV案例
ST意法半导体智能家居案例
STM32 ARM Cortex 32位微控制器
关注我们
st-img 微信公众号
st-img 手机版