CY8CKIT-043 scanf capability with UART?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RiKn_1565556
Level 2
Level 2

Hello All,

   

I am a CY8CKIT-043 user trying to work my way through my first application.

   

A couple weeks ago I posed some questions using the kit's UART function and within a day or so I was back on track, so I am hopeful that my current quandry is something that is easily fixed (i.e. some kind person will point me at an obvious solution I've overlooked.)

   

Here is my situation: Using the PSOC Creator 3.3 application I have modified the kit's "breathing led" application to make use of the UART function to send strings from the kit to a Putty application.  That is working okay now making use of sprintf to fill buffers and then "printing" them using the UART_1_UartPutString() function included in the creator application.

   

Now I am trying to go in the opposite direction.  I'd like to be able to do a 'scanf' response and capture either an integer, float or string value from the UART.  I've experimented with scanf which seems to be implemented in the creator but I can't make it work.  Essentially I'd like to be able to echo a string back to the user in putty and have them respond, for example "how many iterations?" to which the user responds with an integer.

   

I realize I could do the getchar() route, capture every byte, convert the ascii to an integer, etc. etc. but I guess I'm just lazy.  I'd prefer to not to have to go to this level of effort unless I really have to.

   

As I've already said, I could very well be missing something.  I've searched the net and browsed forums and looked at the reference manuals I've found and I come up empty.  Has anyone solved this problem before?

   

Rich

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I had a similar request some days ago. Contacted Cypress and got as answer: Newlib nano does not support scanf() functions.

   

Workaround:

   
        
  • Do it yourself
  •     
  • Not using newlib nano which will result in quite more fram usage
  •     
  • Using atoi() and atof()
  •    
   

 

   

Bob

0 Likes
RiKn_1565556
Level 2
Level 2

Thanks Bob,

   

I was afraid that was the case but I had to ask.  I guess I'll just need to resuscitate that part of my brain - it has been long unused thanks to higher level languages.  You're right though, although primitive, there are still ways to get it accomplished.  Thanks for the input.

   

Rich

0 Likes