debug_scanf() not working?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

debug_scanf() not working?

ソリューションへジャンプ
1,379件の閲覧回数
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 解決策
966件の閲覧回数
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 返答(返信)
967件の閲覧回数
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

966件の閲覧回数
giacomopetrini
Contributor IV

...

...

I'm an idiot.

Thanks

Best Regards Giacomo

0 件の賞賛
返信
966件の閲覧回数
ivadorazinova
NXP Employee
NXP Employee

That´s ok :smileywink:

Best Regards,

Iva

0 件の賞賛
返信