Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
5ebf3978
Commit
5ebf3978
authored
Jun 29, 2015
by
Daniel Campora
Browse files
cc3200: Correct socket settimeout time format.
parent
9780e552
Changes
3
Hide whitespace changes
Inline
Side-by-side
cc3200/mods/modusocket.c
View file @
5ebf3978
...
...
@@ -358,7 +358,7 @@ STATIC mp_obj_t socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) {
if
(
timeout_in
==
mp_const_none
)
{
timeout
=
-
1
;
}
else
{
timeout
=
1000
*
mp_obj_get_int
(
timeout_in
);
timeout
=
mp_obj_get_int
(
timeout_in
);
}
int
_errno
;
if
(
wlan_socket_settimeout
(
self
,
timeout
,
&
_errno
)
!=
0
)
{
...
...
cc3200/mods/modwlan.c
View file @
5ebf3978
...
...
@@ -1279,21 +1279,24 @@ int wlan_socket_setsockopt(mod_network_socket_obj_t *socket, mp_uint_t level, mp
return
0
;
}
int
wlan_socket_settimeout
(
mod_network_socket_obj_t
*
s
,
mp_uint_t
timeout_
m
s
,
int
*
_errno
)
{
int
wlan_socket_settimeout
(
mod_network_socket_obj_t
*
s
,
mp_uint_t
timeout_s
,
int
*
_errno
)
{
int
ret
;
if
(
timeout_
m
s
==
0
||
timeout_
m
s
==
-
1
)
{
in
t
opt
val
;
if
(
timeout_
m
s
==
0
)
{
if
(
timeout_s
==
0
||
timeout_s
==
-
1
)
{
SlSockNonblocking_
t
opt
ion
;
if
(
timeout_s
==
0
)
{
// set non-blocking mode
opt
val
=
1
;
opt
ion
.
NonblockingEnabled
=
1
;
}
else
{
// set blocking mode
opt
val
=
0
;
opt
ion
.
NonblockingEnabled
=
0
;
}
ret
=
sl_SetSockOpt
(
s
->
sd
,
SOL_SOCKET
,
SO_NONBLOCKING
,
&
opt
val
,
sizeof
(
opt
val
));
ret
=
sl_SetSockOpt
(
s
->
sd
,
SOL_SOCKET
,
SO_NONBLOCKING
,
&
opt
ion
,
sizeof
(
opt
ion
));
}
else
{
// set timeout
ret
=
sl_SetSockOpt
(
s
->
sd
,
SOL_SOCKET
,
SO_RCVTIMEO
,
&
timeout_ms
,
sizeof
(
timeout_ms
));
struct
SlTimeval_t
timeVal
;
timeVal
.
tv_sec
=
timeout_s
;
// seconds
timeVal
.
tv_usec
=
0
;
// microseconds. 10000 microseconds resolution
ret
=
sl_SetSockOpt
(
s
->
sd
,
SOL_SOCKET
,
SO_RCVTIMEO
,
&
timeVal
,
sizeof
(
timeVal
));
}
if
(
ret
!=
0
)
{
...
...
cc3200/mods/modwlan.h
View file @
5ebf3978
...
...
@@ -76,7 +76,7 @@ extern int wlan_socket_recv(mod_network_socket_obj_t *s, byte *buf, mp_uint_t le
extern
int
wlan_socket_sendto
(
mod_network_socket_obj_t
*
s
,
const
byte
*
buf
,
mp_uint_t
len
,
byte
*
ip
,
mp_uint_t
port
,
int
*
_errno
);
extern
int
wlan_socket_recvfrom
(
mod_network_socket_obj_t
*
s
,
byte
*
buf
,
mp_uint_t
len
,
byte
*
ip
,
mp_uint_t
*
port
,
int
*
_errno
);
extern
int
wlan_socket_setsockopt
(
mod_network_socket_obj_t
*
socket
,
mp_uint_t
level
,
mp_uint_t
opt
,
const
void
*
optval
,
mp_uint_t
optlen
,
int
*
_errno
);
extern
int
wlan_socket_settimeout
(
mod_network_socket_obj_t
*
s
,
mp_uint_t
timeout_
m
s
,
int
*
_errno
);
extern
int
wlan_socket_settimeout
(
mod_network_socket_obj_t
*
s
,
mp_uint_t
timeout_s
,
int
*
_errno
);
extern
int
wlan_socket_ioctl
(
mod_network_socket_obj_t
*
s
,
mp_uint_t
request
,
mp_uint_t
arg
,
int
*
_errno
);
#endif
/* MODWLAN_H_ */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment