Where is Standard Out

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
lilltroll
XCore Expert
Posts: 956
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Where is Standard Out

Post by lilltroll »

I'm taking a look at the XLOG module to be able to redirect stdout to LCD or Ethernet instead of UART.

But - what is standard out by default using XDE?, is it transferred to the console by XTAG, and if, how can XTAG get it from each core?

Can anyone tell me what happens if I write (without XLOG):

printstr("Hello World")

How does XLOG redirect the stdout stream to channels ?


... or do I have to read the debug code... :mrgreen:


Probably not the most confused programmer anymore on the XCORE forum.
User avatar
mjcross
Member++
Posts: 16
Joined: Wed Jun 29, 2011 5:39 pm

Post by mjcross »

Did you ever find an answer to this? I have a similar ambition to redirect stdout to a channel so that I can use printf() to talk to my LCD driver...

Thanks!
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

lilltroll wrote:Can anyone tell me what happens if I write (without XLOG):

printstr("Hello World")
  • printstr() calls _write() (see syscall.h for the prototype of this function)
  • _write() calls _DoSyscall() with r0 set to OSCALL_WRITE (6) and r1 to r3 set to the arguments of _write() (See the Tools development guide for details of this mechanism).
  • The jump to _DoSyscall() causes a breakpoint setup by the debugger to fire.
  • The debugger reads the arguments of _DoSyscall() and translates it into a call to _write() on the host machine. It then writes the return value back to r0 and tells the processor to return from debug.
All printing performed by the print library / the C standard library ends up using _write(). If you want to redirect output then you should provide you own definition of _write(). So long as the definition isn't in a library this will override the standard definition of _write().