ESP-IDF |从键盘输入任务
如何从ESP-IDF中的任务中的键盘中获取输入,
我尝试过的代码是
void xTask1(void *params)
{
while (true)
{
char c = 0;
char str[4];
memset(str, 0, sizeof(str));
while (c != '\n')
{
printf("Enter the value:\n");
c = getchar();
if (c != 0xff)
{
str[strlen(str)] = c;
printf("%c", c);
}
vTaskDelay(100 / portTICK_PERIOD_MS);
}
int d = atoi(str);
printf("you have typed : %d\n", d);
}
}
void app_main(void)
{
xTaskCreate(xTask1, "task1", 2048, NULL, 1, NULL);
}
,我要获得的输出
I (309) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
不是输入输入,
- 我在这里犯的错误是什么?
How to take input from keyboard inside a task in ESP-IDF ,
The code I have tried is
void xTask1(void *params)
{
while (true)
{
char c = 0;
char str[4];
memset(str, 0, sizeof(str));
while (c != '\n')
{
printf("Enter the value:\n");
c = getchar();
if (c != 0xff)
{
str[strlen(str)] = c;
printf("%c", c);
}
vTaskDelay(100 / portTICK_PERIOD_MS);
}
int d = atoi(str);
printf("you have typed : %d\n", d);
}
}
void app_main(void)
{
xTaskCreate(xTask1, "task1", 2048, NULL, 1, NULL);
}
and the output I am getting is
I (309) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Enter the value:
Its not holding in to enter the input,
- What is the mistake I am making here.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论