This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SIMPLELINK-MSP432-SDK: What "stdout" does the DisplayHost fwrite to by default? Can its destination be configured?

Part Number: SIMPLELINK-MSP432-SDK
Other Parts Discussed in Thread: MSP-FET

I'm a bit confused by the purpose of the DisplayHost driver provided in the SimpleLink MSP432P4 SDK (docs at http://dev.ti.com/tirex/explore/content/simplelink_msp432p4_sdk_3_40_01_02/docs/tidrivers/doxygen/html/_display_host_8h.html).

Looking at its source within the SDK's install path, it looks like it ultimately just calls `fwrite(…, stdout);` with the formatted result of whatever I would `Display_printf(…)` as a user. But what does `fwrite` do on the MSP432?!

It's clear that TI has set up stdio to be conformant with what I presume would be relevant C or C++ standards (i.e. rather than POSIX since this isn't dependent on the SimpleLink POSIX wrapper stuff). Is the implementation of the stdio functions available somewhere? Is it just a stub implementation, e.g. an fwrite() to stdout just gets discarded, or is there builtin debugger support or something? Is there a documented way to overwrite these so that DisplayHost will write somewhere useful?

Basically wondering if/why/how one would ever use DisplayHost (versus e.g. DisplayUART on a LaunchPad or custom serial backchannel port) and that's leading me to wonder the same regarding the compilers stdio stuff as well -- is it just there so code can compile, or would said code also "work" somehow with a default stdin/stdout actually hooked up? And if so can I change what writing to those std descriptors does?

  • Hi Nathan,

    The only available source code can be found in C:\ti\simplelink_msp432p4_sdk_3_40_01_02\source\ti\display\DisplayHost.c

    Srinivas

  • Okay, it sounds like the C/C++ libraries are closed source then. Can you tell me what the builtin `fwrite` function does by default and if its behavior can be configured?

  • It looks like the stdlib libraries are NOT closed source. Putting an `fwrite("TEST", 4, 1, stdout)` into a sample project and stepping through it, the debugger first finds fwrite.c within "C:\ti\ccs1000\ccc\tools\compiler\ti-cgt-arm_20.2.2.LTS\lib\src" which eventually calls into `HOSTwrite()` and `__TI_writemsg()` implemented in files within the same folder.

    I still haven't found the whole explanation or a good guide to overall usage of the feature, but in short the data is sent via a debugging channel and when stdout is written to it tends to open a "my_project:CIO" console view within the CCS Debug perspective. Nifty! We've been setting up a UART for this kind of logging/interaction but the MSP-FET UART is pretty lousy with dropped characters and stuff. Maybe this will be useful.

    Now that I know a tiny bit more about what I'm asking about, can someone point me to documentation for the HOSTwrite() and CIO? Or whatever their higher-level name is?

  • For the MSP432 specifically, the link is currently http://dev.ti.com/tirex/explore/node?node=AB7f4Ige5MhJBdj939tqxg__z-lQYNj__LATEST (found by a tip for a different platform at https://e2e.ti.com/support/processors/f/791/t/883775). In case the site gets reshuffled those notes were found in the "TI Resource Explorer > SimpleLink MSP432P4 SDK > SimpleLink Academy > Debugging > Debug Printing" article.

    It explains things like:

    By default in CCS (and similarily in IAR), printf output goes to a CIO ('C' Input/Output) buffer. When the CIO buffer is full or a EOL character (i.e. '\n') is written, a breakpoint is hit and CCS reads the contents of the buffer. CCS then resumes the target. As one can guess, this action can have very bad implications for real-time performance.

    and:

    printf output can be redirected. For the below comparisons, we've redirected it to a UART via the add_devicefreopen and setvbuf APIs.

    and specifically mentions the Display_Type_HOST as being for this IDE debugging feature.