Is uart_write_bytes and read thread safe?

username
Posts: 477
Joined: Thu May 03, 2018 1:18 pm

Re: Is uart_write_bytes and read thread safe?

Postby username » Tue Oct 22, 2019 10:58 pm

I am glad it cut your compile time down. Just know that the -j8 is not for everyone. On my computer its -j16.
With the cost of the ESP32, and all that it has dual cores, large flash, and the RTOS. I just don't understand why anyone would even use anything Arduino anymore.

zliudr
Posts: 357
Joined: Thu Oct 03, 2019 5:15 am

Re: Is uart_write_bytes and read thread safe?

Postby zliudr » Wed Oct 23, 2019 12:45 am

Arduino has training wheels so that anyone who can blink an LED can use ESP32 with minimal efforts. ESP-IDF is pretty intimidating. I've spent my years programming various systems otherwise I'd be intimidated to even starting. Less people can help you if you do ESP-IDF than if you do arduino. Anyway, I really appreciate your responses. For a while I thought I was stuck having to read all 1600 pages but now I feel that I'll eventually read all those pages :)

zliudr
Posts: 357
Joined: Thu Oct 03, 2019 5:15 am

Re: Is uart_write_bytes and read thread safe?

Postby zliudr » Thu Oct 24, 2019 3:17 am

Hey username,

Thanks for your code. I just got a chance to read it and compare with some sample code I've been running/tinkering. So you have two tasks, one task sets a bit in an event group and the other task waits for bit change to acts according to the bit, then clears the bit. What if there needs to be data exchanged? My use case will be one task is running azure client and it may receive a message from azure server. It needs to inform my main task of the received message. The main task takes the message and uses it. Can I do the following?
A static pointer is defined outside functions. Messenger task receives a message, malloc memory and copy it to malloc memory. It saves the memory pointer to the static pointer. It sets a bit MESSAGE_RECEIVED. The main task sees the bit, it uses the static pointer to access the content, free the memory when done, then clears the bit. The messenger task will buffer additional messages while the MESSAGE_RECEIVE bit is still set. When it is cleared, malloc memory to pass the next message. Does this make sense?

Thanks.

Who is online

Users browsing this forum: No registered users and 89 guests