MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / rxSerialTask2

Function rxSerialTask2

ESP32_AP-Flasher/src/serialap.cpp:713–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711}
712
713void rxSerialTask2(void* parameter) {
714 char rxStr[100] = {0};
715 int rxStrCount = 0;
716 uint32_t modemResetHoldoff = millis();
717 char lastchar = 0;
718 time_t startTime = millis();
719 int charCount = 0;
720 Serial2.begin(115200, SERIAL_8N1, FLASHER_DEBUG_TXD, FLASHER_DEBUG_RXD);
721 while (rxSerialStopTask2 == false) {
722 while (Serial2.available()) {
723 lastchar = Serial2.read();
724 charCount++;
725
726 // debug info
727 Serial.write(lastchar);
728
729 rxStr[rxStrCount] = lastchar;
730 if (lastchar == '\n' || lastchar == '\r') {
731 if (strncmp(rxStr, "receive buffer full, drop the current frame", 43) == 0 && millisDiff(modemResetHoldoff) > 20000) {
732 modemResetHoldoff = millis();
733 vTaskDelay(100 / portTICK_PERIOD_MS);
734 config.runStatus = RUNSTATUS_STOP;
735 Serial.println("IEEE802.15.4 modem stuck case detected, resetting...");
736 APTagReset();
737 vTaskDelay(1000 / portTICK_PERIOD_MS);
738 Serial.println("bringing AP online again");
739 if (bringAPOnline()) {
740 config.runStatus = RUNSTATUS_RUN;
741 Serial.println("Finished!");
742 } else {
743 Serial.println("Failed!");
744 }
745 logLine("IEEE802.15.4 modem reset " + (config.runStatus == RUNSTATUS_RUN) ? ("ok") : ("failed"));
746 }
747 rxStrCount = 0;
748 memset(rxStr, 0, sizeof(rxStr));
749 } else if (rxStrCount < sizeof(rxStr) - 2) {
750 rxStrCount++;
751 } else {
752 rxStrCount = 0;
753 memset(rxStr, 0, sizeof(rxStr));
754 }
755 }
756 vTaskDelay(1 / portTICK_PERIOD_MS);
757
758 time_t currentTime = millis();
759 if (currentTime - startTime >= 1000) {
760 if (charCount > 6000) {
761 rxSerialStopTask2 = true;
762 Serial.println("Serial monitor stopped because of flooding (" + String(charCount) + " characters per second)");
763 }
764 startTime = currentTime;
765 charCount = 0;
766 }
767 }
768 Serial2.end();
769 Serial.println("Exiting AP serial monitor");
770 vTaskDelete(NULL);

Callers

nothing calls this directly

Calls 11

millisDiffFunction · 0.85
APTagResetFunction · 0.85
bringAPOnlineFunction · 0.85
logLineFunction · 0.85
memsetFunction · 0.85
printlnMethod · 0.80
beginMethod · 0.45
availableMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected