I am cleaning up my library code for the CSI camera interface and the Pixel pipeline. One thing that I want to do is to have the ability to notify users of status and errors. Presently, that is done by returning status values and by printing errors on Serial.

I would like to make the error and status reporting independent of the USB serial for situations where the USB serial is not connected. As I see it there are a couple of options:

1. Have each library include a SetStream(stream *sptr) method. The stream pointer would default to &Serial-----after all the code uses that link to get downloaded. The user could set the stream pointer to &Serial1, NULL, or possibly a log file. Error and status messages would go to that stream.

2. Library methods could return a boolean error result. If the result is false, the main program would call library.GetErrorCode, or library.GetErrorString to investigate and record the error. This might be simplified by having the library method return an error code with 0 meaning success, and the other codes providing indices to error description strings.


Another problem-in-waiting is what to do when passing buffer pointers to the CSI and PXP. I am currently signaling an error when a VGA-sized buffer (614KB) is specified, but the buffer address is not in EXTMEM. Other than managing caches when the buffer is not in DTCM, buffer allocations are left up to the calling program.

I have considered the possibility of defining pointers to 1MByte segments of EXTMEM and allowing the user to specify one of those. A 1MB buffer will hold a full VGA buffer of RGB888 data (921KB), but there is the potential for a lot of wasted memory if smaller bitmaps are used. There is also a significant speed penalty for some PXP operations, which execute about 8 times faster with one or both buffers in DTCM or DMAMEM.


I would appreciate any comments on other possibilities and the pitfalls and benefits of the approaches.