Dual Core share serial

Lodewyk
Posts: 2
Joined: Mon Dec 30, 2019 5:07 pm

Dual Core share serial

Postby Lodewyk » Thu Jun 18, 2020 12:52 pm

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

lbernstone
Posts: 97
Joined: Mon Jul 22, 2019 3:20 pm

Re: Dual Core share serial

Postby lbernstone » Fri Jun 19, 2020 3:47 am

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

Who is online

Users browsing this forum: No registered users and 15 guests