-1

I am building a simple telnet style interface for experimental settings on my project. I am getting all the serial output sent to serial (and USB to PC). The code works fine, but if I try to read from Serial or check 'Serial.available()' I will get:

Fatal exception 9(LoadStoreAlignmentCause)

Definition: bool pridaj_cely(uint8_t source_from=0, uint8_t line_LCD=0);

The code:

bool Vstup::pridaj_cely(uint8_t source_from, uint8_t line_LCD) {
  uint8_t i = 0;
  Serial.println(F("one piece input read"));
  switch (origin) {
    case 0: { //Serial
        int16_t znak = -1;
        while (Serial.available() < 0) {
          Serial.print(F("."));
          delay(100);
        }
        Serial.print(F("Somothing is comming"));
        while (Serial.available() > 0) {
          celok[i] = Serial.read();
          if (i < 12)  i++;
        }
      }
      break;
  }
  return 1;
}

Code of Priojenie:

bool pripojenie(bool force_it = 0) {
  Serial.println(("Beginning connection routine"));
  kolo = millis();
  while (!WiFi.isConnected()) {
    int8_t sieti = WiFi.scanComplete();
    Serial.printf("Search result %X", sieti);
    switch (sieti) {
      case -2:
        Serial.println(("\tSearch begins"));
        WiFi.scanNetworks(1);
        delay(50);
        break;
      case -1:
        Serial.print(("."));
        delay(300);
        break;
      default: //This is the relevant case
        Vstup odpoved;
        Serial.ciara;
        Serial.ciara;
        Serial.printf(("Found %X networks"), sieti);
        Serial.ciara;
        Serial.println();
        for (uint8_t i = 0; i < sieti; i++) {
          Serial.printf("%d: %s, Kanál:%d (%ddBm) %s\n", i, WiFi.SSID(i).c_str(), WiFi.channel(i), WiFi.RSSI(i), WiFi.encryptionType(i) == ENC_TYPE_NONE ? "Otvorena" : "");
        }
        Serial.ciara;
        Serial.println(("\nChose network number:"));
        odpoved.pridaj_cely(0);
        // -------------------Never gets past this one-------
        if ((odpoved.Nacislo10() >= 0) && (odpoved.Nacislo10() < sieti)) {
          Serial.printf(("Zadaj heslo pre %s\n"), WiFi.SSID(odpoved.Nacislo10()).c_str());
          String heslo = Serial.readString();
          Serial.print(F("Dostal som "));
          for (uint8_t i = 0; i > heslo.length(); i++) Serial.print(heslo[i]);
          Serial.println();
          Serial.printf(("Vybral som možnosť číslo %d a sieť: "), odpoved.Nacislo10(), WiFi.SSID(odpoved.Nacislo10()).c_str());
          //WiFi.begin(WiFi.SSID(odpoved.Nacislo10()).c_str(), heslo);
        } else Serial.printf(("Nesprávny výber %d"), odpoved.Nacislo10());
    }
  }
}

I have commented all the functions that use pins. The source compiles without any problem.

I am adding the result of exception decoder as it did not help me solve it.


Decoding stack results
0x40202a8d: __yield() at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 105
0x40202355: Stream::timedRead() at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/Stream.cpp line 37
0x40202392: Stream::readString() at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/Stream.cpp line 240
0x402013b6: pripojenie(bool) at /home/asi/Dropbox/Arduino/hotel_vstup/hotel_vstup.ino line 315
0x40203411: malloc(size_t) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/heap.cpp line 95
0x40204548: umm_malloc(size_t) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/umm_malloc/umm_malloc.cpp line 1685
0x402018d8: ESP8266WiFiScanClass::_scanDone(void*, int) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp line 296
0x4020141c: pripojenie_samo(unsigned char) at /home/asi/Dropbox/Arduino/hotel_vstup/hotel_vstup.ino line 327
0x402018d8: ESP8266WiFiScanClass::_scanDone(void*, int) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp line 296
0x40204bb1: std::_Function_handler ::_M_invoke(std::_Any_data const&, int) at /home/asi/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/xtensa-lx106-elf/include/c++/4.8.2/functional line 2073
0x4020197c: ESP8266WiFiScanClass::_scanDone(void*, int) at /home/asi/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/xtensa-lx106-elf/include/c++/4.8.2/functional line 2300
0x4020e5b8: sys_check_timeouts at core/timeouts.c line 368
0x40202957: loop_task(ETSEvent*) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 133
0x4020ac9a: __ssputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 233
0x40206938: _printf_i at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c line 194
0x4020ac9a: __ssputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 233
0x402034b4: malloc_loc(size_t, char const*, int) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/heap.cpp line 126
0x40204548: umm_malloc(size_t) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/umm_malloc/umm_malloc.cpp line 1685
0x402018d8: ESP8266WiFiScanClass::_scanDone(void*, int) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp line 296
0x402018d8: ESP8266WiFiScanClass::_scanDone(void*, int) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp line 296
0x40204738: umm_realloc(void*, size_t) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/umm_malloc/umm_malloc.cpp line 1745
0x402018d8: ESP8266WiFiScanClass::_scanDone(void*, int) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp line 296
0x4020299c: esp_yield() at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 91
0x40202f53: delay(unsigned long) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_wiring.cpp line 54
0x40201a89: ESP8266WiFiScanClass::scanNetworks(bool, bool, unsigned char, unsigned char*) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp line 98
0x40203942: uart_write(uart_t*, char const*, size_t) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/uart.cpp line 498
0x4020299c: esp_yield() at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 91
0x40202f53: delay(unsigned long) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_wiring.cpp line 54
0x402015fd: loop() at /home/asi/Dropbox/Arduino/hotel_vstup/hotel_vstup.ino line 460
0x40201410: pripojenie_samo(unsigned char) at /home/asi/Dropbox/Arduino/hotel_vstup/hotel_vstup.ino line 325
0x40204bb8: std::_Function_base::_Base_manager ::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at /home/asi/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/xtensa-lx106-elf/include/c++/4.8.2/functional line 1934
0x40204ba4: std::_Function_handler ::_M_invoke(std::_Any_data const&, int) at /home/asi/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/xtensa-lx106-elf/include/c++/4.8.2/functional line 2069
0x40201e50: HardwareSerial::setDebugOutput(bool) at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/HardwareSerial.cpp line 79
0x40202a4c: loop_wrapper() at /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 125

line 325 is a wrapper function because async scan can only call void function of specific type and calls pripojenie_samo(uint8_t pointless)

Serial Output: (after translation to English)

Beginning connection routine
Search result 3
-----------------------------------------------------
-----------------------------------------------------
Found  3 networks

-----------------------------------------------------

0: VM5070527, Kanál:11 (-55dBm) 
1: Virgin Media, Kanál:11 (-74dBm) 
2: VM5076233, Kanál:11 (-85dBm) 
-----------------------------------------------------

Chose network number:
Instance cleared
one piece input read

Panic /home/asi/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp:103 __yield

>>>stack>>>

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld

SDK:2.2.1(cfd48f3)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020

  • decode the stack dump of the exception. github.com/me-no-dev/EspExceptionDecoder – Juraj Dec 26 '19 at 6:31
  • Added, but I see no relevant info, just disappointment that chip contains full paths if I comment-out all the Serial-available() and Serial .read() the rest of the code works – Tomas Dec 27 '19 at 13:27
  • the paths are in a file on your computer. the decoding takes the debug info from the files created at build but not uploaded to MCU – Juraj Dec 27 '19 at 13:31
  • Thanks, but the problem is still here – Tomas Dec 27 '19 at 13:32
  • did the build for decoding match the code that crashed? the stack dump indicates crash in pripojenie(bool) – Juraj Dec 27 '19 at 13:35
1

I have figured it out There seem to be understandable limitations if what kind of function can be run as a result of asynchronous scanning (which doesn't seem to interrupt running of a loop function) So if I have used delay(x) or a while loop until there is input on serial, MCU resets after allotted time runs out. I have re-written code to start function from loop when scan is complete, and it all runs fine now. I guess Arduino isn't right language for parallel programing

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.