Question on uart lib


I have several configuration strings I need to send with the UART. I was wondering if someone can tell me the best way to use uart1TxSend to send a string.
It doesn’t like uart0TxSend (“test_string”, size).

Thanks a lot,

Hello, Colin.

This should work:

uint8 XDATA buffer[] = "stuff";
if (uart1TxAvailable() >= sizeof(buffer)-1)
  uart1TxSend(buffer, sizeof(buffer)-1);

The documentation is here:

If you’re going to be doing this kind of thing in a lot of places in your code, you might prefer to define a putchar() function that prints to the UART, and then use printf instead. There are example apps in the Wixel SDK that do that.


Thank you David. I think printf is the way to go, especially since many strings need to be constructed out of integers. So my putchar() might look like this?

void putchar(char c)
	while ( !uart1TxAvailable() );

But how big is that Tx buffer? If it’s big enough for the whole string, I might be better off to just not call printf untill there’s room for it all.

Thanks again,

Yes, the putchar you wrote will work, but beware that your function could block for a long time, which might interfere with the requirements of other libraries you are using (e.g. you might want to call usbComService() in the loop).

The buffer is 256 bytes, so yes, you can move the call to uart1TxAvailable() to be before the calls to printf.


Beautiful! Thanks David.