Merge pull request #7016 from jepler/remove-multiterminal
Remove multiterminal
This commit is contained in:
commit
6b0c08682c
|
@ -202,10 +202,10 @@ interchangeably with the CPython name. This is confusing. Instead, think up a
|
|||
new name that is related to the extra functionality you are adding.
|
||||
|
||||
For example, storage mounting and unmounting related functions were moved from
|
||||
``uos`` into a new `storage` module. Terminal-related functions were moved into
|
||||
`multiterminal`. These names better match their functionality and do not
|
||||
conflict with CPython names. Make sure to check that you don't conflict with
|
||||
CPython libraries too. That way we can port the API to CPython in the future.
|
||||
``uos`` into a new `storage` module. These names better match their
|
||||
functionality and do not conflict with CPython names. Make sure to check that
|
||||
you don't conflict with CPython libraries too. That way we can port the API to
|
||||
CPython in the future.
|
||||
|
||||
Example
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -90,7 +90,6 @@ shared-bindings/microcontroller/Pin.rst shared-bindings/microcontroller/#microco
|
|||
shared-bindings/microcontroller/Processor.rst shared-bindings/microcontroller/#microcontroller.Processor
|
||||
shared-bindings/microcontroller/RunMode.rst shared-bindings/microcontroller/#microcontroller.RunMode
|
||||
shared-bindings/microcontroller/__init__.rst shared-bindings/microcontroller/
|
||||
shared-bindings/multiterminal/__init__.rst shared-bindings/multiterminal/
|
||||
shared-bindings/neopixel_write/__init__.rst shared-bindings/neopixel_write/
|
||||
shared-bindings/network/__init__.rst shared-bindings/network/
|
||||
shared-bindings/nvm/ByteArray.rst shared-bindings/nvm/#nvm.ByteArray
|
||||
|
|
|
@ -1934,10 +1934,6 @@ msgstr ""
|
|||
msgid "Stereo right must be on PWM channel B"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/multiterminal/__init__.c
|
||||
msgid "Stream missing readinto() or write() method."
|
||||
msgstr ""
|
||||
|
||||
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
|
||||
msgid "Supply at least one UART pin"
|
||||
msgstr ""
|
||||
|
@ -3799,6 +3795,7 @@ msgstr ""
|
|||
|
||||
#: ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.h
|
||||
#: ports/espressif/boards/beetle-esp32-c3/mpconfigboard.h
|
||||
#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n8r2/mpconfigboard.h
|
||||
#: ports/espressif/boards/lolin_c3_mini/mpconfigboard.h
|
||||
#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h
|
||||
#: supervisor/shared/safe_mode.c
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include "shared-bindings/multiterminal/__init__.h"
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/mphal.h"
|
||||
#include "py/runtime.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
|
||||
//| """Manage additional terminal sources
|
||||
//|
|
||||
//| The `multiterminal` module allows you to configure an additional serial
|
||||
//| terminal source. Incoming characters are accepted from both the internal
|
||||
//| serial connection and the optional secondary connection."""
|
||||
|
||||
//| def get_secondary_terminal() -> Optional[typing.BinaryIO]:
|
||||
//| """Returns the current secondary terminal."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t multiterminal_obj_get_secondary_terminal() {
|
||||
return common_hal_multiterminal_get_secondary_terminal();
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(multiterminal_get_secondary_terminal_obj, multiterminal_obj_get_secondary_terminal);
|
||||
|
||||
//| def set_secondary_terminal(stream: typing.BinaryIO) -> None:
|
||||
//| """Read additional input from the given stream and write out back to it.
|
||||
//| This doesn't replace the core stream (usually UART or native USB) but is
|
||||
//| mixed in instead.
|
||||
//|
|
||||
//| :param stream stream: secondary stream"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t multiterminal_obj_set_secondary_terminal(mp_obj_t secondary_terminal) {
|
||||
mp_obj_t write_m[3];
|
||||
mp_load_method_maybe(secondary_terminal, MP_QSTR_write, write_m);
|
||||
mp_obj_t readinto_m[3];
|
||||
mp_load_method_maybe(secondary_terminal, MP_QSTR_readinto, readinto_m);
|
||||
if (write_m[0] == MP_OBJ_NULL || readinto_m[0] == MP_OBJ_NULL) {
|
||||
mp_raise_ValueError(translate("Stream missing readinto() or write() method."));
|
||||
return mp_const_none;
|
||||
}
|
||||
common_hal_multiterminal_set_secondary_terminal(secondary_terminal);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(multiterminal_set_secondary_terminal_obj, multiterminal_obj_set_secondary_terminal);
|
||||
|
||||
//| def clear_secondary_terminal() -> None:
|
||||
//| """Clears the secondary terminal."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t multiterminal_obj_clear_secondary_terminal() {
|
||||
common_hal_multiterminal_clear_secondary_terminal();
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(multiterminal_clear_secondary_terminal_obj, multiterminal_obj_clear_secondary_terminal);
|
||||
|
||||
//| def schedule_secondary_terminal_read(socket: socket.socket) -> None:
|
||||
//| """In cases where the underlying OS is doing task scheduling, this notifies
|
||||
//| the OS when more data is available on the socket to read. This is useful
|
||||
//| as a callback for lwip sockets."""
|
||||
//| ...
|
||||
//|
|
||||
// TODO(tannewt): This is a funny API. Replace it with a direct call into the OS
|
||||
// by the lwip object.
|
||||
STATIC mp_obj_t multiterminal_obj_schedule_secondary_terminal_read(mp_obj_t socket) {
|
||||
common_hal_multiterminal_schedule_secondary_terminal_read(socket);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(multiterminal_schedule_secondary_terminal_read_obj, multiterminal_obj_schedule_secondary_terminal_read);
|
||||
|
||||
// TODO(tannewt): Expose the internal serial connection as `primary_terminal`
|
||||
|
||||
STATIC const mp_rom_map_elem_t multiterminal_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_multiterminal) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_get_secondary_terminal), MP_ROM_PTR(&multiterminal_get_secondary_terminal_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_secondary_terminal), MP_ROM_PTR(&multiterminal_set_secondary_terminal_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_clear_secondary_terminal), MP_ROM_PTR(&multiterminal_clear_secondary_terminal_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_schedule_secondary_terminal_read), MP_ROM_PTR(&multiterminal_schedule_secondary_terminal_read_obj) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(multiterminal_module_globals, multiterminal_module_globals_table);
|
||||
|
||||
const mp_obj_module_t multiterminal_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t *)&multiterminal_module_globals,
|
||||
};
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* 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 SHARED_BINDINGS_MULTITERMINAL___INIT___H
|
||||
#define SHARED_BINDINGS_MULTITERMINAL___INIT___H
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
void common_hal_multiterminal_schedule_secondary_terminal_read(mp_obj_t socket);
|
||||
mp_obj_t common_hal_multiterminal_get_secondary_terminal();
|
||||
void common_hal_multiterminal_set_secondary_terminal(mp_obj_t secondary_terminal);
|
||||
void common_hal_multiterminal_clear_secondary_terminal();
|
||||
|
||||
#endif // SHARED_BINDINGS_MULTITERMINAL___INIT___H
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Paul Sokolovsky
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "py/mpstate.h"
|
||||
|
||||
#include "shared-bindings/multiterminal/__init__.h"
|
||||
|
||||
mp_obj_t shared_module_multiterminal_get_secondary_terminal() {
|
||||
if (MP_STATE_VM(dupterm_objs[0]) == MP_OBJ_NULL) {
|
||||
return mp_const_none;
|
||||
} else {
|
||||
return MP_STATE_VM(dupterm_objs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void shared_module_multiterminal_set_secondary_terminal(mp_obj_t secondary_terminal) {
|
||||
MP_STATE_VM(dupterm_objs[0]) = secondary_terminal;
|
||||
if (MP_STATE_PORT(dupterm_arr_obj) == MP_OBJ_NULL) {
|
||||
MP_STATE_PORT(dupterm_arr_obj) = mp_obj_new_bytearray(1, "");
|
||||
}
|
||||
}
|
||||
|
||||
void shared_module_multiterminal_clear_secondary_terminal() {
|
||||
MP_STATE_VM(dupterm_objs[0]) = MP_OBJ_NULL;
|
||||
MP_STATE_PORT(dupterm_arr_obj) = MP_OBJ_NULL;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* 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 SHARED_MODULE_MULTITERMINAL___INIT___H
|
||||
#define SHARED_MODULE_MULTITERMINAL___INIT___H
|
||||
|
||||
mp_obj_t shared_module_multiterminal_get_secondary_terminal();
|
||||
void shared_module_multiterminal_set_secondary_terminal(mp_obj_t secondary_terminal);
|
||||
void shared_module_multiterminal_clear_secondary_terminal();
|
||||
|
||||
#endif // SHARED_MODULE_MULTITERMINAL___INIT___H
|
Loading…
Reference in New Issue