consoleprint

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

consoleprint

1,049 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by myudkovich on Tue Mar 22 06:57:50 MST 2011
[SIZE=2]Hello Support

I  checked the Function consoleprint([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Hello World\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); and this is working very good . [/SIZE]
[SIZE=2]My question is , Do we have a function to receive data from Console, process and then printf ? [/SIZE]
[SIZE=2][/SIZE]
0 Kudos
Reply
5 Replies

1,043 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Mar 22 11:51:52 MST 2011

Quote: myudkovich

[SIZE=2]My question is , Do we have a function to receive data from Console, process and then printf ? [/SIZE]


scanf?
http://www.cplusplus.com/reference/clibrary/cstdio/scanf/

Note that as jharwood's post intimates, there is no way of getting an "instant" response to a key press on the host PC. scanf will require you to enter some text, and then press <enter> in order to submit it back to your application code.

Regards,
CodeRedSupport
0 Kudos
Reply

1,043 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Tue Mar 22 10:47:43 MST 2011
I modified the example above because it had contained a definition for BUF_SIZE and char array buffer.  These were not necessary as cr_fast_printf allocates memory for us.

Just for clarification the following is what I  removed.

extern int consoleprint(char *cpstring);
#define BUF_SIZE 80
char buffer[BUF_SIZE]; // Character buffer to hold string for consoleprint
// Make sure this is big enough !!!
0 Kudos
Reply

1,043 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Tue Mar 22 10:33:11 MST 2011
Actually after looking over the above code we probably don't need to define BUF_SIZE or buffer as cr_fast_printf() dynamically allocates memory.

Anybody want to confirm this?  I have meetings until afternoon and won't be able to check until then.

Thanks,
Larry
0 Kudos
Reply

1,043 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Tue Mar 22 09:43:39 MST 2011
For an easier way to use consoleprint see this post http://knowledgebase.nxp.com/showpost.php?p=2300&postcount=4

Add cr_fast_printf.c, consoleprint.h and consoleprint.c to your project and use it in a similar way as this.

/*
===============================================================================
 Name        : main.c
 Author      : $(author)
 Version     :
 Copyright   : $(copyright)
 Description : main definition
===============================================================================
*/
#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif
#include <cr_section_macros.h>
#include <NXP/crp.h>
// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
#include <stdio.h>
extern int cr_fast_printf(const char *fmt, ...);
#define MESSAGE cr_fast_printf
 
 
int main(void) {
 
 MESSAGE("Hello World\n");
 
 // Enter an infinite loop, just incrementing a counter
 volatile static int i = 0 ;
 while(1) {
  i++ ;
 }
 return 0 ;
}


Le'itraot
0 Kudos
Reply

1,043 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Tue Mar 22 08:33:40 MST 2011
The question has been answered previously in [B]this thread[/B] :)
0 Kudos
Reply