xiaoxiang781216 commented on issue #10556:
URL: https://github.com/apache/nuttx/issues/10556#issuecomment-1712744663

   > > it's wrong to use public(C++ keyword) in stream interface, please 
provide a patch to rename public to other word(e.g. common).
   > 
   > Should I also provide a patch for the `this` keyword being used?
   
   Yes.
   
   > Also would forbidding the use of C++ keywords in C be something to add to 
the [C coding 
standard](https://nuttx.apache.org/docs/latest/contributing/coding_style.html) 
as well as automated checks in `nxstyle`?
   
   it will be great.
   
   > Not sure if this is something that should be brought up in the mailing 
list or not.
   > 
   
   it's a natural requirement that all c header files should be work with c++ 
compiler.
   
   > > 4. rtt serial console: [Add SEGGER RTT serial/console supportĀ 
#9777](https://github.com/apache/nuttx/pull/9777)
   > 
   > Thanks Xiang, it looks like this is equivalent to what I was looking for. 
I see that this PR introduced the `SERIAL_RTT` kconfig. This was after NuttX 
12.2.1 was released so it didn't make the cut. For posterity, I'll post a code 
snippet of how I was able to get RTT working in my nuttx version in a C file:
   > 
   > ```
   >   #include <nuttx/segger/rtt.h>
   >   ....
   > 
   >   struct lib_rttoutstream_s out_stream = {0};
   >  /* channel 0 is reserved by RTT for the Terminal*/
   >   lib_rttoutstream_open(&out_stream, 0, CONFIG_SEGGER_RTT_BUFFER_SIZE_UP);
   > 
   >   /* the below should be equivalent to 
`out_stream.public.puts(&out_stream.public, "dan\r\n", sizeof("dan\r\n");`  */
   >   out_stream.public.putc(&out_stream.public, (int)'d');
   >   out_stream.public.putc(&out_stream.public, (int)'a');
   >   out_stream.public.putc(&out_stream.public, (int)'n');
   >   out_stream.public.putc(&out_stream.public, (int)'\r');
   >   out_stream.public.putc(&out_stream.public, (int)'\n');
   >   out_stream.public.putc(&out_stream.public, (int)'\0');
   > 
   >   while (1){
   >         usleep(500);
   >     }
   > ```
   > 
   
   The code snippet is more like rtt syslog channel:
   https://github.com/apache/nuttx/blob/master/drivers/segger/syslog_rtt.c
   not rtt serial device:
   https://github.com/apache/nuttx/blob/master/drivers/segger/serial_rtt.c
   
   > Using Segger's 
[JLinkRTTViewer](https://www.segger.com/products/debug-probes/j-link/tools/rtt-viewer/),
 I attached to the existing J-link debug session I had with Segger Ozone and 
was able to see my log in Terminal 0: 
![image](https://user-images.githubusercontent.com/66082730/266814288-a90eabdd-e6b2-4fb3-bbe1-77f13daa6d60.png)
   
   If you just want to see the log, syslog_rtt is better than serial_rtt. The 
later is designed to work with nsh through JLink.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to