- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've over-ridden the _write() function so that printf output is directed to a device (one of several UARTs) of my choosing. The _write() method takes a file descriptor int which is used to specific which device the output is bound for.
However, I have several 'devices' that I'd like to send output to with fprintf, thus think I need to create a FILE object and set the file descriptor. Unfortunately, calling fprintf with my own FILE objects is resulting in a call to _write(). I've even tried to copy stderr as follows without success.
Any ideas?
Thanks,
Chris
main() {
FILE fobj;
memcpy(&fobj, stderr, sizeof(FILE))
fobj._file = FD_UART_2;
fprintf(&fobj,"something\n");
} // main
int _write(int file, char *ptr, int len) {
LED_Y_Write(~LED_Y_Read()); // how I know its not getting called w/fprintf
switch(file) {
case stdout:
case stderr :
UART_1_PutArray(ptr, len);
break;
case FD_UART_2 :
UART_2_PutArray(ptr, len);
break;
} // switch
} // _write
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please create a tech support case and attach the coplete project so that we can take it from there to debug the issue.
https://secure.cypress.com/myaccount/?id=25&source=CY-ENG-HEADER
Thanks,
Keerthi