Hello,
i have a function wich just send "hello world" via uart0.
static otError SendUARTCommand(void) {
volatile uint32_t ret;
const uint8_t message[] = "Hello World! \n\r";
dk_set_led_on(DONGLE_RED_MULTI_LED);
ret = uart_tx(UART0Handle, &message, sizeof(message) - 1, SYS_FOREVER_MS);
}
It work when i call this function outside of a zephyr thread.
like this...
void main(void) {
int ret;
ret = dk_leds_init();
UART0Handle = device_get_binding(UART_LABEL);
if (!UART0Handle) {
return;
}
const uint8_t message[] = "Hello World! \n\r";
dk_set_led_on(DONGLE_RED_MULTI_LED);
ret = uart_tx(UART0Handle, &message, sizeof(message) - 1, SYS_FOREVER_MS);
But when if define a zephyr thread (which is working as expected):
K_THREAD_DEFINE(main_thread, MY_STACK_SIZE,
SenderThreadFunction, NULL, NULL, NULL,
MY_PRIORITY, 0, 0);
and call it from this thread:
void SenderThreadFunction(void *p1, void *p2, void *p3) {
...
res = SendUARTCommand(void);
}
The output is corrupted

depending on how many characters i like to send the pattern looks different, but corrupted anyway.
i haven't found any advice how to use this function in threads. may be i have to take a mutex/semaphore, but i don't know which and where this could be provided.
Thanks
Sören