| 767 | } |
| 768 | |
| 769 | void fxReceiveLoop(void) |
| 770 | { |
| 771 | static const char *piBegin = "\r\n<?xs."; |
| 772 | static const char *tagEnd = ">\r\n"; |
| 773 | static txMachine* current = NULL; |
| 774 | static uint8_t state = 0; |
| 775 | static uint16_t binary = 0; |
| 776 | static DebugFragment fragment = NULL; |
| 777 | static uint32_t value = 0; |
| 778 | static uint8_t bufferedBytes = 0; |
| 779 | static uint8_t buffered[128]; |
| 780 | typedef char _assert_buffered_fits_debugBuffer[(sizeof(buffered) < sizeof(((txMachine *)0)->debugBuffer)) ? 1 : -1]; |
| 781 | |
| 782 | if (!mxDebugMutexAllocated()) |
| 783 | return; |
| 784 | |
| 785 | mxDebugMutexTake(); |
| 786 | |
| 787 | modWatchDogReset(); |
| 788 | |
| 789 | while (true) { |
| 790 | int c = ESP_getc(); |
| 791 | if (-1 == c) |
| 792 | break; |
| 793 | |
| 794 | if ((state >= 0) && (state <= 6)) { |
| 795 | if (0 == state) { |
| 796 | current = NULL; |
| 797 | value = 0; |
| 798 | binary = 0; |
| 799 | } |
| 800 | if (c == c_read8(piBegin + state)) |
| 801 | state++; |
| 802 | else |
| 803 | if ((6 == state) && ('#' == c)) { |
| 804 | binary = 1; |
| 805 | state++; |
| 806 | } |
| 807 | else |
| 808 | state = 0; |
| 809 | } |
| 810 | else if ((state >= 7) && (state <= 14)) { |
| 811 | if (('0' <= c) && (c <= '9')) { |
| 812 | state++; |
| 813 | value = (value * 16) + (c - '0'); |
| 814 | } |
| 815 | else if (('a' <= c) && (c <= 'f')) { |
| 816 | state++; |
| 817 | value = (value * 16) + (10 + c - 'a'); |
| 818 | } |
| 819 | else if (('A' <= c) && (c <= 'F')) { |
| 820 | state++; |
| 821 | value = (value * 16) + (10 + c - 'A'); |
| 822 | } |
| 823 | else |
| 824 | state = 0; |
| 825 | } |
| 826 | else if (state == 15) { |
no test coverage detected