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

Function rxSerialTask

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

Source from the content-addressed store, hash-verified

455 }
456}
457void rxSerialTask(void* parameter) {
458 static char cmdbuffer[4] = {0};
459 static uint8_t* packetp = nullptr;
460 // static uint8_t pktlen = 0;
461 static uint8_t pktindex = 0; // length of the command
462 static uint8_t RXState = ZBS_RX_WAIT_HEADER;
463 static char lastchar = 0;
464 static uint8_t charindex = 0;
465
466 gSerialTaskState = SERIAL_STATE_RUNNING;
467 LOG("rxSerialTask starting\n");
468 while (gSerialTaskState == SERIAL_STATE_RUNNING) {
469 while (AP_SERIAL_PORT.available()) {
470 lastchar = AP_SERIAL_PORT.read();
471 switch (RXState) {
472 case ZBS_RX_WAIT_HEADER:
473
474 Serial.write(lastchar);
475
476 // shift characters in
477 for (uint8_t c = 0; c < 3; c++) {
478 cmdbuffer[c] = cmdbuffer[c + 1];
479 }
480 cmdbuffer[3] = lastchar;
481
482 if ((strncmp(cmdbuffer, "ACK>", 4) == 0)) cmdReplyValue = CMD_REPLY_ACK;
483 if ((strncmp(cmdbuffer, "NOK>", 4) == 0)) cmdReplyValue = CMD_REPLY_NOK;
484 if ((strncmp(cmdbuffer, "NOQ>", 4) == 0)) cmdReplyValue = CMD_REPLY_NOQ;
485
486 if ((strncmp(cmdbuffer, "VER>", 4) == 0)) {
487 pktindex = 0;
488 RXState = ZBS_RX_WAIT_VER;
489 charindex = 0;
490 memset(cmdbuffer, 0x00, 4);
491 }
492 if ((strncmp(cmdbuffer, "MAC>", 4) == 0)) {
493 RXState = ZBS_RX_WAIT_MAC;
494 charindex = 0;
495 memset(cmdbuffer, 0x00, 4);
496 }
497 if ((strncmp(cmdbuffer, "ZCH>", 4) == 0)) {
498 RXState = ZBS_RX_WAIT_CHANNEL;
499 charindex = 0;
500 memset(cmdbuffer, 0x00, 4);
501 }
502#ifdef HAS_SUBGHZ
503 if ((strncmp(cmdbuffer, "SCH>", 4) == 0)) {
504 RXState = ZBS_RX_WAIT_SUBCHANNEL;
505 charindex = 0;
506 memset(cmdbuffer, 0x00, 4);
507 }
508#endif
509 if ((strncmp(cmdbuffer, "ZPW>", 4) == 0)) {
510 RXState = ZBS_RX_WAIT_POWER;
511 charindex = 0;
512 memset(cmdbuffer, 0x00, 4);
513 }
514 if ((strncmp(cmdbuffer, "PEN>", 4) == 0)) {

Callers

nothing calls this directly

Calls 6

memsetFunction · 0.85
addRXQueueFunction · 0.85
availableMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected