Page 1 of 1

Dual Core share serial

Posted: Thu Jun 18, 2020 12:52 pm
by Lodewyk
Good day,

I have code running on Core 0 and different code on Core 1.

I would like to serial.print stuff from both cores, but let's say core1 has to finish writing before core 0 can use the serial hardware.
IE i want to queue core 0's message to wait for the buffer to be empty before attempting to send, thereafter core 0 has access once again.

Core 1 will send tons of messages really fast and Core 0 only now and then, it is very important that they share the hardware serial I do not want to use one of the other serial ports available.

If anyone can point me to a way of checking if the serial transmit buffer is empty that would be great.

Regards
Lodewyk

Re: Dual Core share serial

Posted: Fri Jun 19, 2020 3:47 am
by lbernstone
You should set a binary semaphore, and have each processes take the semaphore when they need to write. Then, simply flush the serial object, write, and give back the semaphore. Rinse, repeat.
https://docs.espressif.com/projects/esp ... aphore-api