mDNS component's real time safety

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

mDNS component's real time safety

Postby PeterR » Wed Jun 20, 2018 11:47 am

Hi,
I am have an IoT application to develop on the ESP32. The device will advertise using mDNS, host a webserver etc etc.
There is an mDNS component in the ESP library which would be awesome to use.
I am puzzled though as the ESP component uses both a FreeRTOS thread and the LwIP raw UDP API (pbufs etc).

I had understood that the LwIP raw api was not reentrant. Perhaps the example works because only the mDNS component uses LwIP?
Is the mDNS component going to work when I add other tasks; webserver, MQTT etc?

Has anyone used the mDNS component with other tasks and IP activity?
& I also believe that IDF CAN should be fixed.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: mDNS component's real time safety

Postby kolban » Wed Jun 20, 2018 4:17 pm

Howdy and welcome to the forum. I haven't looked inside the mDNS component's implementation but my belief is that the internals of such a component are free to use whichever technology/implementations that makes sense to them as long as the result satisfies the contract of usage. I haven't seen anywhere a statement that using the mDNS component precludes using the other networking APIs such as WiFi and sockets.

There appears to be a sample of using the mDNS component found here:

https://github.com/espressif/esp-idf/bl ... ple_main.c
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: mDNS component's real time safety

Postby PeterR » Fri Jun 22, 2018 1:34 pm

Thanks.
Looking into this deeper and there are semaphores controlling Ethernet buffer access within emac_main.c
I am not sure though; although pbuf() allocation seems to be controlled pbuf chaining does not appear to be controlled.

Anyone able to confirm and/or provide reference (I know the LwIP reference that raw api is not thread safe)?
& I also believe that IDF CAN should be fixed.

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: mDNS component's real time safety

Postby ESP_igrr » Sun Jun 24, 2018 12:16 pm

mDNS indeed was initially written on top of non thread safe raw API. Thread safety was implemented in https://github.com/espressif/esp-idf/pull/733 later.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: mDNS component's real time safety

Postby WiFive » Sun Jun 24, 2018 3:13 pm

mdns has been rewritten since that commit and the current init and deinit are done in API calls but write is not.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: mDNS component's real time safety

Postby PeterR » Thu Jun 28, 2018 11:07 am

Cool, that really helps a lot. I did not spot tcpip_api_call() in the API documentation (is it documented?).
Easy enough now to modify this and other thread unsafe examples.
Weird that they undid the RT safety on the write though.
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: No registered users and 84 guests