6.1.3 Output from Connext DDSUtilities
18
If you are using the Android project files generated by the rtiddsgen-generated makefile to compile the pub-
lisher and subscriber examples as Android Apps, the generated source code for the application is doing
something special to redirect the output to allow them to show up in the Android App.
For the Java example scenario, all the System.out output is redirected to the TextView in the GUI of the
Android App. Refer to the generated Java Activity class source code under the project src directory for
details on how this is done.
For the C/C++ example scenario, a special RTIAndroid_registerOnPrintf() method can be found in the
generated publisher and subscriber example source code to redirect all printf() calls to a function callback.
The RTIAndroid_registerOnPrintf() method is called when the example is run for the first time. Each
time printf() is called from the generated publisher and subscriber example source code, the registered
function callback, implemented in JNI, will be called. In the JNI method, we first attach the current thread
to the Dalvik VM if it has not been done, then we call a method in the Java Activity class to display the
message in the TextView UI. The native thread will be detached from the Dalvik VM, if necessary, before
we return to the native publisher/subscriber example code. Refer to the generated Java Activity class
source code under the project src directory, JNI code, and publisher/subscriber C/C++ code in the
example’s main directory for details on how this is done.
Note that when running the rtiddsgen-generated examples as an Android App, DDS logging messages
and the printing of the Samples in the C or C++ subscriber will still need to be viewed using logcat—they
will not show up in the GUI of the Android App.
Alternatively, you can change the generated example code to cause all the output to go to logcat. For C
and C++, replace all calls to printf() with __android_log_print() with your desired priority and tag. For
Java, use methods in the android.util.Log class instead of the System.out class.
Refer to Android SDK documentation for details:
l http://developer.android.com/tools/debugging/debugging-log.html
6.1.3 Output from Connext DDSUtilities
The Connext DDS rtiddsspy, rtiddsping and rtiddsprototyper utilities are implemented with Connext DDS
core libraries. As a result, DDS log messages must be viewed with logcat.
If you run rtiddsping, rtiddsspy, and rtiddsprototyper in a shell, all the output from the utility will show up
in the shell (even though DDS log messages still need to be viewed with logcat).
If you run rtiddsping, rtiddsspy, and rtiddsprototyper as Android Apps, most of the utility output will
show up on the App UI, with the following exceptions. When running rtiddsspy with the
-printSample option as an Android App, and when running rtiddsprototyper as an Android App, the
value of the received sample is printed to stdout and therefore will not show up in either the UI or in
logcat. The rest of the output from the utility itself will show up in the App UI as expected. DDS log mes-
sages still need to be viewed with logcat.