Formatted I/O

Discussion to talk about software related topics only.
Post Reply
addonray
Posts: 19
Joined: Thu Sep 03, 2015 10:46 am

Formatted I/O

Post by addonray »

Hi,

Is there any way (other than dealing with putchar() replacement directly) to do formatted output (via fdprintf, etc.) through a low level function of my own? I'm moving an older UART based project to use an FTDI async FIFO (8 bit bus) USB IC. There is a ton of formatted output code already in play. With the Rabbit Softools compiler, there was an Fassign function that let you point a file descriptor at any function, avoiding putchar() completely for any given descriptor. I remember with the Keil tools, I had to directly manipulate putchar(). How would I best address this with the NB tools?
:?
Thanks,

Ray
sulliwk06
Posts: 118
Joined: Tue Sep 17, 2013 7:14 am

Re: Formatted I/O

Post by sulliwk06 »

If I understand correctly, I think you can accomplish what you want by creating your own file descriptor GetExtraFD (in iointernal.h). You create an IoExpandStruct and define your own read, write, and close functions for that file descriptor. I used this method for creating file descriptors for an external quad uart chip.
addonray
Posts: 19
Joined: Thu Sep 03, 2015 10:46 am

Re: Formatted I/O

Post by addonray »

That looks like it's exactly what I need! There was nothing in the docs about it. Do you recall if they had any example code anywhere?

Thanks!

Ray
sulliwk06
Posts: 118
Joined: Tue Sep 17, 2013 7:14 am

Re: Formatted I/O

Post by sulliwk06 »

No I don't think I ever found any examples, I just used the system library as a reference, there were a few places where they used that.
addonray
Posts: 19
Joined: Thu Sep 03, 2015 10:46 am

Re: Formatted I/O

Post by addonray »

Thank you! I'll search by function names there.
Post Reply