| 559 | } |
| 560 | |
| 561 | void fxReceive(txMachine* the) |
| 562 | { |
| 563 | struct tcp_pcb *pcb = the->connection; |
| 564 | if (!pcb) return; |
| 565 | |
| 566 | xmodLog(" fxReceive - ENTER"); |
| 567 | |
| 568 | if (kSerialConnection != pcb) { |
| 569 | /* struct pbuf *p; |
| 570 | uint16_t use; |
| 571 | |
| 572 | modWatchDogReset(); |
| 573 | if (NULL == the->readers[0]) { |
| 574 | modDelayMilliseconds(10); |
| 575 | return; |
| 576 | } |
| 577 | |
| 578 | p = the->readers[0]; |
| 579 | if (p->next) |
| 580 | modLog(" fxReceive - cannot handle fragmented!!"); |
| 581 | |
| 582 | mxDebugMutexTake(); |
| 583 | use = p->len - the->readerOffset; |
| 584 | if (use > sizeof(the->debugBuffer)) |
| 585 | use = sizeof(the->debugBuffer); |
| 586 | #if 0 |
| 587 | c_memmove(the->debugBuffer, the->readerOffset + (char *)p->payload, use); |
| 588 | the->readerOffset += use; |
| 589 | the->debugOffset = use; |
| 590 | #else |
| 591 | uint16_t i; |
| 592 | uint8_t *debugBuffer = the->debugBuffer; |
| 593 | for (i = 0; i < use; i++) { |
| 594 | uint8_t byte = *(uint8_t *)(i + the->readerOffset + (char *)p->payload); |
| 595 | switch (the->wsState) { |
| 596 | case 0: |
| 597 | the->wsState = 1; |
| 598 | the->wsFin = 0 != (0x80 & byte); |
| 599 | if (NULL == the->wsCmd) { |
| 600 | if (8 == (byte & 0x0f)) { // close |
| 601 | fxDisconnect(the); |
| 602 | use = 0; |
| 603 | break; |
| 604 | } |
| 605 | the->wsCmd = (2 == (byte & 0x0f)) ? (void *)-1 : NULL; // binary data is cmd; text is xsbug |
| 606 | } |
| 607 | break; |
| 608 | case 1: |
| 609 | byte &= 0x7F; |
| 610 | if (126 == byte) |
| 611 | the->wsState = 3; |
| 612 | else { |
| 613 | the->wsLength = byte; |
| 614 | the->wsState = 5; |
| 615 | } |
| 616 | break; |
| 617 | case 2: //@@ unused |
| 618 | break; |
nothing calls this directly
no test coverage detected