Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
dc2b1def
Commit
dc2b1def
authored
6 years ago
by
Gunar Schorcht
Committed by
Schorcht
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cpu/esp32: restructures _recv function in esp_eth
parent
8318779b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpu/esp32/esp-eth/esp_eth_netdev.c
+22
-31
22 additions, 31 deletions
cpu/esp32/esp-eth/esp_eth_netdev.c
with
22 additions
and
31 deletions
cpu/esp32/esp-eth/esp_eth_netdev.c
+
22
−
31
View file @
dc2b1def
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment