| 120 | } |
| 121 | |
| 122 | int EthernetUDP::parsePacket() |
| 123 | { |
| 124 | // discard any remaining bytes in the last packet |
| 125 | flush(); |
| 126 | |
| 127 | if (w5500.getRXReceivedSize(_sock) > 0) |
| 128 | { |
| 129 | //HACK - hand-parse the UDP packet using TCP recv method |
| 130 | uint8_t tmpBuf[8]; |
| 131 | int ret =0; |
| 132 | //read 8 header bytes and get IP and port from it |
| 133 | ret = recv(_sock,tmpBuf,8); |
| 134 | if (ret > 0) |
| 135 | { |
| 136 | _remoteIP = tmpBuf; |
| 137 | _remotePort = tmpBuf[4]; |
| 138 | _remotePort = (_remotePort << 8) + tmpBuf[5]; |
| 139 | _remaining = tmpBuf[6]; |
| 140 | _remaining = (_remaining << 8) + tmpBuf[7]; |
| 141 | |
| 142 | // When we get here, any remaining bytes are the data |
| 143 | ret = _remaining; |
| 144 | } |
| 145 | return ret; |
| 146 | } |
| 147 | // There aren't any packets available |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | int EthernetUDP::read() |
| 152 | { |
no test coverage detected