Skip to content

Commit 8fa3d29

Browse files
committed
stm32/modnwwiznet5k: Implement stream ioctl for the Wiznet driver.
Now supports polling for read and write ability.
1 parent 285ac58 commit 8fa3d29

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

ports/stm32/modnwwiznet5k.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "py/objlist.h"
3232
#include "py/runtime.h"
33+
#include "py/stream.h"
3334
#include "py/mperrno.h"
3435
#include "py/mphal.h"
3536
#include "lib/netutils/netutils.h"
@@ -305,9 +306,19 @@ STATIC int wiznet5k_socket_settimeout(mod_network_socket_obj_t *socket, mp_uint_
305306
}
306307

307308
STATIC int wiznet5k_socket_ioctl(mod_network_socket_obj_t *socket, mp_uint_t request, mp_uint_t arg, int *_errno) {
308-
// TODO
309-
*_errno = MP_EINVAL;
310-
return -1;
309+
if (request == MP_STREAM_POLL) {
310+
int ret = 0;
311+
if (arg & MP_STREAM_POLL_RD && getSn_RX_RSR(socket->u_param.fileno) != 0) {
312+
ret |= MP_STREAM_POLL_RD;
313+
}
314+
if (arg & MP_STREAM_POLL_WR && getSn_TX_FSR(socket->u_param.fileno) != 0) {
315+
ret |= MP_STREAM_POLL_WR;
316+
}
317+
return ret;
318+
} else {
319+
*_errno = MP_EINVAL;
320+
return MP_STREAM_ERROR;
321+
}
311322
}
312323

313324
#if 0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy