debug_scanf() not working?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

debug_scanf() not working?

跳至解决方案
1,086 次查看
giacomopetrini
Contributor IV

Hello,

in a project, created with KDS 2.0.0, KSDK 1.1.0 and PE, I'm trying to create some user interaction with the console.

I added the fsl_debug_console component in PE.

I can output messages using debug_printf() and read 1 character using debug_getchar().

 

Now in fsl_debug_console.c there is the debug_scanf() funtion, that I expect to work like the classic scanf().

 

But it seems that it doesn't:

 uint16_t choice;  debug_printf("\nSet Year (last 2 digit): ");  choice = debug_scanf("%d",&choice);  debug_printf("%d\n",choice);

 

The input is "15\n", so I expect that the debug_printf() outputs "15\n", but the output is "1\n".

 

Am I doing something wrong?

 

Thanks, regards Giacomo

标签 (1)
1 解答
673 次查看
ivadorazinova
NXP Employee
NXP Employee

Hello giacomopetrini,

the bad thing is, that you assign debug_scanf("%d",&choice) to choice.

You must do it by this way:


uint16_t choice;

      debug_printf("\nSet Year (last 2 digit): ");

      debug_scanf("%d",&choice);

      debug_printf("%d\n",choice);

Best Regards,

Iva

在原帖中查看解决方案

3 回复数
674 次查看
ivadorazinova
NXP Employee
NXP Employee

Hello giacomopetrini,

the bad thing is, that you assign debug_scanf("%d",&choice) to choice.

You must do it by this way:


uint16_t choice;

      debug_printf("\nSet Year (last 2 digit): ");

      debug_scanf("%d",&choice);

      debug_printf("%d\n",choice);

Best Regards,

Iva

673 次查看
giacomopetrini
Contributor IV

...

...

I'm an idiot.

Thanks

Best Regards Giacomo

0 项奖励
673 次查看
ivadorazinova
NXP Employee
NXP Employee

That´s ok :smileywink:

Best Regards,

Iva

0 项奖励