Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
84e17063
Commit
84e17063
authored
8 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
zephyr/modusocket: Strip packet header right in the receive callback.
Instead of complicating recv() implementation.
parent
967cad74
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zephyr/modusocket.c
+5
-6
5 additions, 6 deletions
zephyr/modusocket.c
with
5 additions
and
6 deletions
zephyr/modusocket.c
+
5
−
6
View file @
84e17063
...
...
@@ -120,8 +120,6 @@ STATIC void parse_inet_addr(socket_obj_t *socket, mp_obj_t addr_in, struct socka
// to the fact that it copies data byte by byte).
static
char
*
net_buf_gather
(
struct
net_buf
*
buf
,
char
*
to
,
unsigned
max_len
)
{
struct
net_buf
*
tmp
=
buf
->
frags
;
unsigned
header_len
=
net_nbuf_appdata
(
buf
)
-
tmp
->
data
;
net_buf_pull
(
tmp
,
header_len
);
while
(
tmp
&&
max_len
)
{
unsigned
len
=
tmp
->
len
;
...
...
@@ -166,6 +164,10 @@ static void sock_received_cb(struct net_context *context, struct net_buf *net_bu
// Make sure that "EOF flag" is not set
net_nbuf_set_buf_sent
(
net_buf
,
false
);
// We don't care about packet header, so get rid of it asap
unsigned
header_len
=
net_nbuf_appdata
(
net_buf
)
-
net_buf
->
frags
->
data
;
net_buf_pull
(
net_buf
->
frags
,
header_len
);
// net_buf->frags will be overwritten by fifo, so save it
net_nbuf_set_token
(
net_buf
,
net_buf
->
frags
);
k_fifo_put
(
&
socket
->
recv_q
,
net_buf
);
...
...
@@ -350,15 +352,13 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
return
mp_const_empty_bytes
;
}
unsigned
header_len
=
0
;
if
(
socket
->
cur_buf
==
NULL
)
{
DEBUG_printf
(
"TCP recv: no cur_buf, getting
\n
"
);
struct
net_buf
*
net_buf
=
k_fifo_get
(
&
socket
->
recv_q
,
K_FOREVER
);
// Restore ->frags overwritten by fifo
net_buf
->
frags
=
net_nbuf_token
(
net_buf
);
header_len
=
net_nbuf_appdata
(
net_buf
)
-
net_buf
->
frags
->
data
;
DEBUG_printf
(
"TCP recv: new cur_buf: %p, hdr_len: %u
\n
"
,
net_buf
,
header_len
);
DEBUG_printf
(
"TCP recv: new cur_buf: %p
\n
"
,
net_buf
);
socket
->
cur_buf
=
net_buf
;
}
...
...
@@ -368,7 +368,6 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
assert
(
0
);
}
net_buf_pull
(
frag
,
header_len
);
unsigned
frag_len
=
frag
->
len
;
recv_len
=
frag_len
;
if
(
recv_len
>
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