Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

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

Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

Jump to solution
2,279 Views
pedroortega
Contributor I

Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

I have tested gets(), with and without fflush() and always happen the same.

Thanks in advance for your help.

0 Kudos
1 Solution
1,619 Views
Petr_H
NXP Employee
NXP Employee

Hi,

I have tested it on the TWR-K60 board and it's working properly for me.  Please find attached an example project that echoes a string after the user presses enter. It uses TWR-SER board serial port for output. You can try it if it will work for you.

I also attach the picture with the property marked in the component. Do you see it like that?

Best regards

Petr Hradsky

Processor Expert Support Team

View solution in original post

0 Kudos
9 Replies
1,619 Views
Petr_H
NXP Employee
NXP Employee

Hi,

Are you using Kinetis and CodeWarrior? Do you have the ConsoleIO component in your project? If not, it needs to be added into the project. It also adds inherited Serial_LDD that need to be configured (baudrate, pins etc...).

With these component both writing and reading console should work.

Best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
1,619 Views
pedroortega
Contributor I

Excuse me; I forgot to attach a snapshot.

De: Ortega Sanz Pedro

Enviado el: miércoles, 26 de febrero de 2014 17:17

Para: 'jive-891534970-4qmg-2-87zu@freescale.hosted.jivesoftware.com'

Asunto: RE: - Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

Hi Petr.

Thanks for your early response.

Yes I am using KINETIS (K60) and CodeWarrior, In the project there is ConsoleIO and it is properly configured (printf(), work perfectly).

Attached you can find a snapshot of screen.

The issue is that when the scanf(), get(), or gets() are executed the MCU does not wait for string+ CR/LF or any character; the program continue without delay.

I try to use fflush(), in order to clear the input buffer but there is no difference.

Best regards

De: Petr Hradsky

Enviado el: miércoles, 26 de febrero de 2014 15:43

Para: Ortega Sanz Pedro

Asunto: Re: - Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

<https://community.freescale.com/>

Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

reply from Petr Hradsky<https://community.freescale.com/people/Petr_H?et=watches.email.thread> in Processor Expert Software - View the full discussion<https://community.freescale.com/message/383610?et=watches.email.thread#383610>

0 Kudos
1,619 Views
Petr_H
NXP Employee
NXP Employee

Hi,

In the latest version (CW MCU v10.5 PEx Update 1.0.0) there is a property in Console component that can change the behavior. As far as I know, there was an issue with CW10.5 that it wasn't there.

I suppose that you are using CodeWarrior 10.5. Do you have it and do you have the PEx update 1.0.0 installed ?

If not could you try to install the CW MCU v10.5 PEx Update 1.0.0. It should allow you to generate code with waiting for the reception of the string.

Here is the link with updates:

CW-MCU10: CodeWarrior for MCUs (Eclipse IDE) - ColdFire, 56800/E DSC, Kinetis, Qorivva 56xx, RS08/S0...

Best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
1,619 Views
pedroortega
Contributor I

Hi Petr.

I have installed all updates available, and the behavior of the MCU is the same. I don´t find any new properties in the Console component and the Scanf() does not wait for new characters.

Attached you can find the version installed.

De: Petr Hradsky

Enviado el: viernes, 07 de marzo de 2014 17:09

Para: Ortega Sanz Pedro

Asunto: Re: - Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

<https://community.freescale.com/>

Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

reply from Petr Hradsky<https://community.freescale.com/people/Petr_H?et=watches.email.thread> in Processor Expert Software - View the full discussion<https://community.freescale.com/message/386454?et=watches.email.thread#386454>

0 Kudos
1,620 Views
Petr_H
NXP Employee
NXP Employee

Hi,

I have tested it on the TWR-K60 board and it's working properly for me.  Please find attached an example project that echoes a string after the user presses enter. It uses TWR-SER board serial port for output. You can try it if it will work for you.

I also attach the picture with the property marked in the component. Do you see it like that?

Best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
1,619 Views
pedroortega
Contributor I

Hi Petr.

I have tried to test your project in my PC and the property “wait until at least one character is recived”, does not appearance (attached you can see it)

In order to avoid that a I am working with old versión y tried to install al updates that you say me , but the program does not allow. I read all licences but never the button FINISH is available.

Best regards.

De: Petr Hradsky

Enviado el: miércoles, 12 de marzo de 2014 17:39

Para: Ortega Sanz Pedro

Asunto: Re: - Re: Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

<https://community.freescale.com/>

Re: Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

reply from Petr Hradsky<https://community.freescale.com/people/Petr_H?et=watches.email.thread> in Processor Expert Software - View the full discussion<https://community.freescale.com/message/387466?et=watches.email.thread#387466>

0 Kudos
1,619 Views
Petr_H
NXP Employee
NXP Employee

Hi,

This is strange, I haven't met such issue yet. Please try to click to the text and back if the Finish button won't enable.

Maybe there is something wrong with your installation so it would be better to completely reinstall the CodeWarrior to separate directory and perform the updates.

Best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
1,619 Views
pedroortega
Contributor I

Hi Petr.

I have followed your advices and now all works properly.

Thanks very much for your help.

Best regards.

0 Kudos
1,619 Views
pedroortega
Contributor I

Hi Petr.

Thanks for your early response.

Yes I am using KINETIS (K60) and CodeWarrior, In the project there is ConsoleIO and it is properly configured (printf(), work perfectly).

Attached you can find a snapshot of screen.

The issue is that when the scanf(), get(), or gets() are executed the MCU does not wait for string+ CR/LF or any character; the program continue without delay.

I try to use fflush(), in order to clear the input buffer but there is no difference.

Best regards

De: Petr Hradsky

Enviado el: miércoles, 26 de febrero de 2014 15:43

Para: Ortega Sanz Pedro

Asunto: Re: - Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

<https://community.freescale.com/>

Hi, I am trying to use Scanf() in a Processor Expert project, and the function return nothing. Does not wait for characters and exit immediately. Any idea?

reply from Petr Hradsky<https://community.freescale.com/people/Petr_H?et=watches.email.thread> in Processor Expert Software - View the full discussion<https://community.freescale.com/message/383610?et=watches.email.thread#383610>

0 Kudos