debug_scanf() not working?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

debug_scanf() not working?

Jump to solution
1,080 Views
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

Labels (1)
1 Solution
667 Views
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

View solution in original post

3 Replies
668 Views
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

667 Views
giacomopetrini
Contributor IV

...

...

I'm an idiot.

Thanks

Best Regards Giacomo

0 Kudos
667 Views
ivadorazinova
NXP Employee
NXP Employee

That´s ok :smileywink:

Best Regards,

Iva

0 Kudos