Skip to content
Snippets Groups Projects
Commit dc2b1def authored by Gunar Schorcht's avatar Gunar Schorcht Committed by Schorcht
Browse files

cpu/esp32: restructures _recv function in esp_eth

parent 8318779b
No related branches found
No related tags found
No related merge requests found
......@@ -245,48 +245,39 @@ static int _esp_eth_recv(netdev_t *netdev, void *buf, size_t len, void *info)
int size = dev->rx_len;
if (!buf && !len) {
/* return the size without dropping received data */
mutex_unlock(&dev->dev_lock);
return size;
}
if (!buf && len) {
/* return the size and drop received data */
if (!buf) {
/* get the size of the frame; if len > 0 then also drop the frame */
if (len > 0) {
/* drop frame requested */
dev->rx_len = 0;
}
mutex_unlock(&dev->dev_lock);
dev->rx_len = 0;
return size;
}
if (buf && len && dev->rx_len) {
/* return the packet */
if (dev->rx_len > len) {
if (dev->rx_len > len) {
/* buffer is smaller than the number of received bytes */
DEBUG("%s: Not enough space in receive buffer for %d bytes\n",
mutex_unlock(&dev->dev_lock);
return -ENOBUFS;
}
#if ENABLE_DEBUG
/* esp_hexdump (dev->rx_buf, dev->rx_len, 'b', 16); */
#endif
__func__, dev->rx_len);
mutex_unlock(&dev->dev_lock);
return -ENOBUFS;
}
/* copy received date and reset the receive length */
memcpy(buf, dev->rx_buf, dev->rx_len);
dev->rx_len = 0;
#if ENABLE_DEBUG
/* esp_hexdump (dev->rx_buf, dev->rx_len, 'b', 16); */
#endif
#ifdef MODULE_NETSTATS_L2
netdev->stats.rx_count++;
netdev->stats.rx_bytes += size;
#endif
/* copy received date and reset the receive length */
memcpy(buf, dev->rx_buf, dev->rx_len);
dev->rx_len = 0;
mutex_unlock(&dev->dev_lock);
return size;
}
#ifdef MODULE_NETSTATS_L2
netdev->stats.rx_count++;
netdev->stats.rx_bytes += size;
#endif
mutex_unlock(&dev->dev_lock);
return -EINVAL;
return size;
}
static int _esp_eth_get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment