cc3200: Make socket stream methods return POSIX error codes.

This commit is contained in:
Daniel Campora 2015-07-16 22:39:35 +02:00
parent f738424403
commit a243d6b057
2 changed files with 15 additions and 3 deletions

View File

@ -418,12 +418,24 @@ MP_DEFINE_CONST_DICT(socket_locals_dict, socket_locals_dict_table);
STATIC mp_uint_t socket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { STATIC mp_uint_t socket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {
mod_network_socket_obj_t *self = self_in; mod_network_socket_obj_t *self = self_in;
return wlan_socket_recv(self, buf, size, errcode); mp_int_t ret = wlan_socket_recv(self, buf, size, errcode);
if (ret < 0) {
ret = MP_STREAM_ERROR;
// needed to convert simplelink's negative error codes to POSIX
(*errcode) *= -1;
}
return ret;
} }
STATIC mp_uint_t socket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { STATIC mp_uint_t socket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
mod_network_socket_obj_t *self = self_in; mod_network_socket_obj_t *self = self_in;
return wlan_socket_send(self, buf, size, errcode); mp_int_t ret = wlan_socket_send(self, buf, size, errcode);
if (ret < 0) {
ret = MP_STREAM_ERROR;
// needed to convert simplelink's negative error codes to POSIX
(*errcode) *= -1;
}
return ret;
} }
STATIC mp_uint_t socket_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) { STATIC mp_uint_t socket_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {

View File

@ -1357,7 +1357,7 @@ int wlan_socket_ioctl (mod_network_socket_obj_t *s, mp_uint_t request, mp_uint_t
} }
} else { } else {
*_errno = EINVAL; *_errno = EINVAL;
ret = -1; ret = MP_STREAM_ERROR;
} }
return ret; return ret;
} }