kopia lustrzana https://github.com/micropython/micropython
stm32/modnwwiznet5k: Implement stream ioctl for the Wiznet driver.
Now supports polling for read and write ability.pull/3377/head
rodzic
285ac58532
commit
8fa3d2996c
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "py/objlist.h"
|
#include "py/objlist.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
#include "py/stream.h"
|
||||||
#include "py/mperrno.h"
|
#include "py/mperrno.h"
|
||||||
#include "py/mphal.h"
|
#include "py/mphal.h"
|
||||||
#include "lib/netutils/netutils.h"
|
#include "lib/netutils/netutils.h"
|
||||||
|
@ -305,9 +306,19 @@ STATIC int wiznet5k_socket_settimeout(mod_network_socket_obj_t *socket, mp_uint_
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int wiznet5k_socket_ioctl(mod_network_socket_obj_t *socket, mp_uint_t request, mp_uint_t arg, int *_errno) {
|
STATIC int wiznet5k_socket_ioctl(mod_network_socket_obj_t *socket, mp_uint_t request, mp_uint_t arg, int *_errno) {
|
||||||
// TODO
|
if (request == MP_STREAM_POLL) {
|
||||||
|
int ret = 0;
|
||||||
|
if (arg & MP_STREAM_POLL_RD && getSn_RX_RSR(socket->u_param.fileno) != 0) {
|
||||||
|
ret |= MP_STREAM_POLL_RD;
|
||||||
|
}
|
||||||
|
if (arg & MP_STREAM_POLL_WR && getSn_TX_FSR(socket->u_param.fileno) != 0) {
|
||||||
|
ret |= MP_STREAM_POLL_WR;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
*_errno = MP_EINVAL;
|
*_errno = MP_EINVAL;
|
||||||
return -1;
|
return MP_STREAM_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
Ładowanie…
Reference in New Issue