undefined reference to `__read_console'

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

undefined reference to `__read_console'

Jump to solution
4,952 Views
prashantsathe
Contributor III

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 ?

Labels (1)
Tags (2)
0 Kudos
1 Solution
3,118 Views
prashantsathe
Contributor III

Console read/write for printf was not configured In my case(Libs functions).

I have implemented the custom printf directing to UART.

Anyway thanks

View solution in original post

0 Kudos
8 Replies
3,119 Views
prashantsathe
Contributor III

Console read/write for printf was not configured In my case(Libs functions).

I have implemented the custom printf directing to UART.

Anyway thanks

0 Kudos
3,118 Views
geniusxiong
Contributor I

Can you tell me how to implement the custom printf directing to UART?

Thanks

0 Kudos
3,118 Views
jiri_kral
NXP Employee
NXP Employee

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 

0 Kudos
3,118 Views
geniusxiong
Contributor I

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.

0 Kudos
3,118 Views
jiri_kral
NXP Employee
NXP Employee

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

3,118 Views
geniusxiong
Contributor I

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 ?

天雄

0 Kudos
3,118 Views
jiri_kral
NXP Employee
NXP Employee

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 

0 Kudos
3,118 Views
geniusxiong
Contributor I

Thank you very much!

天雄

0 Kudos