This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Getting fprintf() to work. At all.

Greetings -

The (custom) device I'm working on has multiple possible serial interfaces. I thought "Hey, I've written entire operating systems before, I should just intercept "open()" and then exploit stdio and have it do my evil bidding!". Mostly on account of retarget.c allows _write() to be re-swizzled.

Except it would appear that something like

FILE *some_other_way_of_chatting;
some_other_way_of_chatting = fdopen(my_fake_file_descriptor, "rw");

doesn't produce a (FILE *) object that gets routed through _write(). Which makes things rather pointless.

I did find dprintf() and I may do something with it, but I'd really like to use stdio. Because I'm weird that way.

Parents
  • Sigurd - That's not doing it for me. Part of the problem is various solutions all seem to require not using the standard "stdio" paradigm (like dprintf() -- it's an integer, not an opaque structure) or they have some other object which can't readily be constructed (like the one for nrf_fprintf()). Now that I see y'all accept "external" code, as with fprintf(), I'll have to write "Julie's embedded stdio library" and send it to y'all after I'm no longer buried.

Reply
  • Sigurd - That's not doing it for me. Part of the problem is various solutions all seem to require not using the standard "stdio" paradigm (like dprintf() -- it's an integer, not an opaque structure) or they have some other object which can't readily be constructed (like the one for nrf_fprintf()). Now that I see y'all accept "external" code, as with fprintf(), I'll have to write "Julie's embedded stdio library" and send it to y'all after I'm no longer buried.

Children
No Data
Related