Use micropython #defines for stream polling operations
We adopted the file "py/ioctl.h" and the ioctl names beginning with MP_IOCTL_POLL while micropython went with "py/stream.h" and MP_STREAM_POLL. Align with upstream. Closes #6711
This commit is contained in:
parent
b4c2ef13e4
commit
068b7c4af8
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/objlist.h"
|
#include "py/objlist.h"
|
||||||
|
38
py/ioctl.h
38
py/ioctl.h
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Micro Python project, http://micropython.org/
|
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* SPDX-FileCopyrightText: Copyright (c) 2013-2015 Damien P. George
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
#ifndef MICROPY_INCLUDED_PY_IOCTL_H
|
|
||||||
#define MICROPY_INCLUDED_PY_IOCTL_H
|
|
||||||
|
|
||||||
#define MP_IOCTL_POLL (0x100 | 1)
|
|
||||||
|
|
||||||
// These values are compatible with Linux, which are in turn
|
|
||||||
// compatible with iBCS2 spec.
|
|
||||||
#define MP_IOCTL_POLL_RD (0x0001)
|
|
||||||
#define MP_IOCTL_POLL_WR (0x0004)
|
|
||||||
#define MP_IOCTL_POLL_ERR (0x0008)
|
|
||||||
#define MP_IOCTL_POLL_HUP (0x0010)
|
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_PY_IOCTL_H
|
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "py/mperrno.h"
|
#include "py/mperrno.h"
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stream.h"
|
#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
|
|||||||
check_for_deinit(self);
|
check_for_deinit(self);
|
||||||
raise_error_if_not_connected(self);
|
raise_error_if_not_connected(self);
|
||||||
mp_uint_t ret;
|
mp_uint_t ret;
|
||||||
if (request == MP_IOCTL_POLL) {
|
if (request == MP_STREAM_POLL) {
|
||||||
mp_uint_t flags = arg;
|
mp_uint_t flags = arg;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if ((flags & MP_IOCTL_POLL_RD) && common_hal_bleio_characteristic_buffer_rx_characters_available(self) > 0) {
|
if ((flags & MP_STREAM_POLL_RD) && common_hal_bleio_characteristic_buffer_rx_characters_available(self) > 0) {
|
||||||
ret |= MP_IOCTL_POLL_RD;
|
ret |= MP_STREAM_POLL_RD;
|
||||||
}
|
}
|
||||||
// No writing provided.
|
// No writing provided.
|
||||||
// if ((flags & MP_IOCTL_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) {
|
// if ((flags & MP_STREAM_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) {
|
||||||
// ret |= MP_IOCTL_POLL_WR;
|
// ret |= MP_STREAM_POLL_WR;
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
*errcode = MP_EINVAL;
|
*errcode = MP_EINVAL;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "py/mperrno.h"
|
#include "py/mperrno.h"
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stream.h"
|
#include "py/stream.h"
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "shared/runtime/context_manager_helpers.h"
|
#include "shared/runtime/context_manager_helpers.h"
|
||||||
#include "shared/runtime/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
|
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/objtype.h"
|
#include "py/objtype.h"
|
||||||
#include "py/runtime.h"
|
#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
|
|||||||
busio_uart_obj_t *self = native_uart(self_in);
|
busio_uart_obj_t *self = native_uart(self_in);
|
||||||
check_for_deinit(self);
|
check_for_deinit(self);
|
||||||
mp_uint_t ret;
|
mp_uint_t ret;
|
||||||
if (request == MP_IOCTL_POLL) {
|
if (request == MP_STREAM_POLL) {
|
||||||
mp_uint_t flags = arg;
|
mp_uint_t flags = arg;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if ((flags & MP_IOCTL_POLL_RD) && common_hal_busio_uart_rx_characters_available(self) > 0) {
|
if ((flags & MP_STREAM_POLL_RD) && common_hal_busio_uart_rx_characters_available(self) > 0) {
|
||||||
ret |= MP_IOCTL_POLL_RD;
|
ret |= MP_STREAM_POLL_RD;
|
||||||
}
|
}
|
||||||
if ((flags & MP_IOCTL_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) {
|
if ((flags & MP_STREAM_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) {
|
||||||
ret |= MP_IOCTL_POLL_WR;
|
ret |= MP_STREAM_POLL_WR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*errcode = MP_EINVAL;
|
*errcode = MP_EINVAL;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/mperrno.h"
|
#include "py/mperrno.h"
|
||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/runtime.h"
|
#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
|
|||||||
case MP_STREAM_POLL: {
|
case MP_STREAM_POLL: {
|
||||||
mp_uint_t flags = arg;
|
mp_uint_t flags = arg;
|
||||||
mp_uint_t ret = 0;
|
mp_uint_t ret = 0;
|
||||||
if ((flags & MP_IOCTL_POLL_RD) && common_hal_keypad_eventqueue_get_length(self)) {
|
if ((flags & MP_STREAM_POLL_RD) && common_hal_keypad_eventqueue_get_length(self)) {
|
||||||
ret |= MP_IOCTL_POLL_RD;
|
ret |= MP_STREAM_POLL_RD;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "shared-bindings/terminalio/Terminal.h"
|
#include "shared-bindings/terminalio/Terminal.h"
|
||||||
#include "shared-bindings/util.h"
|
#include "shared-bindings/util.h"
|
||||||
|
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/objstr.h"
|
#include "py/objstr.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
@ -111,11 +111,11 @@ STATIC mp_uint_t terminalio_terminal_write(mp_obj_t self_in, const void *buf_in,
|
|||||||
STATIC mp_uint_t terminalio_terminal_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
STATIC mp_uint_t terminalio_terminal_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
||||||
terminalio_terminal_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
terminalio_terminal_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
mp_uint_t ret;
|
mp_uint_t ret;
|
||||||
if (request == MP_IOCTL_POLL) {
|
if (request == MP_STREAM_POLL) {
|
||||||
mp_uint_t flags = arg;
|
mp_uint_t flags = arg;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if ((flags & MP_IOCTL_POLL_WR) && common_hal_terminalio_terminal_ready_to_tx(self)) {
|
if ((flags & MP_STREAM_POLL_WR) && common_hal_terminalio_terminal_ready_to_tx(self)) {
|
||||||
ret |= MP_IOCTL_POLL_WR;
|
ret |= MP_STREAM_POLL_WR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*errcode = MP_EINVAL;
|
*errcode = MP_EINVAL;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "shared-bindings/usb_cdc/Serial.h"
|
#include "shared-bindings/usb_cdc/Serial.h"
|
||||||
#include "shared-bindings/util.h"
|
#include "shared-bindings/util.h"
|
||||||
|
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stream.h"
|
#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
|
|||||||
usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
mp_uint_t ret = 0;
|
mp_uint_t ret = 0;
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case MP_IOCTL_POLL: {
|
case MP_STREAM_POLL: {
|
||||||
mp_uint_t flags = arg;
|
mp_uint_t flags = arg;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if ((flags & MP_IOCTL_POLL_RD) && common_hal_usb_cdc_serial_get_in_waiting(self) > 0) {
|
if ((flags & MP_STREAM_POLL_RD) && common_hal_usb_cdc_serial_get_in_waiting(self) > 0) {
|
||||||
ret |= MP_IOCTL_POLL_RD;
|
ret |= MP_STREAM_POLL_RD;
|
||||||
}
|
}
|
||||||
if ((flags & MP_IOCTL_POLL_WR) && common_hal_usb_cdc_serial_get_out_waiting(self) == 0) {
|
if ((flags & MP_STREAM_POLL_WR) && common_hal_usb_cdc_serial_get_out_waiting(self) == 0) {
|
||||||
ret |= MP_IOCTL_POLL_WR;
|
ret |= MP_STREAM_POLL_WR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "shared-bindings/usb_midi/PortIn.h"
|
#include "shared-bindings/usb_midi/PortIn.h"
|
||||||
#include "shared-bindings/util.h"
|
#include "shared-bindings/util.h"
|
||||||
|
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stream.h"
|
#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
|
|||||||
STATIC mp_uint_t usb_midi_portin_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
STATIC mp_uint_t usb_midi_portin_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
||||||
usb_midi_portin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
usb_midi_portin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
mp_uint_t ret;
|
mp_uint_t ret;
|
||||||
if (request == MP_IOCTL_POLL) {
|
if (request == MP_STREAM_POLL) {
|
||||||
mp_uint_t flags = arg;
|
mp_uint_t flags = arg;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if ((flags & MP_IOCTL_POLL_RD) && common_hal_usb_midi_portin_bytes_available(self) > 0) {
|
if ((flags & MP_STREAM_POLL_RD) && common_hal_usb_midi_portin_bytes_available(self) > 0) {
|
||||||
ret |= MP_IOCTL_POLL_RD;
|
ret |= MP_STREAM_POLL_RD;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*errcode = MP_EINVAL;
|
*errcode = MP_EINVAL;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "shared-bindings/usb_midi/PortOut.h"
|
#include "shared-bindings/usb_midi/PortOut.h"
|
||||||
#include "shared-bindings/util.h"
|
#include "shared-bindings/util.h"
|
||||||
|
|
||||||
#include "py/ioctl.h"
|
#include "py/stream.h"
|
||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stream.h"
|
#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
|
|||||||
STATIC mp_uint_t usb_midi_portout_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
STATIC mp_uint_t usb_midi_portout_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
||||||
usb_midi_portout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
usb_midi_portout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
mp_uint_t ret;
|
mp_uint_t ret;
|
||||||
if (request == MP_IOCTL_POLL) {
|
if (request == MP_STREAM_POLL) {
|
||||||
mp_uint_t flags = arg;
|
mp_uint_t flags = arg;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if ((flags & MP_IOCTL_POLL_WR) && common_hal_usb_midi_portout_ready_to_tx(self)) {
|
if ((flags & MP_STREAM_POLL_WR) && common_hal_usb_midi_portout_ready_to_tx(self)) {
|
||||||
ret |= MP_IOCTL_POLL_WR;
|
ret |= MP_STREAM_POLL_WR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*errcode = MP_EINVAL;
|
*errcode = MP_EINVAL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user