Working on MAC57D5MB for freeRtos.
I am working on adding a printf functionalities. Build get failed at the send saying
C:/Freescale/S32_ARM_v1.2/S32DS/arm_ewl2/lib/armv7e-m\libc99.a(ansi_files.o):(.data.__files+0x40): undefined reference to `__read_console'
C:/Freescale/S32_ARM_v1.2/S32DS/arm_ewl2/lib/armv7e-m\libc99.a(ansi_files.o):(.data.__files+0x44): undefined reference to `__write_console'
Could you help me on this ?
已解决! 转到解答。
Console read/write for printf was not configured In my case(Libs functions).
I have implemented the custom printf directing to UART.
Anyway thanks
Hi,
you can look at this Example - https://community.nxp.com/docs/DOC-335240
It is for FreeRTOS - but basics are the same. You can re-use console.c and console.h files in your project.
Hope it helps.
Jiri
Thank you!
With this reference example, I add console.c and console.h to my project , and then I can use printf and scanf , that's good!
But another problem, if i scanf some words from lpuart, and then use PINS_DRV_SetPins this function for setting gpio ,
PINS_DRV_SetPins will not work, i don't know why. Can you help me?
console.c and console.h I have not changed these two files.
Hi,
um - what you mean by PINS_DRV_SetPins doesn't work? I tried toggle pin ( PINS_DRV_TogglePins(LED_GPIO, (1 << LED2)); ) right after scanf - and for me is working normally. Is your particular pin (driven by PINS_DRV_SetPins) set as an output?
Jiri
ok, thanks!
The problem has already been solved yet.
And another question:
I don't know if I can use scanf to get a string, for example, char msg[100]; scanf("%s", msg); I try and test with existing console.c maybe can not use
scanf to get a string, so i will modify the function __read_console in console.c? and how do i modify it ?
天雄
Hi,
you can use scanf for string read. You need to specify length of your buffer (in the rtos printf example is max size 256 bytes). There is no buffer overflow check in console.c file - it is good idea to add it (exit from read console if size exceed maximum allowed size).
It depend for what purpose you need to read string. scanf function is dedicated for keyboard input. For transfer string data for example from file is better idea use LPUART_DRV_ReceiveData SDK function.
Jiri