Printf and Tiny library

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Printf and Tiny library

7,611件の閲覧回数
LPs1978
Contributor III

Hi all,

   I'm building a project with tiny library C_4i_CF_SZ.a

 

I want to use printf to write on my LCD display.

 

My routines are ok and tested. What I want to do is to redirect the printf to my proprietary function that use my GUI. 

As usual I tryed to redirect the stdout->write_proc to my function Write_Display.

I debugged my code and I'm sure that the correct address is filled in the right position of stdout structure, but when I use printf and fflush functions my proprietary function is not colled.

 

Where is my error??

 

Thanks for your support

ラベル(1)
0 件の賞賛
返信
8 返答(返信)

5,774件の閲覧回数
vier_kuifjes
Senior Contributor I

You could also use sprintf to print to a string and then copy the data in the string to the LCD using some LCD driving routines.

 

That is how I do it anyway...

0 件の賞賛
返信

5,774件の閲覧回数
LPs1978
Contributor III

Yes, I undestand your solution, but it isn't so fast.

 

Otherwise It's a problem that I want to understand to know better the MSL library.

0 件の賞賛
返信

5,774件の閲覧回数
RichTestardi
Senior Contributor II

Hi,

 

If you want, you can just define your own printf() which overrides the default putchar routine, as described here:

 

http://forums.freescale.com/freescale/board/message?board.id=CWCFCOMM&message.id=2508&query.id=4632#...

 

Then you can change your putchar() routine to write to your LCD, and use printf() normally to access it.

 

There's also some background on how the whole printf path works in that thread.

 

-- Rich

0 件の賞賛
返信

5,774件の閲覧回数
LPs1978
Contributor III

Thanks Rich, buts I know the way you explained to me.

 

I made the same some time ago, using the entire printf_tiny_io.c in my progect linked before the MSL library with my modification.

 

What I want to understand is why, with tiny support, I cannot use the stdout with printf. Probably I have to configure something in the stdout structure to make it able to work....

0 件の賞賛
返信

5,774件の閲覧回数
admin
Specialist II

Did you tested the low level by sending to the same custom file descriptor using fprintf() ?

0 件の賞賛
返信

5,774件の閲覧回数
LPs1978
Contributor III

Yes! I tested the fprintf function with stdout.

 

I checked also that the write_proc is the correct one when teh fprintf is executed and all is ok.

 

I'm desperate.

0 件の賞賛
返信

5,774件の閲覧回数
admin
Specialist II

To better understand the issue, could you send using fprintf() to another (non-stdout and non-LCD) file descriptor? Say, to TCP socket?

Generally, if everything is seems correct, but isn't working, the direction of the search is wrong.

 

0 件の賞賛
返信

5,774件の閲覧回数
LPs1978
Contributor III

The only thing that I found is that always the printf calls WriteUARTN function. I think that is this the problem, that cause that my chars are not placed into the stdout structure.

 

Onother strange thing is that all stdout structure seems not initialize (eg. stdout->buffer_ptr = 0x0000)

0 件の賞賛
返信