i am looking for a way to redirect the standard I/O to use something other than the netburner serial ports. I have found the examples of:
int fdserial_debug=OpenSerial(DEBUG_SERIAL_PORT,
DEBUG_BAUDRATE,
DEBUG_STOP_BITS,
DEBUG_DATA_BITS,
eParityNone);
ReplaceStdio(1,fdserial_debug); // 0=stdin, 1=stdout, 2=stderr
printf("No we're using printf()!\r\n");
But, I don't see an example if I want to use a device otherthan a Uart. In my case, i want the stdout to go my own function that will put the output into a memory device.
redirecting stdout and stdin to device otherthan a UART
Re: redirecting stdout and stdin to device otherthan a UART
There is a section on this in the network programmers guide, including custom fd implementations:
File Descriptors
16.1
Overview
A file descriptor is a handle to a network socket, serial port or other system peripheral. May of the API functions pass a file descriptor to your application functions, such as the web server MyGet function example in this guide.
There are a maximum of 64 file descriptors:
•0 – 2 for stdin, stdout and stderr
•3 – 4 for the first two UART serial ports, 0 and 1.
•5 – 37 for TCP (32 in total)
•38 – 63 for expansion (additional UARTs, TCP sockets, or custom)
16.2
Creating Custom I/O Drivers Using File Descriptors
The header file in \nburn\include\iointernal.h defines the programming interface functions to create a custom file descriptor.
etc etc ........
File Descriptors
16.1
Overview
A file descriptor is a handle to a network socket, serial port or other system peripheral. May of the API functions pass a file descriptor to your application functions, such as the web server MyGet function example in this guide.
There are a maximum of 64 file descriptors:
•0 – 2 for stdin, stdout and stderr
•3 – 4 for the first two UART serial ports, 0 and 1.
•5 – 37 for TCP (32 in total)
•38 – 63 for expansion (additional UARTs, TCP sockets, or custom)
16.2
Creating Custom I/O Drivers Using File Descriptors
The header file in \nburn\include\iointernal.h defines the programming interface functions to create a custom file descriptor.
etc etc ........
Re: redirecting stdout and stdin to device otherthan a UART
I am missing something then. I have seen this in the manual before, but I don't see how to replace the first 3 file descriptors, stdin, stdout, stderr. With my own file descriptor... Do I use the ReplaceStdio function to then reassign the current stdout with my custom file descriptor?
I basically would like to use printf, putchar, getchar to use my own device not the serial port...
I basically would like to use printf, putchar, getchar to use my own device not the serial port...
Re: redirecting stdout and stdin to device otherthan a UART
Did you see the fdprintf example in the Nburn/examples folder? You may have a good reason to change the behavior of printf but if not pity the poor maintenance programmer who comes after and see if using calls to fdprintf() wouldn't work just as well.