Skip to content

Commit 747e9f9

Browse files
authored
Merge pull request #7058 from jepler/ioctl-poll
Use micropython #defines for stream polling operations
2 parents 496057e + 068b7c4 commit 747e9f9

File tree

10 files changed

+35
-73
lines changed

10 files changed

+35
-73
lines changed

extmod/moduselect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <stdio.h>
1111

12-
#include "py/ioctl.h"
12+
#include "py/stream.h"
1313
#include "py/runtime.h"
1414
#include "py/obj.h"
1515
#include "py/objlist.h"

py/ioctl.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

shared-bindings/_bleio/CharacteristicBuffer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626

2727
#include "py/mperrno.h"
28-
#include "py/ioctl.h"
28+
#include "py/stream.h"
2929
#include "py/objproperty.h"
3030
#include "py/runtime.h"
3131
#include "py/stream.h"
@@ -138,15 +138,15 @@ STATIC mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t r
138138
check_for_deinit(self);
139139
raise_error_if_not_connected(self);
140140
mp_uint_t ret;
141-
if (request == MP_IOCTL_POLL) {
141+
if (request == MP_STREAM_POLL) {
142142
mp_uint_t flags = arg;
143143
ret = 0;
144-
if ((flags & MP_IOCTL_POLL_RD) && common_hal_bleio_characteristic_buffer_rx_characters_available(self) > 0) {
145-
ret |= MP_IOCTL_POLL_RD;
144+
if ((flags & MP_STREAM_POLL_RD) && common_hal_bleio_characteristic_buffer_rx_characters_available(self) > 0) {
145+
ret |= MP_STREAM_POLL_RD;
146146
}
147147
// No writing provided.
148-
// if ((flags & MP_IOCTL_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) {
149-
// ret |= MP_IOCTL_POLL_WR;
148+
// if ((flags & MP_STREAM_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) {
149+
// ret |= MP_STREAM_POLL_WR;
150150
// }
151151
} else {
152152
*errcode = MP_EINVAL;

shared-bindings/_bleio/PacketBuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626

2727
#include "py/mperrno.h"
28-
#include "py/ioctl.h"
28+
#include "py/stream.h"
2929
#include "py/objproperty.h"
3030
#include "py/runtime.h"
3131
#include "py/stream.h"

shared-bindings/busio/UART.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "shared/runtime/context_manager_helpers.h"
3434
#include "shared/runtime/interrupt_char.h"
3535

36-
#include "py/ioctl.h"
36+
#include "py/stream.h"
3737
#include "py/objproperty.h"
3838
#include "py/objtype.h"
3939
#include "py/runtime.h"
@@ -276,14 +276,14 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t
276276
busio_uart_obj_t *self = native_uart(self_in);
277277
check_for_deinit(self);
278278
mp_uint_t ret;
279-
if (request == MP_IOCTL_POLL) {
279+
if (request == MP_STREAM_POLL) {
280280
mp_uint_t flags = arg;
281281
ret = 0;
282-
if ((flags & MP_IOCTL_POLL_RD) && common_hal_busio_uart_rx_characters_available(self) > 0) {
283-
ret |= MP_IOCTL_POLL_RD;
282+
if ((flags & MP_STREAM_POLL_RD) && common_hal_busio_uart_rx_characters_available(self) > 0) {
283+
ret |= MP_STREAM_POLL_RD;
284284
}
285-
if ((flags & MP_IOCTL_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) {
286-
ret |= MP_IOCTL_POLL_WR;
285+
if ((flags & MP_STREAM_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) {
286+
ret |= MP_STREAM_POLL_WR;
287287
}
288288
} else {
289289
*errcode = MP_EINVAL;

shared-bindings/keypad/EventQueue.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#include "py/ioctl.h"
27+
#include "py/stream.h"
2828
#include "py/mperrno.h"
2929
#include "py/objproperty.h"
3030
#include "py/runtime.h"
@@ -147,8 +147,8 @@ STATIC mp_uint_t eventqueue_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t
147147
case MP_STREAM_POLL: {
148148
mp_uint_t flags = arg;
149149
mp_uint_t ret = 0;
150-
if ((flags & MP_IOCTL_POLL_RD) && common_hal_keypad_eventqueue_get_length(self)) {
151-
ret |= MP_IOCTL_POLL_RD;
150+
if ((flags & MP_STREAM_POLL_RD) && common_hal_keypad_eventqueue_get_length(self)) {
151+
ret |= MP_STREAM_POLL_RD;
152152
}
153153
return ret;
154154
}

shared-bindings/terminalio/Terminal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "shared-bindings/terminalio/Terminal.h"
3030
#include "shared-bindings/util.h"
3131

32-
#include "py/ioctl.h"
32+
#include "py/stream.h"
3333
#include "py/objproperty.h"
3434
#include "py/objstr.h"
3535
#include "py/runtime.h"
@@ -111,11 +111,11 @@ STATIC mp_uint_t terminalio_terminal_write(mp_obj_t self_in, const void *buf_in,
111111
STATIC mp_uint_t terminalio_terminal_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
112112
terminalio_terminal_obj_t *self = MP_OBJ_TO_PTR(self_in);
113113
mp_uint_t ret;
114-
if (request == MP_IOCTL_POLL) {
114+
if (request == MP_STREAM_POLL) {
115115
mp_uint_t flags = arg;
116116
ret = 0;
117-
if ((flags & MP_IOCTL_POLL_WR) && common_hal_terminalio_terminal_ready_to_tx(self)) {
118-
ret |= MP_IOCTL_POLL_WR;
117+
if ((flags & MP_STREAM_POLL_WR) && common_hal_terminalio_terminal_ready_to_tx(self)) {
118+
ret |= MP_STREAM_POLL_WR;
119119
}
120120
} else {
121121
*errcode = MP_EINVAL;

shared-bindings/usb_cdc/Serial.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "shared-bindings/usb_cdc/Serial.h"
3030
#include "shared-bindings/util.h"
3131

32-
#include "py/ioctl.h"
32+
#include "py/stream.h"
3333
#include "py/objproperty.h"
3434
#include "py/runtime.h"
3535
#include "py/stream.h"
@@ -114,14 +114,14 @@ STATIC mp_uint_t usb_cdc_serial_ioctl_stream(mp_obj_t self_in, mp_uint_t request
114114
usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in);
115115
mp_uint_t ret = 0;
116116
switch (request) {
117-
case MP_IOCTL_POLL: {
117+
case MP_STREAM_POLL: {
118118
mp_uint_t flags = arg;
119119
ret = 0;
120-
if ((flags & MP_IOCTL_POLL_RD) && common_hal_usb_cdc_serial_get_in_waiting(self) > 0) {
121-
ret |= MP_IOCTL_POLL_RD;
120+
if ((flags & MP_STREAM_POLL_RD) && common_hal_usb_cdc_serial_get_in_waiting(self) > 0) {
121+
ret |= MP_STREAM_POLL_RD;
122122
}
123-
if ((flags & MP_IOCTL_POLL_WR) && common_hal_usb_cdc_serial_get_out_waiting(self) == 0) {
124-
ret |= MP_IOCTL_POLL_WR;
123+
if ((flags & MP_STREAM_POLL_WR) && common_hal_usb_cdc_serial_get_out_waiting(self) == 0) {
124+
ret |= MP_STREAM_POLL_WR;
125125
}
126126
break;
127127
}

shared-bindings/usb_midi/PortIn.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "shared-bindings/usb_midi/PortIn.h"
3030
#include "shared-bindings/util.h"
3131

32-
#include "py/ioctl.h"
32+
#include "py/stream.h"
3333
#include "py/objproperty.h"
3434
#include "py/runtime.h"
3535
#include "py/stream.h"
@@ -81,11 +81,11 @@ STATIC mp_uint_t usb_midi_portin_read(mp_obj_t self_in, void *buf_in, mp_uint_t
8181
STATIC mp_uint_t usb_midi_portin_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
8282
usb_midi_portin_obj_t *self = MP_OBJ_TO_PTR(self_in);
8383
mp_uint_t ret;
84-
if (request == MP_IOCTL_POLL) {
84+
if (request == MP_STREAM_POLL) {
8585
mp_uint_t flags = arg;
8686
ret = 0;
87-
if ((flags & MP_IOCTL_POLL_RD) && common_hal_usb_midi_portin_bytes_available(self) > 0) {
88-
ret |= MP_IOCTL_POLL_RD;
87+
if ((flags & MP_STREAM_POLL_RD) && common_hal_usb_midi_portin_bytes_available(self) > 0) {
88+
ret |= MP_STREAM_POLL_RD;
8989
}
9090
} else {
9191
*errcode = MP_EINVAL;

shared-bindings/usb_midi/PortOut.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "shared-bindings/usb_midi/PortOut.h"
3030
#include "shared-bindings/util.h"
3131

32-
#include "py/ioctl.h"
32+
#include "py/stream.h"
3333
#include "py/objproperty.h"
3434
#include "py/runtime.h"
3535
#include "py/stream.h"
@@ -64,11 +64,11 @@ STATIC mp_uint_t usb_midi_portout_write(mp_obj_t self_in, const void *buf_in, mp
6464
STATIC mp_uint_t usb_midi_portout_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
6565
usb_midi_portout_obj_t *self = MP_OBJ_TO_PTR(self_in);
6666
mp_uint_t ret;
67-
if (request == MP_IOCTL_POLL) {
67+
if (request == MP_STREAM_POLL) {
6868
mp_uint_t flags = arg;
6969
ret = 0;
70-
if ((flags & MP_IOCTL_POLL_WR) && common_hal_usb_midi_portout_ready_to_tx(self)) {
71-
ret |= MP_IOCTL_POLL_WR;
70+
if ((flags & MP_STREAM_POLL_WR) && common_hal_usb_midi_portout_ready_to_tx(self)) {
71+
ret |= MP_STREAM_POLL_WR;
7272
}
7373
} else {
7474
*errcode = MP_EINVAL;

0 commit comments

Comments
 (0)