Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Error in while function of STM32F4 serial port printing

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Summary: write while functions and other types of loops to add "{}", otherwise I don't know what will go wrong.

Original function:

Void division_func (void)

{

Char * p=NULL

Int I = 0

/ / such as the string received by USART1: 2013-12-14

/ / split the string with'-'. The first string now split is: 2013

P = strtok ((char *) g_usart1_recv_buf, "-")

Printf ("split:% d% s\ r\ n", iTunes, p)

/ / continue to split

While ((p=strtok (NULL, "-")

Printf ("split:% d% s\ r\ n", iTunes, p)

}

Running result: error

After modification:

Void division_func (void)

{

Char * p=NULL

Int I = 0

/ / such as the string received by USART1: 2013-12-14

/ / split the string with'-'. The first string now split is: 2013

P = strtok ((char *) g_usart1_recv_buf, "-")

Printf ("split:% d% s\ r\ n", iTunes, p)

/ / continue to split

While ((p=strtok (NULL, "-")

{

Printf ("split:% d% s\ r\ n", iTunes, p)

}

}

Running result: normal

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report