ESP32 Command Station

Atani Dec 10, 2017

  1. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Well here's a compile error for you... I disabled #include "Config_LCC.h", and get a bunch of errors stemming from this one:

    In file included from include/ESP32CommandStation.h:112:0,
    from src/DCC/DCCProgrammer.cpp:18:
    include/ConfigValidation.h:369:4: error: #error "Invalid Configuration detected, LCC_CAN_RX_PIN and " "LCC_CAN_TX_PIN must be unique."

    There doesn't seem to be a variable to indicate if the LCC module is enabled like I see in other modules (for example: #define S88_ENABLED true) so I assume there's no testing in ConfigValidation.h and the code just assumes LCC is always going to be enabled?

    Regarding my sound issue... it would help if I could find my laptop, but I haven't been able to figure out where I put it. Obviously I don't use it very often. :) I may have to break down and use the terminal on my phone, but ugh, that's some painful typing.

    [Update] Woo-hoo, finally found the laptop! And interestingly, the whistle DOES work properly under the current master code. Perhaps it was one of those broken DCC timing issues that you were referring to, who knows? But at least I do know now that the sound card is working correctly.

    I also realized why I can't get the web interface to work on my phone (or my laptop)... it's because the raspberry pi, which provides my wifi network for the train, doesn't bridge the connection to the internet. I prefer to keep it isolated, and as such, in the past I had always copied down the current versions of all the jquery files to the Pi and modified index.html to point to the local sources. I'll have to do that again once I can build the development code, but I thought I'd point out that there CAN be cases where the train network is isolated (for example, if I took my setup to a train club meeting where we have no internet). Could you keep it in mind as a build option to point to local sources, possibly with a script to run on the desktop which can grab all the appropriate jquery files and drop them into a folder?
     
    Last edited: Oct 18, 2019
  2. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Starting with v1.5.0 LCC is a mandatory module, no config changes are required unless you intend to use the LCC functionality in which case updating the node-id should be done to ensure uniqueness but it is not mandatory. I'll add a better validation check to ConfigValidation.h so it aborts compilation with a more clear error indicating that LCC is mandatory.

    Great! Very likely it was a timing issue.

    Starting with v1.5.0 all required files are served directly from the CS rather than offloading to a CDN. The usage of the CDN was required previously to offload the jQuery css/js loads as they would often lead to the EspAsyncWebServer crashing (and thus the entire TCP/IP stack crashing!). With the new httpd code in place the CS is able to serve up the content more reliably and has a few extra features available, one being the ability to have the CS act as an AP for true internet disconnected operation.
     
  3. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    I have tried your recent (2 day old) development build on an Adafruit ESP32. Builds great. Even easier with the Python 3 changes. Thanks for that.
    I tried connecting JMRI to the CAN WIFI point with both name (from the serial stream) and name.local. Neither worked. I used PIO to display all of the mDSN entries and my esp32 is not there. Same with attempts to get to the HTTP point by name. Everything works with the IP address instead.
    I have a fairly extensive network with lots of routers that could affect multicast. So I reduced my network to one SSID with it's router. Same issue. Now this is NOT really any issue for me, but I thought you might want to know. I can hard code IP addresses. My DHCP server attempts to assign the same IP address to know MAC addresses. I see mDNS logging is on and going to stderr. But I don't see that output so I suspect I am looking in the wrong place.

    Thanks
     
  4. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Hmm, this sounds like a bug in the ESP32 mDNS code from ESP-IDF. You should see in the CS console something like:
    Code:
    [mDNS] Advertising _http._tcp:80.
    
    I'll do some testing of this and see what I can find out, but I'm thinking it could be a race condition between the startup/init of mDNS and when the publish call is made. I don't have an easy way to scan mDNS on my PC (windows 7) so I'll fire up the rPi and do some scans from there.

    It should log to the serial console of the CS (UART0, USB, etc).

    I'm glad that it worked for you. I've pushed out a couple small updates today for S88 and a slight performance improvement on the web interface (deferred loading of javascript files, may or may not work for all browsers).

    I'm planning on doing some testing of the CS connected to the layout this weekend and hopefully nothing major will come out of it to fix.
     
  5. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    This is not high priority. But I am passing this along so you can see what I am seeing:

    Shutdown limit 4080/4096 (1992.19 mA), events (on: 50101013f000002, off: 50101013f000003)
    [WiFi] Starting WiFi Manager task
    [WiFi] Starting TCP/IP stack
    [WiFi] Initializing WiFi stack
    [WiFi] Configuring Station (SSID: 314159DN)
    [WiFi] Starting WiFi stack
    [WiFi] [1/36] Waiting for SSID connection.
    [WiFi] Setting ESP32 hostname to "esp32cs_50101013f00".
    [WiFi] MAC Address: 24:0a:c4:12:fd:6c
    [mDNS] Initializing mDNS system
    [mDNS] Setting mDNS hostname to "esp32cs_50101013f00"
    [DHCP] Starting DHCP Client.
    [WiFi] Station started, attempting to connect to SSID: 314159DN.
    Allocating new alias 0B9 for node 050101013f00
    [WiFi] Connected to SSID: 314159DN
    [IPv4] [2/36] Waiting for IP address assignment.
    [WiFi] IP address is 10.0.1.56, starting hub (if enabled) and uplink.
    [httpd] Starting HTTP listener on port 80
    [mDNS] Advertising _http._tcp:80.
    Listening on port 80, fd 48
    [WiFi] Starting JMRI listener
    [mDNS] Advertising _esp32cs._tcp:2560.
    Listening on port 2560, fd 49

    This is an Adafruit esp32 because my esp32 development board stopped updating code. It says it does but the results don't change. The timing may be very different on this board than your board. BTW, I see the mDSN values with PIO and then devices and then multicast DNS. Does that not work on Windows 7. I checked it with dns-sd (or something very close to that) but that returned even fewer entries.
     
  6. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    You might run an erase_flash on the "dead" board if it is at all recognized by the PC. Or use esptool.py directly to verify the board is still functional.

    I've reproduced the mDNS issue locally and have a possible fix as seen below:
    Code:
    [IPv4] [2/36] Waiting for IP address assignment.
    [WiFi] IP address is 10.0.0.76, starting hub (if enabled) and uplink.
    [httpd] Starting HTTP listener on port 80
    [mDNS] Advertising _http._tcp:80.
    Listening on port 80, fd 48
    [HUB] Starting TCP/IP listener on port 12021
    Listening on port 12021, fd 49
    [mDNS] Advertising _openlcb-can._tcp:12021.
    [mDNS] mdns_service_add(_http._tcp:80): ESP_FAIL.
    [WiFi] Starting JMRI listener
    [mDNS] Advertising _esp32cs._tcp:2560.
    [mDNS] Advertising _http._tcp:80.
    Listening on port 2560, fd 50
    [mDNS] mdns_service_add(_esp32cs._tcp:2560): ESP_OK.
    [Nextion] Display of page 2 was not successful.
    [mDNS] mdns_service_add(_openlcb-can._tcp:12021): ESP_OK.
    [mDNS] mdns_service_add(_http._tcp:80): ESP_OK.
    
    The problem appears to be the call to the ESP-IDF API mdns_service_add() returning ESP_FAIL which occurs due to a timeout condition. The mDNS task runs at a very low priority whereas the rest of the system runs at a much higher priority. I've added an explicit check for ESP_FAIL and added code to reschedule the call to mdns_service_add() until the API returns ESP_OK (success).

    However, even with this my rPi does not see the service being advertised so there is still something to be resolved here. I'll be logging an issue to track this since it was previously working.
     
  7. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    I know what is happening, but I don't know why:
    multicast requires a JOIN to look for the multicast packet. And that has a parameter of the connection type. That type is AP (1), but the pointers are setup for station (0). And this has nothing to do with initialization. The code that fails is:

    esp_err_t mdns_init()
    ....
    for (i=0; i<TCPIP_ADAPTER_IF_MAX; i++) {
    if (!tcpip_adapter_get_ip6_linklocal(i, &tmp_addr6) && !_ipv6_address_is_zero(tmp_addr6)) {
    _mdns_enable_pcb(i, MDNS_IP_PROTOCOL_V6);
    }
    if (!tcpip_adapter_get_ip_info(i, &if_ip_info) && if_ip_info.ip.addr) {
    printf("JFF Calling enable_pcb %d\n", i); fflush(stdout);
    // JFF _mdns_enable_pcb(i, MDNS_IP_PROTOCOL_V4);
    _mdns_enable_pcb(0, MDNS_IP_PROTOCOL_V4); // JFF I changed this to do the real registration. The value of i is 1
    }
    }


    from dsn-sd -B
    21:39:10.454 Add 3 11 local. _http._tcp. esp32cs_50101013f00
    21:39:10.454 Add 2 18 local. _http._tcp. esp32cs_50101013f00
    C:\Users\John>dns-sd -B _esp32cs
    Browsing for _esp32cs._tcp
    Timestamp A/R Flags if Domain Service Type Instance Name
    21:43:05.715 Add 3 11 local. _esp32cs._tcp. esp32cs_50101013f00
    21:43:05.715 Add 2 18 local. _esp32cs._tcp. esp32cs_50101013f00

    My trace will make little sense but notice that the code is looking for an IP address before we get connected.

    [WiFi] Setting ESP32 hostname to "esp32cs_50101013f00".
    [WiFi] MAC Address: 24:0a:c4:12:fd:6c
    [mDNS] Initializing mDNS system
    JFF Calling enable_pcb 1 JFF prints 1 but really call with 0 see code above
    JFF Enable PCB
    JFF UDP PCB INIT
    JFF join group 0 1 The 0 is the IF type
    Loop through interfaces looking for non-zero values. Only 0 has such a value.
    JFF interface 0 1
    JFF interface 1 0
    JFF interface 2 0
    JFF UDP main init
    JFF UDP PCB MAIN INIT success
    Start Service Task JFFStarted Service Task JFF[mDNS] Setting mDNS hostname to "esp32cs_50101013f00"
    [DHCP] Starting DHCP Client.
    [WiFi] Station started, attempting to connect to SSID: 314159DN.
    Allocating new alias 0B9 for node 050101013f00
    [WiFi] Connected to SSID: 314159DN
    [IPv4] [2/36] Waiting for IP address assignment.
    [WiFi] IP address is 10.0.1.56, starting hub (if enabled) and uplink.
    [httpd] Starting HTTP listener on port 80
    [mDNS] Advertising _http._tcp:80.
    Listening on port 80, fd 48
    [WiFi] Starting JMRI listener
    [mDNS] Advertising _esp32cs._tcp:2560.
    Listening on port 2560, fd 49

    TX[0][0]: To: 224.0.0.251:5353, Packet[1912]:
    Q: ._openlcb-can._tcp.local. PTR IN

    TX[0][0]: To: 224.0.0.251:5353, Packet[2111]:
    Q: *U* esp32cs_50101013f00._esp32cs._tcp.local. ANY IN
    Q: *U* esp32cs_50101013f00._http._tcp.local. ANY IN
    Q: *U* esp32cs_50101013f00...local. ANY IN
    S: esp32cs_50101013f00._esp32cs._tcp.local. SRV IN 120 [8] 0 0 2560 esp32cs_50101013f00.local.
    S: esp32cs_50101013f00._http._tcp.local. SRV IN 120 [8] 0 0 80 esp32cs_50101013f00.local.
    S: esp32cs_50101013f00.local. A IN 120 [4] 10.0.1.56

    TX[0][0]: To: 224.0.0.251:5353, Packet[2411]:
    Q: esp32cs_50101013f00._esp32cs._tcp.local. ANY IN
    Q: esp32cs_50101013f00._http._tcp.local. ANY IN
    Q: esp32cs_50101013f00...local. ANY IN
    S: esp32cs_50101013f00._esp32cs._tcp.local. SRV IN 120 [8] 0 0 2560 esp32cs_50101013f00.local.
    S: esp32cs_50101013f00._http._tcp.local. SRV IN 120 [8] 0 0 80 esp32cs_50101013f00.local.
    S: esp32cs_50101013f00.local. A IN 120 [4] 10.0.1.56

    TX[0][0]: To: 224.0.0.251:5353, Packet[2711]:
    Q: esp32cs_50101013f00._esp32cs._tcp.local. ANY IN
    Q: esp32cs_50101013f00._http._tcp.local. ANY IN
    Q: esp32cs_50101013f00...local. ANY IN
    S: esp32cs_50101013f00._esp32cs._tcp.local. SRV IN 120 [8] 0 0 2560 esp32cs_50101013f00.local.
    S: esp32cs_50101013f00._http._tcp.local. SRV IN 120 [8] 0 0 80 esp32cs_50101013f00.local.
    S: esp32cs_50101013f00.local. A IN 120 [4] 10.0.1.56
     
  8. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    I moved the mdsn_init to just after the IP address is obtained and that fixed the issue. This is in the openMRN code and that part matches what is in GIT for the master. There are too many branches to guess if there is a fix on one of them.

    oddly this doesn't show up in the platformIO mdns device list even though dsn-sd can find them.

    [WiFi] IP address is 10.0.1.56, starting hub (if enabled) and uplink.
    [mDNS] Initializing mDNS system
    JFF Calling enable_pcb 0
    JFF Enable PCB
    JFF UDP PCB INIT
    JFF UDP main init
    JFF UDP PCB MAIN INIT success
    JFF Calling enable_pcb 1
    JFF Enable PCB
    JFF UDP PCB INIT
    [mDNS] Setting mDNS hostname to "esp32cs_50101013f00"

    C:\Users\John>dns-sd -B
    Browsing for _http._tcp
    Timestamp A/R Flags if Domain Service Type Instance Name
    23:33:22.237 Add 3 11 local. _http._tcp. esp32cs_50101013f00
    23:33:22.237 Add 3 11 local. _http._tcp. Roamio
    23:33:22.237 Add 3 11 local. _http._tcp. Living Room
    23:33:22.237 Add 3 11 local. _http._tcp. Media Room
    23:33:22.237 Add 3 11 local. _http._tcp. Roamio (2)
    23:33:22.237 Add 2 11 local. _http._tcp. Canon MX920 series
    ^C

    C:\Users\John>dns-sd -B _esp32cs
    Browsing for _esp32cs._tcp
    Timestamp A/R Flags if Domain Service Type Instance Name
    23:34:02.284 Add 2 11 local. _esp32cs._tcp. esp32cs_50101013f00

    and after while I get

    ESP_ERROR_CHECK_WITHOUT_ABORT failed: esp_err_t 0x101 (ESP_ERR_NO_MEM) at 0x4008879b
    file: "lib\OpenMRNLite\src\freertos_drivers\esp32\Esp32WiFiManager.cpp" line 1200
    func: int mdns_lookup(const char*, addrinfo*, addrinfo**)
    expression: mdns_query_ptr(service_name.c_str(), protocol_name.c_str(), MDNS_QUERY_TIMEOUT, MDNS_MAX_RESULTS, &results)

    [TaskMon] uptime: 00:06:00 freeHeap: 151048, largest free block: 88752, tasks: 17, mainBufferPool: 464

    ESP_ERROR_CHECK_WITHOUT_ABORT failed: esp_err_t 0x101 (ESP_ERR_NO_MEM) at 0x4008879b
    file: "lib\OpenMRNLite\src\freertos_drivers\esp32\Esp32WiFiManager.cpp" line 1200
    func: int mdns_lookup(const char*, addrinfo*, addrinfo**)
    expression: mdns_query_ptr(service_name.c_str(), protocol_name.c_str(), MDNS_QUERY_TIMEOUT, MDNS_MAX_R
     
  9. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    ESP32 CS is a bit ahead of OpenMRN/OpenMRNLite as I've been developing new features for OpenMRN on the ESP32 and have been testing them. In this case it looks like I need to adjust the timing (again) as there is a built-in dependency from mdns_init() on the system having IP addresses assigned. Right now this change is pending merge to OpenMRN but I've held it back so I could do extended testing before merge. I've updated the code locally in the ESP32 CS to fix up the mDNS startup issue and it should be fixed shortly on the development branch.

    Interesting, I wonder why it thinks there was no memory. I'll need to dig into the code a bit and see what is possibly causing that. This is being called from the LCC Uplink code searching for an mDNS service registration for _openlcb-can._tcp which should be advertised by an LCC Hub (OpenMRN/applications/hub is a perfect example of one and is what I setup on my rPi for testing with JMRI).
     
  10. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    @John Flanagan If you can pull the latest development code and give it a try I'd appreciate it. The updated code now defers mdns_publish calls and mdns_init until both SoftAP and Station are UP when they are both enabled or when SoftAP is only enabled it will start after configuring the IP address (if static IP is used).

    I've not seen the memory crash that you have reported yet but I'll keep an eye out for it.
     
  11. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    The mdsn_query_ptr code returns non memory for several things that have nothing to do with memory. Like a queuing error. So that could be some parameter issue. I can look at that later in the week. Also there is some chance that I messed up some code I changed so I need to delete and reload the ESP32 code I may have changed.

    I will pull down the latest code.
     
  12. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    I had repeated errors when JMRI was opened and attempted to connect to the esp32....local name. The 10.0.1.16 IP is my windows JMRI workstation.

    Is there a way to turn on a meaningful trace back to see what was happening?

    Incoming connection from 10.0.1.16, fd 50.
    CORRUPT HEAP: multi_heap.c:165 detected at 0x3ffe1e98
    abort() was called at PC 0x4008f58b on core 0
    E (1219) esp_apptrace: Application tracing via TRAX is disabled in menuconfig!

    ELF file SHA256: 0000000000000000000000000000000000000000000000000000000000000000

    Backtrace: 0x40088255:0x3ffc4750 0x400884e5:0x3ffc4770 0x4008f58b:0x3ffc4790 0x4008f828:0x3ffc47b0 0x4008f985:0x3ffc47d0 0x4008fd86:0x3ffc47f0 0x4008426d:0x3ffc4810 0x4008689d:0x3ffc4830 0x4000bec7:0x3ffc4850 0x401974f1:0x3ffc4870 0x4010715b:0x3ffc4890 0x40112289:0x3ffc4900 0x40107450:0x3ffc4920 0x401074f1:0x3ffc4980 0x400d3f0a:0x3ffc49d0 0x40104f3b:0x3ffc49f0 0x400ea77f:0x3ffc4a20 0x4013bf64:0x3ffc4ce0 0x4008cac5:0x3ffc4d00

    E (1269) esp_apptrace: Application tracing via TRAX is disabled in menuconfig!
    Rebooting...

    At this point I cleaned everything and rebuild it. This is the latest ESP32 code because I uninstalled everything and re-installed it.

    Incoming connection from 10.0.1.16, fd 50.
    CORRUPT HEAP: Bad tail at 0x3ffe1fb0. Expected 0xbaad5678 got 0x00000032
    assertion "head != NULL" failed: file "C:\users\john\.platformio\packages\framework-espidf\components\heap\multi_heap_poisoning.c", line 214, function: multi_heap_free
    abort() was called at PC 0x4018730f on core 0
    E (6156) esp_apptrace: Application tracing via TRAX is disabled in menuconfig!

    ELF file SHA256: 0000000000000000000000000000000000000000000000000000000000000000

    Backtrace: 0x40088255:0x3ffc4710 0x400884e5:0x3ffc4730 0x4018730f:0x3ffc4750 0x4008fd7f:0x3ffc4780 0x4008426d:0x3ffc47a0 0x4008689d:0x3ffc47c0 0x4000bec7:0x3ffc47e0 0x4012c3fd:0x3ffc4800 0x401306ce:0x3ffc4820 0x40130701:0x3ffc4860 0x40107081:0x3ffc4890 0x40112231:0x3ffc4900 0x401073f4:0x3ffc4920 0x40107495:0x3ffc4980 0x400d3f0a:0x3ffc49d0 0x40104f3b:0x3ffc49f0 0x400ea77f:0x3ffc4a20 0x4013bf0c:0x3ffc4ce0 0x4008cac5:0x3ffc4d00

    E (6208) esp_apptrace: Application tracing via TRAX is disabled in menuconfig!
     
  13. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    Something is wrong with my environment. The line numbers didn't match up right so I re-downloaded your code as opposed to a GIT update. That fixed that but the build worked and it should not have as I didn't fix my SSID.
     
  14. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    The ssid and pw are stored in a json file in spiffs or sd. Once you have a good build on the esp32 it will use those values going forward. Long term the goal will be move more of the config to be set at runtime rather than compile time.

    The backtrace can be decoded but I find it is usually not as meaningful in PIO as other envs. Something with the compile flags it picks as defaults ends up corrupting the line numbers and filenames at times, though it usually gets method names right and gets pretty close to the right place.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  15. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    Some how I must have gotten the config SSID stored there. I thought it was a build/load issue. I erased the flash and loaded again. I don't know why my line numbers were off in the file you changed. I use GIT GUI and update from origin. But they were wrong which means some code was wrong. I downloaded all the files again and rebuilt. I just don't know how to prevent this next time.

    All of the issues went away. No abort, no false claim of memory not available. One nit issue of a bad IP address print.

    istening on port 2560, fd 49
    [mDNS] Advertising _http._tcp:80.
    [mDNS] Advertising _esp32cs._tcp:2560.
    Incoming connection from 10.0.1.16, fd 50.
    [JMRI 0.0.0.0/50] Connected
     
  16. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Good to know, and yes the JMRI line is a known issue. I'll be fixing that up soon.

    If you see it again you can go to the web ui and click the factory reset button and it should restart the CS using whatever "default" config that has been configured via the Config_XXX files. It is also possible to reconfigure the CS directly in the web ui under the Command Station -> Configuration section (including some LCC bits!)

    It sounds like it did some sort of merge to the code rather than a reset to origin or what you had wanted. From GIT GUI you should be able to a "reset --hard" and then do a pull. You should also be able to do all of this inside VS:Code directly, the third icon down on the left side bar is for source control and you can do a pull and have it sync from origin automatically (even discard all local changes etc).
     
  17. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    The "memory error" has returned. But it it not a memory error but a queuing error. The action queue in mdns.c in the platform code fails a queue. Which must mean the un-queue must be not keeping up. The queue is 16 deep. So it is unlikely it is full. Perhaps the task stops. I put in prints to see but the issue has not happened again with the prints in.
     
  18. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    This is very likely due to the mDNS task created inside mdns.c is running at priority 1 and almost all other tasks running at a much higher priority. Due to this the mDNS task is receiving little to no runtime on the cores. This is a poorly implemented mDNS responder in this regard, when an item is inserted to the queue the task should be woken up (or scheduled) so it can process it quickly.

    Until the mDNS task can be configured via KConfig there are only a couple options to work around this:
    1. Increase the "mdns" task priority by scanning running tasks.
    2. Reduce the priority of OpenMRN task.
    Option #1 is doable in the CS code with FreeRTOS public APIs but only because CONFIG_FREERTOS_USE_TRACE_FACILITY is enabled, this is not feasible to use inside OpenMRN as it is not enabled by default in arduino-esp32. Option #2 is not typically used from the OpenMRNLite library with the default examples which rely strictly on the setup()/loop() invocation of the OpenMRN library. The CS opts for a higher performance option of offloading the OpenMRN Executor to it's own task (inheriting from app_main task), this is possible from OpenMRNLite by calling OpenMRN::start_executor_thread() or OpenMRN::loop_executor() (CS uses this option).

    To test if the "mdns" task is being starved (it seems to be in your test env), try commenting this line.
     
  19. John Flanagan

    John Flanagan TrainBoard Member

    45
    6
    7
    The line to comment out didn't make it. But I have interesting traces. First the code

    for (;;) {
    if (_mdns_server && _mdns_server->action_queue) {
    printf("JFF queueReceive\n"); fflush(stdout);
    if (xQueueReceive(_mdns_server->action_queue, &a, portMAX_DELAY) == pdTRUE) {
    if (a->type == ACTION_TASK_STOP) {
    printf("JFF service task STOP called\n"); fflush(stdout);
    break;
    }
    printf("JFF Unqueue action\n"); fflush(stdout);
    MDNS_SERVICE_LOCK();
    _mdns_execute_action(a);
    MDNS_SERVICE_UNLOCK();
    printf("JFF after UNLOCK\n"); fflush(stdout);
    }
    } else {
    vTaskDelay(500 * portTICK_PERIOD_MS);
    }
    }
    And the last part of _mdns_execute_action

    }
    printf("JFF End Action\n"); fflush(stdout);
    free(action);
    printf("JFF after free\n"); fflush(stdout);
    }

    So the "after free" is just before the implied return; And the next line is UNLOCK and then the print. But this looks like the UNLOCK never returned.

    I am not running the tracks so the chip is basically idle. The UNLOCK is a QUEUE_SEND that probably kicks off a higher priority task waiting.

    JFF queueReceive
    JFF Unqueue action
    JFF Execute action 12
    JFF End Action
    JFF after free
    JFF after UNLOCK
    JFF queueReceive
    JFF Unqueue action
    JFF Execute action 13
    JFF End Action
    JFF after free
    JFF xQueueSend
    JFF send_search_action failed
    ESP_ERROR_CHECK_WITHOUT_ABORT failed: esp_err_t 0x101 (ESP_ERR_NO_MEM) at 0x4008879b
    file: "lib\OpenMRNLite\src\freertos_drivers\esp32\Esp32WiFiManager.cpp" line 1274
    func: int mdns_lookup(const char*, addrinfo*, addrinfo**)
    expression: mdns_query_ptr(service_name.c_str(), protocol_name.c_str(), MDNS_QUERY_TIMEOUT, MDNS_MAX_RESULTS, &results)
     
  20. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    I updated the code after sending the line to comment, if you work from the current development code it should not have the starvation based on the task priorities. I need to do more testing on it but it seemed to work.
     

Share This Page