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
GitLab 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
64d00511
Commit
64d00511
authored
8 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
zephyr/modusocket: Implement send().
parent
88582e33
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
zephyr/modusocket.c
+20
-0
20 additions, 0 deletions
zephyr/modusocket.c
with
20 additions
and
0 deletions
zephyr/modusocket.c
+
20
−
0
View file @
64d00511
...
@@ -130,6 +130,25 @@ STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
...
@@ -130,6 +130,25 @@ STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
socket_connect_obj
,
socket_connect
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
socket_connect_obj
,
socket_connect
);
STATIC
mp_obj_t
socket_send
(
mp_obj_t
self_in
,
mp_obj_t
buf_in
)
{
socket_obj_t
*
socket
=
self_in
;
socket_check_closed
(
socket
);
mp_buffer_info_t
bufinfo
;
mp_get_buffer_raise
(
buf_in
,
&
bufinfo
,
MP_BUFFER_READ
);
struct
net_buf
*
send_buf
=
net_nbuf_get_tx
(
socket
->
ctx
,
K_FOREVER
);
// TODO: Probably should limit how much data we send in one call still
if
(
!
net_nbuf_append
(
send_buf
,
bufinfo
.
len
,
bufinfo
.
buf
,
K_FOREVER
))
{
mp_raise_OSError
(
ENOSPC
);
}
RAISE_ERRNO
(
net_context_send
(
send_buf
,
/*cb*/
NULL
,
K_FOREVER
,
NULL
,
NULL
));
return
mp_obj_new_int_from_uint
(
bufinfo
.
len
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
socket_send_obj
,
socket_send
);
STATIC
mp_obj_t
socket_close
(
mp_obj_t
self_in
)
{
STATIC
mp_obj_t
socket_close
(
mp_obj_t
self_in
)
{
socket_obj_t
*
socket
=
self_in
;
socket_obj_t
*
socket
=
self_in
;
if
(
socket
->
ctx
!=
NULL
)
{
if
(
socket
->
ctx
!=
NULL
)
{
...
@@ -145,6 +164,7 @@ STATIC const mp_map_elem_t socket_locals_dict_table[] = {
...
@@ -145,6 +164,7 @@ STATIC const mp_map_elem_t socket_locals_dict_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_close
),
(
mp_obj_t
)
&
socket_close_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_close
),
(
mp_obj_t
)
&
socket_close_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_bind
),
(
mp_obj_t
)
&
socket_bind_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_bind
),
(
mp_obj_t
)
&
socket_bind_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_connect
),
(
mp_obj_t
)
&
socket_connect_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_connect
),
(
mp_obj_t
)
&
socket_connect_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_send
),
(
mp_obj_t
)
&
socket_send_obj
},
};
};
STATIC
MP_DEFINE_CONST_DICT
(
socket_locals_dict
,
socket_locals_dict_table
);
STATIC
MP_DEFINE_CONST_DICT
(
socket_locals_dict
,
socket_locals_dict_table
);
...
...
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