From b227b79dec1e2c24c067acae36c992ea8b26a50c Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Sat, 10 Oct 2020 20:24:19 +0200 Subject: [PATCH 01/78] Fix #3504: Don't use time module in pew.tick() The time.sleep() and time.monotonic() functions break the timer interrupt on which PewPew10 display relies, so we can't use them anymore. Instead I'm adding a time-keeping function to the display code itself, which then can be used in pew.tick() internally. --- ports/atmel-samd/common-hal/_pew/PewPew.c | 7 +++++++ ports/atmel-samd/common-hal/_pew/PewPew.h | 1 + shared-bindings/_pew/__init__.c | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/ports/atmel-samd/common-hal/_pew/PewPew.c b/ports/atmel-samd/common-hal/_pew/PewPew.c index cfdfe75d8d..fa015e7dfa 100644 --- a/ports/atmel-samd/common-hal/_pew/PewPew.c +++ b/ports/atmel-samd/common-hal/_pew/PewPew.c @@ -40,6 +40,7 @@ static uint8_t pewpew_tc_index = 0xff; +static volatile uint16_t pewpew_ticks = 0; void pewpew_interrupt_handler(uint8_t index) { @@ -52,6 +53,7 @@ void pewpew_interrupt_handler(uint8_t index) { } pew_tick(); + ++pewpew_ticks; // Clear the interrupt bit. tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0; @@ -123,3 +125,8 @@ void pew_reset(void) { } MP_STATE_VM(pew_singleton) = NULL; } + +uint16_t pew_get_ticks() { + return pewpew_ticks; +} + diff --git a/ports/atmel-samd/common-hal/_pew/PewPew.h b/ports/atmel-samd/common-hal/_pew/PewPew.h index da1cae0a2c..a9c3b6626c 100644 --- a/ports/atmel-samd/common-hal/_pew/PewPew.h +++ b/ports/atmel-samd/common-hal/_pew/PewPew.h @@ -44,5 +44,6 @@ typedef struct { void pew_init(void); void pewpew_interrupt_handler(uint8_t index); void pew_reset(void); +uint16_t pew_get_ticks(void); #endif // MICROPY_INCLUDED_PEW_PEWPEW_H diff --git a/shared-bindings/_pew/__init__.c b/shared-bindings/_pew/__init__.c index 498beaf1c9..912d267c4c 100644 --- a/shared-bindings/_pew/__init__.c +++ b/shared-bindings/_pew/__init__.c @@ -29,6 +29,7 @@ #include "PewPew.h" #include "common-hal/_pew/PewPew.h" + STATIC mp_obj_t get_pressed(void) { pew_obj_t *pew = MP_STATE_VM(pew_singleton); if (!pew) { @@ -41,12 +42,19 @@ STATIC mp_obj_t get_pressed(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed); +STATIC mp_obj_t get_ticks(void) { + return mp_obj_new_int(pew_get_ticks()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_ticks_obj, get_ticks); + + //| """LED matrix driver""" //| STATIC const mp_rom_map_elem_t pew_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pew) }, { MP_OBJ_NEW_QSTR(MP_QSTR_PewPew), MP_ROM_PTR(&pewpew_type)}, { MP_OBJ_NEW_QSTR(MP_QSTR_get_pressed), MP_ROM_PTR(&get_pressed_obj)}, + { MP_OBJ_NEW_QSTR(MP_QSTR_get_ticks), MP_ROM_PTR(&get_ticks_obj)}, }; STATIC MP_DEFINE_CONST_DICT(pew_module_globals, pew_module_globals_table); From 3f6ca7bd323cdb288c720e4d17a599ec7310fd4e Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Sat, 10 Oct 2020 23:59:44 +0200 Subject: [PATCH 02/78] Make end-of-line-fixer happy --- ports/atmel-samd/common-hal/_pew/PewPew.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/atmel-samd/common-hal/_pew/PewPew.c b/ports/atmel-samd/common-hal/_pew/PewPew.c index fa015e7dfa..1e7561ac8e 100644 --- a/ports/atmel-samd/common-hal/_pew/PewPew.c +++ b/ports/atmel-samd/common-hal/_pew/PewPew.c @@ -129,4 +129,3 @@ void pew_reset(void) { uint16_t pew_get_ticks() { return pewpew_ticks; } - From 84d7a0da9dff287d6696bcea5c1517db916d5933 Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Wed, 20 Jan 2021 20:24:42 -0600 Subject: [PATCH 03/78] Initial steps, mostly via clone and modify. --- tools/gen_usb_descriptor.py | 47 +++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 672f09c889..5ab4d6be1d 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -2,6 +2,21 @@ # # SPDX-License-Identifier: MIT +def fix_note(note): + index = note.rfind(" object at") + if index >= 0: + note = note[:index] + ">" + return note + +def fix_notes(notes): + count = len(notes) + index = 0 + while index < count: + notes[index] = fix_note(notes[index]) + index += 1 + + return notes + import argparse import os @@ -13,7 +28,7 @@ from adafruit_usb_descriptor import audio, audio10, cdc, hid, midi, msc, standar import hid_report_descriptors DEFAULT_INTERFACE_NAME = 'CircuitPython' -ALL_DEVICES='CDC,MSC,AUDIO,HID' +ALL_DEVICES='CDC,MSC,AUDIO,HID,VENDOR' ALL_DEVICES_SET=frozenset(ALL_DEVICES.split(',')) DEFAULT_DEVICES='CDC,MSC,AUDIO,HID' @@ -62,6 +77,10 @@ parser.add_argument('--midi_ep_num_out', type=int, default=0, help='endpoint number of MIDI OUT') parser.add_argument('--midi_ep_num_in', type=int, default=0, help='endpoint number of MIDI IN') +parser.add_argument('--vendor_ep_num_out', type=int, default=0, + help='endpoint number of VENDOR OUT') +parser.add_argument('--vendor_ep_num_in', type=int, default=0, + help='endpoint number of VENDOR IN') parser.add_argument('--max_ep', type=int, default=0, help='total number of endpoints available') parser.add_argument('--output_c_file', type=argparse.FileType('w', encoding='UTF-8'), required=True) @@ -89,21 +108,27 @@ if not args.renumber_endpoints: if 'MSC' in args.devices: if args.msc_ep_num_out == 0: raise ValueError("MSC endpoint OUT number must not be 0") - elif args.msc_ep_num_in == 0: + elif args.msc_ep_num_in == 0: raise ValueError("MSC endpoint IN number must not be 0") if 'HID' in args.devices: if args.args.hid_ep_num_out == 0: raise ValueError("HID endpoint OUT number must not be 0") - elif args.hid_ep_num_in == 0: + elif args.hid_ep_num_in == 0: raise ValueError("HID endpoint IN number must not be 0") if 'AUDIO' in args.devices: if args.args.midi_ep_num_out == 0: raise ValueError("MIDI endpoint OUT number must not be 0") - elif args.midi_ep_num_in == 0: + elif args.midi_ep_num_in == 0: raise ValueError("MIDI endpoint IN number must not be 0") + if 'VENDOR' in args.devices: + if args.vendor_ep_num_out == 0: + raise ValueError("VENDOR endpoint OUT number must not be 0") + elif args.vendor_ep_num_in == 0: + raise ValueError("VENDOR endpoint IN number must not be 0") + class StringIndex: """Assign a monotonically increasing index to each unique string. Start with 0.""" string_to_index = {} @@ -359,6 +384,10 @@ audio_control_interface = standard.InterfaceDescriptor( # Audio streaming interfaces must occur before MIDI ones. audio_interfaces = [audio_control_interface] + cs_ac_interface.audio_streaming_interfaces + cs_ac_interface.midi_streaming_interfaces +# TODO New code goes here to create vendor objects + +vendor_interfaces = [] # TODO Fix this! + interfaces_to_join = [] if 'CDC' in args.devices: @@ -373,6 +402,9 @@ if 'HID' in args.devices: if 'AUDIO' in args.devices: interfaces_to_join.append(audio_interfaces) +if 'VENDOR' in args.devices: + interfaces_to_join.append(vendor_interfaces) + # util.join_interfaces() will renumber the endpoints to make them unique across descriptors, # and renumber the interfaces in order. But we still need to fix up certain # interface cross-references. @@ -425,6 +457,9 @@ if 'AUDIO' in args.devices: # correct ordering. descriptor_list.append(audio_control_interface) +if 'VENDOR' in args.devices: + descriptor_list.extend(vendor_interfaces) + # Finally, build the composite descriptor. configuration = standard.ConfigurationDescriptor( @@ -479,6 +514,7 @@ for descriptor in descriptor_list: b = bytes(descriptor) notes = descriptor.notes() + notes = fix_notes(notes) # for comparision of files beteen runs i = 0 # This prints each subdescriptor on a separate line. @@ -507,6 +543,7 @@ for idx, descriptor in enumerate(string_descriptors): b = bytes(descriptor) notes = descriptor.notes() + notes = fix_notes(notes) # for comparision of files beteen runs i = 0 # This prints each subdescriptor on a separate line. @@ -550,7 +587,7 @@ c_file.write("\n") hid_descriptor_length = len(bytes(combined_hid_report_descriptor)) -# Now we values we need for the .h file. +# Now the values we need for the .h file. h_file.write("""\ #ifndef MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H #define MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H From 9ce33a5771cd6061e81aeaf2b1c4361490c36b08 Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Fri, 22 Jan 2021 08:16:10 -0600 Subject: [PATCH 04/78] Now generates the WebUSB URL Descriptor. Still need to generate the Vendor Descriptors. --- tools/gen_usb_descriptor.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 5ab4d6be1d..0f936597f4 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -37,6 +37,8 @@ ALL_HID_DEVICES_SET=frozenset(ALL_HID_DEVICES.split(',')) # Digitizer works on Linux but conflicts with mouse, so omit it. DEFAULT_HID_DEVICES='KEYBOARD,MOUSE,CONSUMER,GAMEPAD' +DEFAULT_WEBUSB_URL = 'www.circuitpython.org' # In the future, this may become a specific landing page + parser = argparse.ArgumentParser(description='Generate USB descriptors.') parser.add_argument('--highspeed', default=False, action='store_true', help='descriptor for highspeed device') @@ -77,6 +79,9 @@ parser.add_argument('--midi_ep_num_out', type=int, default=0, help='endpoint number of MIDI OUT') parser.add_argument('--midi_ep_num_in', type=int, default=0, help='endpoint number of MIDI IN') +parser.add_argument('--webusb_url', type=str, + help='The URL to include in the WebUSB URL Descriptor', + default=DEFAULT_WEBUSB_URL) parser.add_argument('--vendor_ep_num_out', type=int, default=0, help='endpoint number of VENDOR OUT') parser.add_argument('--vendor_ep_num_in', type=int, default=0, @@ -623,7 +628,17 @@ extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}]; msc_vendor=args.manufacturer[:8], msc_product=args.product[:16])) +if 'VENDOR' in args.devices: + h_file.write("""\ +extern const tusb_desc_webusb_url_t desc_webusb_url; + +""") + +h_file.write("""\ +#endif // MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H +""") # Write out the report descriptor and info + c_file.write("""\ const uint8_t hid_report_descriptor[{HID_DESCRIPTOR_LENGTH}] = {{ """.format(HID_DESCRIPTOR_LENGTH=hid_descriptor_length)) @@ -692,6 +707,16 @@ c_file.write("""\ }; """) -h_file.write("""\ -#endif // MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H -""") +if 'VENDOR' in args.devices: + # Mimic what the tinyusb webusb demo does + c_file.write(""" +#define URL "{webusb_url}" + +const tusb_desc_webusb_url_t desc_webusb_url = +{{ + .bLength = 3 + sizeof(URL) - 1, + .bDescriptorType = 3, // WEBUSB URL type + .bScheme = 1, // 0: http, 1: https, 255: "" + .url = URL +}}; +""".format(webusb_url=args.webusb_url)) From 9f34ec78c44b6037e2f05bf4ebb44130b35e1425 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 15 Jan 2021 12:01:15 -0500 Subject: [PATCH 05/78] Separate Socket and SSLSocket, add LWIP connect --- locale/circuitpython.pot | 24 +- ports/esp32s2/common-hal/socketpool/Socket.c | 380 +++++++----------- ports/esp32s2/common-hal/socketpool/Socket.h | 2 - .../common-hal/socketpool/SocketPool.c | 22 +- ports/esp32s2/common-hal/ssl/SSLContext.c | 24 +- ports/esp32s2/common-hal/ssl/SSLSocket.c | 169 ++++++++ ports/esp32s2/common-hal/ssl/SSLSocket.h | 44 ++ py/circuitpy_defns.mk | 1 + shared-bindings/socketpool/Socket.c | 207 +++++----- shared-bindings/socketpool/Socket.h | 23 +- shared-bindings/socketpool/SocketPool.c | 3 +- shared-bindings/ssl/SSLContext.h | 3 +- shared-bindings/ssl/SSLSocket.c | 320 +++++++++++++++ shared-bindings/ssl/SSLSocket.h | 46 +++ 14 files changed, 886 insertions(+), 382 deletions(-) create mode 100644 ports/esp32s2/common-hal/ssl/SSLSocket.c create mode 100644 ports/esp32s2/common-hal/ssl/SSLSocket.h create mode 100644 shared-bindings/ssl/SSLSocket.c create mode 100644 shared-bindings/ssl/SSLSocket.h diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 3ffc31cc6c..c88a32a051 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -622,6 +622,10 @@ msgstr "" msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "" @@ -854,7 +858,7 @@ msgstr "" msgid "Error in regex" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -912,7 +916,7 @@ msgstr "" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1248,7 +1252,7 @@ msgstr "" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1256,10 +1260,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "" @@ -1276,10 +1276,6 @@ msgstr "" msgid "Invalid word/bit length" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "" @@ -1562,7 +1558,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2027,7 +2023,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2324,7 +2320,7 @@ msgstr "" msgid "buffer too small" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index 69ef41c6ec..4cbf4cff26 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -38,7 +38,7 @@ #include "components/lwip/lwip/src/include/lwip/sys.h" #include "components/lwip/lwip/src/include/lwip/netdb.h" -STATIC socketpool_socket_obj_t * open_socket_handles[CONFIG_LWIP_MAX_SOCKETS]; // 4 on the wrover/wroom +STATIC socketpool_socket_obj_t * open_socket_handles[CONFIG_LWIP_MAX_SOCKETS]; void socket_reset(void) { for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_handles); i++) { @@ -47,7 +47,6 @@ void socket_reset(void) { common_hal_socketpool_socket_close(open_socket_handles[i]); open_socket_handles[i] = NULL; } else { - // accidentally got a TCP socket in here, or something. open_socket_handles[i] = NULL; } } @@ -64,59 +63,6 @@ bool register_open_socket(socketpool_socket_obj_t* self) { return false; } -STATIC void _lazy_init_LWIP(socketpool_socket_obj_t* self) { - if (self->num != -1) { - return; //safe to call on existing socket - } - if (self->tls != NULL) { - mp_raise_RuntimeError(translate("Invalid use of TLS Socket")); - } - int socknum = -1; - socknum = lwip_socket(self->family, self->type, self->ipproto); - if (socknum < 0 || !register_open_socket(self)) { - mp_raise_RuntimeError(translate("Out of sockets")); - } - self->num = socknum; - lwip_fcntl(socknum, F_SETFL, O_NONBLOCK); -} - -STATIC void _lazy_init_TLS(socketpool_socket_obj_t* self) { - if (self->type != SOCK_STREAM || self->num != -1) { - mp_raise_RuntimeError(translate("Invalid socket for TLS")); - } - esp_tls_t* tls_handle = esp_tls_init(); - if (tls_handle == NULL) { - mp_raise_espidf_MemoryError(); - } - self->tls = tls_handle; -} - -void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, mp_uint_t timeout_ms) { - self->timeout_ms = timeout_ms; -} - -bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t* self, - const char* host, size_t hostlen, uint8_t port) { - _lazy_init_LWIP(self); - - struct sockaddr_in bind_addr; - bind_addr.sin_addr.s_addr = inet_addr(host); - bind_addr.sin_family = AF_INET; - bind_addr.sin_port = htons(port); - - int opt = 1; - int err = lwip_setsockopt(self->num, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); - if (err != 0) { - mp_raise_RuntimeError(translate("Issue setting SO_REUSEADDR")); - } - int result = lwip_bind(self->num, (struct sockaddr *)&bind_addr, sizeof(bind_addr)) == 0; - return result; -} - -bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t* self, int backlog) { - return lwip_listen(self->num, backlog) == 0; -} - socketpool_socket_obj_t* common_hal_socketpool_socket_accept(socketpool_socket_obj_t* self, uint8_t* ip, uint *port) { struct sockaddr_in accept_addr; @@ -125,22 +71,16 @@ socketpool_socket_obj_t* common_hal_socketpool_socket_accept(socketpool_socket_o bool timed_out = false; uint64_t start_ticks = supervisor_ticks_ms64(); - if (self->timeout_ms != (uint)-1) { - mp_printf(&mp_plat_print, "will timeout"); - } else { - mp_printf(&mp_plat_print, "won't timeout"); - } - // Allow timeouts and interrupts while (newsoc == -1 && !timed_out && !mp_hal_is_interrupted()) { - if (self->timeout_ms != (uint)-1) { + if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) { timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; } RUN_BACKGROUND_TASKS; newsoc = lwip_accept(self->num, (struct sockaddr *)&accept_addr, &socklen); - // In non-blocking mode, fail instead of looping + // In non-blocking mode, fail instead of timing out if (newsoc == -1 && self->timeout_ms == 0) { mp_raise_OSError(MP_EAGAIN); } @@ -159,8 +99,6 @@ socketpool_socket_obj_t* common_hal_socketpool_socket_accept(socketpool_socket_o socketpool_socket_obj_t *sock = m_new_obj_with_finaliser(socketpool_socket_obj_t); sock->base.type = &socketpool_socket_type; sock->num = newsoc; - sock->tls = NULL; - sock->ssl_context = NULL; sock->pool = self->pool; if (!register_open_socket(sock)) { @@ -175,183 +113,96 @@ socketpool_socket_obj_t* common_hal_socketpool_socket_accept(socketpool_socket_o } } +bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t* self, + const char* host, size_t hostlen, uint8_t port) { + struct sockaddr_in bind_addr; + bind_addr.sin_addr.s_addr = inet_addr(host); + bind_addr.sin_family = AF_INET; + bind_addr.sin_port = htons(port); + + int opt = 1; + int err = lwip_setsockopt(self->num, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); + if (err != 0) { + mp_raise_RuntimeError(translate("Cannot set socket options")); + } + int result = lwip_bind(self->num, (struct sockaddr *)&bind_addr, sizeof(bind_addr)) == 0; + return result; +} + +void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self) { + self->connected = false; + if (self->num >= 0) { + lwip_shutdown(self->num, 0); + lwip_close(self->num); + self->num = -1; + } +} + bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const char* host, mp_uint_t hostlen, mp_int_t port) { - // For simplicity we use esp_tls for all TCP connections. If it's not SSL, ssl_context will be - // NULL and should still work. This makes regular TCP connections more memory expensive but TLS - // should become more and more common. Therefore, we optimize for the TLS case. - - // Todo: move to SSL Wrapper and add lwip_connect() - _lazy_init_TLS(self); - - esp_tls_cfg_t* tls_config = NULL; - if (self->ssl_context != NULL) { - tls_config = &self->ssl_context->ssl_config; - } - int result = esp_tls_conn_new_sync(host, hostlen, port, tls_config, self->tls); - self->connected = result >= 0; - if (result < 0) { - int esp_tls_code; - int flags; - esp_err_t err = esp_tls_get_and_clear_last_error(self->tls->error_handle, &esp_tls_code, &flags); - - if (err == ESP_ERR_MBEDTLS_SSL_SETUP_FAILED) { - mp_raise_espidf_MemoryError(); - } else if (ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED) { - mp_raise_OSError_msg_varg(translate("Failed SSL handshake")); - } else { - mp_raise_OSError_msg_varg(translate("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, result); - } - } else { - // Connection successful, set the timeout on the underlying socket. We can't rely on the IDF - // to do it because the config structure is only used for TLS connections. Generally, we - // shouldn't hit this timeout because we try to only read available data. However, there is - // always a chance that we try to read something that is used internally. - int fd; - esp_tls_get_conn_sockfd(self->tls, &fd); - struct timeval tv; - tv.tv_sec = 2 * 60; // Two minutes - tv.tv_usec = 0; - setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); - setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); - } - - return self->connected; -} - -bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t* self) { - return self->connected; -} - -mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len) { - int sent = -1; - if (self->num != -1) { - // LWIP Socket - // TODO: deal with potential failure/add timeout? - sent = lwip_send(self->num, buf, len, 0); - } else if (self->tls != NULL) { - // TLS Socket - sent = esp_tls_conn_write(self->tls, buf, len); - } - - if (sent < 0) { - mp_raise_OSError(MP_ENOTCONN); - } - return sent; -} - -mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len) { - int received = 0; - bool timed_out = false; - - if (self->num != -1) { - // LWIP Socket - uint64_t start_ticks = supervisor_ticks_ms64(); - received = -1; - while (received == -1 && - !timed_out && - !mp_hal_is_interrupted()) { - if (self->timeout_ms != (uint)-1) { - timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; - } - RUN_BACKGROUND_TASKS; - received = lwip_recv(self->num, (void*) buf, len - 1, 0); - - // In non-blocking mode, fail instead of looping - if (received == -1 && self->timeout_ms == 0) { - mp_raise_OSError(MP_EAGAIN); - } - } - } else if (self->tls != NULL) { - // TLS Socket - int status = 0; - uint64_t start_ticks = supervisor_ticks_ms64(); - int sockfd; - esp_err_t err = esp_tls_get_conn_sockfd(self->tls, &sockfd); - if (err != ESP_OK) { - mp_raise_OSError(MP_EBADF); - } - while (received == 0 && - status >= 0 && - !timed_out && - !mp_hal_is_interrupted()) { - if (self->timeout_ms != (uint)-1) { - timed_out = self->timeout_ms == 0 || supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; - } - RUN_BACKGROUND_TASKS; - size_t available = esp_tls_get_bytes_avail(self->tls); - if (available == 0) { - // This reads the raw socket buffer and is used for non-TLS connections - // and between encrypted TLS blocks. - status = lwip_ioctl(sockfd, FIONREAD, &available); - } - size_t remaining = len - received; - if (available > remaining) { - available = remaining; - } - if (available > 0) { - status = esp_tls_conn_read(self->tls, (void*) buf + received, available); - if (status == 0) { - // Reading zero when something is available indicates a closed - // connection. (The available bytes could have been TLS internal.) - break; - } - if (status > 0) { - received += status; - } - } - } - } else { - // Socket does not have a valid descriptor of either type - mp_raise_OSError(MP_EBADF); - } - - if (timed_out) { - mp_raise_OSError(ETIMEDOUT); - } - return received; -} - -mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, - const char* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len) { - - _lazy_init_LWIP(self); - - // Get the IP address string const struct addrinfo hints = { .ai_family = AF_INET, .ai_socktype = SOCK_STREAM, }; - struct addrinfo *result; - int error = lwip_getaddrinfo(host, NULL, &hints, &result); - if (error != 0 || result == NULL) { - return 0; + struct addrinfo *result_i; + int error = lwip_getaddrinfo(host, NULL, &hints, &result_i); + if (error != 0 || result_i == NULL) { + mp_raise_OSError(EHOSTUNREACH); } // Set parameters struct sockaddr_in dest_addr; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-align" - dest_addr.sin_addr.s_addr = ((struct sockaddr_in *)result->ai_addr)->sin_addr.s_addr; + dest_addr.sin_addr.s_addr = ((struct sockaddr_in *)result_i->ai_addr)->sin_addr.s_addr; #pragma GCC diagnostic pop - freeaddrinfo(result); + freeaddrinfo(result_i); dest_addr.sin_family = AF_INET; dest_addr.sin_port = htons(port); - int bytes_sent = lwip_sendto(self->num, buf, len, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr)); - if (bytes_sent < 0) { - mp_raise_BrokenPipeError(); - return 0; + // Replace above with function call ----- + + // Switch to blocking mode for this one call + int opts; + opts = lwip_fcntl(self->num,F_GETFL,0); + opts = opts & (~O_NONBLOCK); + lwip_fcntl(self->num, F_SETFL, opts); + + int result = -1; + result = lwip_connect(self->num, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr_in)); + + // Switch back once complete + opts = opts | O_NONBLOCK; + lwip_fcntl(self->num, F_SETFL, opts); + + if (result) { + self->connected = true; + return true; + } else { + mp_raise_OSError(errno); } - return bytes_sent; +} + +bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t* self) { + return self->num < 0; +} + +bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t* self) { + return self->connected; +} + +mp_uint_t common_hal_socketpool_socket_get_hash(socketpool_socket_obj_t* self) { + return self->num; +} + +bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t* self, int backlog) { + return lwip_listen(self->num, backlog) == 0; } mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, uint8_t* buf, mp_uint_t len, uint8_t* ip, uint *port) { - _lazy_init_LWIP(self); - struct sockaddr_in source_addr; socklen_t socklen = sizeof(source_addr); @@ -362,7 +213,7 @@ mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* se while (received == -1 && !timed_out && !mp_hal_is_interrupted()) { - if (self->timeout_ms != (uint)-1) { + if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) { timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; } RUN_BACKGROUND_TASKS; @@ -389,24 +240,87 @@ mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* se return received; } -void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self) { - self->connected = false; - if (self->tls != NULL) { - esp_tls_conn_destroy(self->tls); - self->tls = NULL; +mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len) { + int received = 0; + bool timed_out = false; + + if (self->num != -1) { + // LWIP Socket + uint64_t start_ticks = supervisor_ticks_ms64(); + received = -1; + while (received == -1 && + !timed_out && + !mp_hal_is_interrupted()) { + if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) { + timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; + } + RUN_BACKGROUND_TASKS; + received = lwip_recv(self->num, (void*) buf, len - 1, 0); + + // In non-blocking mode, fail instead of looping + if (received == -1 && self->timeout_ms == 0) { + mp_raise_OSError(MP_EAGAIN); + } + } + } else { + mp_raise_OSError(MP_EBADF); } - if (self->num >= 0) { - lwip_shutdown(self->num, 0); - lwip_close(self->num); - self->num = -1; + + if (timed_out) { + mp_raise_OSError(ETIMEDOUT); } + return received; } -bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t* self) { - return self->tls == NULL && self->num < 0; +mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len) { + int sent = -1; + if (self->num != -1) { + // LWIP Socket + // TODO: deal with potential failure/add timeout? + sent = lwip_send(self->num, buf, len, 0); + } else { + mp_raise_OSError(MP_EBADF); + } + + if (sent < 0) { + mp_raise_OSError(MP_ENOTCONN); + } + return sent; } +mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, + const char* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len) { -mp_uint_t common_hal_socketpool_socket_get_hash(socketpool_socket_obj_t* self) { - return self->num; + // Set parameters + const struct addrinfo hints = { + .ai_family = AF_INET, + .ai_socktype = SOCK_STREAM, + }; + struct addrinfo *result_i; + int error = lwip_getaddrinfo(host, NULL, &hints, &result_i); + if (error != 0 || result_i == NULL) { + mp_raise_OSError(EHOSTUNREACH); + } + + // Set parameters + struct sockaddr_in dest_addr; + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" + dest_addr.sin_addr.s_addr = ((struct sockaddr_in *)result_i->ai_addr)->sin_addr.s_addr; + #pragma GCC diagnostic pop + freeaddrinfo(result_i); + + dest_addr.sin_family = AF_INET; + dest_addr.sin_port = htons(port); + + int bytes_sent = lwip_sendto(self->num, buf, len, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr)); + if (bytes_sent < 0) { + mp_raise_BrokenPipeError(); + return 0; + } + return bytes_sent; +} + +void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, mp_uint_t timeout_ms) { + self->timeout_ms = timeout_ms; } diff --git a/ports/esp32s2/common-hal/socketpool/Socket.h b/ports/esp32s2/common-hal/socketpool/Socket.h index 4e6cfa5ef6..b86f5597c4 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.h +++ b/ports/esp32s2/common-hal/socketpool/Socket.h @@ -41,8 +41,6 @@ typedef struct { int family; int ipproto; bool connected; - esp_tls_t* tls; - ssl_sslcontext_obj_t* ssl_context; socketpool_socketpool_obj_t* pool; mp_uint_t timeout_ms; } socketpool_socket_obj_t; diff --git a/ports/esp32s2/common-hal/socketpool/SocketPool.c b/ports/esp32s2/common-hal/socketpool/SocketPool.c index 5821728ce5..fbd6dca7af 100644 --- a/ports/esp32s2/common-hal/socketpool/SocketPool.c +++ b/ports/esp32s2/common-hal/socketpool/SocketPool.c @@ -25,6 +25,7 @@ */ #include "shared-bindings/socketpool/SocketPool.h" +#include "common-hal/socketpool/Socket.h" #include "py/runtime.h" #include "shared-bindings/wifi/__init__.h" @@ -65,22 +66,23 @@ socketpool_socket_obj_t* common_hal_socketpool_socket(socketpool_socketpool_obj_ mp_raise_NotImplementedError(translate("Only IPv4 sockets supported")); } - // Consider LWIP and MbedTLS "variant" sockets to be incompatible (for now) - // The variant of the socket is determined by whether the socket is wrapped - // by SSL. If no TLS handle is set in sslcontext_wrap_socket, the first call - // of bind() or connect() will create a LWIP socket with a corresponding - // socketnum. - // TODO: move MbedTLS to its own duplicate Socket or Server API, maybe? socketpool_socket_obj_t *sock = m_new_obj_with_finaliser(socketpool_socket_obj_t); sock->base.type = &socketpool_socket_type; - sock->num = -1; sock->type = socket_type; sock->family = addr_family; sock->ipproto = ipproto; - - sock->tls = NULL; - sock->ssl_context = NULL; sock->pool = self; + sock->timeout_ms = (uint)-1; + + // Create LWIP socket + int socknum = -1; + socknum = lwip_socket(sock->family, sock->type, sock->ipproto); + if (socknum < 0 || !register_open_socket(sock)) { + mp_raise_RuntimeError(translate("Out of sockets")); + } + sock->num = socknum; + // Sockets should be nonblocking in most cases + lwip_fcntl(socknum, F_SETFL, O_NONBLOCK); return sock; } diff --git a/ports/esp32s2/common-hal/ssl/SSLContext.c b/ports/esp32s2/common-hal/ssl/SSLContext.c index e24fd338b6..c0179399de 100644 --- a/ports/esp32s2/common-hal/ssl/SSLContext.c +++ b/ports/esp32s2/common-hal/ssl/SSLContext.c @@ -25,6 +25,9 @@ */ #include "shared-bindings/ssl/SSLContext.h" +#include "shared-bindings/ssl/SSLSocket.h" + +#include "bindings/espidf/__init__.h" #include "py/runtime.h" @@ -32,10 +35,25 @@ void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t* self) { } -socketpool_socket_obj_t* common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t* self, +ssl_sslsocket_obj_t* common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t* self, socketpool_socket_obj_t* socket, bool server_side, const char* server_hostname) { - socket->ssl_context = self; + ssl_sslsocket_obj_t *sock = m_new_obj_with_finaliser(ssl_sslsocket_obj_t); + sock->base.type = &ssl_sslsocket_type; + sock->ssl_context = self; + sock->sock = socket; + + if (socket->type != SOCK_STREAM || socket->num != -1) { + mp_raise_RuntimeError(translate("Invalid socket for TLS")); + } + esp_tls_t* tls_handle = esp_tls_init(); + if (tls_handle == NULL) { + mp_raise_espidf_MemoryError(); + } + sock->tls = tls_handle; + + // TODO: do something with the original socket? Don't call a close on the internal LWIP. + // Should we store server hostname on the socket in case connect is called with an ip? - return socket; + return sock; } diff --git a/ports/esp32s2/common-hal/ssl/SSLSocket.c b/ports/esp32s2/common-hal/ssl/SSLSocket.c new file mode 100644 index 0000000000..d8e48c3d59 --- /dev/null +++ b/ports/esp32s2/common-hal/ssl/SSLSocket.c @@ -0,0 +1,169 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Lucian Copeland 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/ssl/SSLSocket.h" +#include "shared-bindings/socketpool/Socket.h" +#include "shared-bindings/ssl/SSLContext.h" + +#include "bindings/espidf/__init__.h" +#include "lib/utils/interrupt_char.h" +#include "py/mperrno.h" +#include "py/runtime.h" +#include "supervisor/shared/tick.h" + +void common_hal_ssl_sslsocket_settimeout(ssl_sslsocket_obj_t* self, mp_uint_t timeout_ms) { + self->sock->timeout_ms = timeout_ms; +} + +ssl_sslsocket_obj_t* common_hal_ssl_sslsocket_accept(ssl_sslsocket_obj_t* self, + uint8_t* ip, uint *port) { + socketpool_socket_obj_t * sock = common_hal_socketpool_socket_accept(self->sock, ip, port); + ssl_sslsocket_obj_t * sslsock = common_hal_ssl_sslcontext_wrap_socket(self->ssl_context, sock, false, NULL); + return sslsock; +} + +bool common_hal_ssl_sslsocket_bind(ssl_sslsocket_obj_t* self, + const char* host, size_t hostlen, uint8_t port) { + return common_hal_socketpool_socket_bind(self->sock, host, hostlen, port); +} + +void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t* self) { + self->sock->connected = false; + esp_tls_conn_destroy(self->tls); + self->tls = NULL; +} + +bool common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t* self, + const char* host, mp_uint_t hostlen, mp_int_t port) { + esp_tls_cfg_t* tls_config = NULL; + tls_config = &self->ssl_context->ssl_config; + int result = esp_tls_conn_new_sync(host, hostlen, port, tls_config, self->tls); + self->sock->connected = result >= 0; + if (result < 0) { + int esp_tls_code; + int flags; + esp_err_t err = esp_tls_get_and_clear_last_error(self->tls->error_handle, &esp_tls_code, &flags); + + if (err == ESP_ERR_MBEDTLS_SSL_SETUP_FAILED) { + mp_raise_espidf_MemoryError(); + } else if (ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED) { + mp_raise_OSError_msg_varg(translate("Failed SSL handshake")); + } else { + mp_raise_OSError_msg_varg(translate("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, result); + } + } else { + // Connection successful, set the timeout on the underlying socket. We can't rely on the IDF + // to do it because the config structure is only used for TLS connections. Generally, we + // shouldn't hit this timeout because we try to only read available data. However, there is + // always a chance that we try to read something that is used internally. + int fd; + esp_tls_get_conn_sockfd(self->tls, &fd); + struct timeval tv; + tv.tv_sec = 2 * 60; // Two minutes + tv.tv_usec = 0; + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); + } + + return self->sock->connected; +} + +bool common_hal_ssl_sslsocket_get_closed(ssl_sslsocket_obj_t* self) { + return self->tls == NULL && self->sock->num < 0; +} + +bool common_hal_ssl_sslsocket_get_connected(ssl_sslsocket_obj_t* self) { + return self->sock->connected; +} + +mp_uint_t common_hal_ssl_sslsocket_get_hash(ssl_sslsocket_obj_t* self) { + return self->sock->num; +} + +bool common_hal_ssl_sslsocket_listen(ssl_sslsocket_obj_t* self, int backlog) { + return common_hal_socketpool_socket_listen(self->sock, backlog); +} + +mp_uint_t common_hal_ssl_sslsocket_recv_into(ssl_sslsocket_obj_t* self, const uint8_t* buf, mp_uint_t len) { + int received = 0; + bool timed_out = false; + int status = 0; + uint64_t start_ticks = supervisor_ticks_ms64(); + int sockfd; + esp_err_t err = esp_tls_get_conn_sockfd(self->tls, &sockfd); + if (err != ESP_OK) { + mp_raise_OSError(MP_EBADF); + } + while (received == 0 && + status >= 0 && + !timed_out && + !mp_hal_is_interrupted()) { + if (self->sock->timeout_ms != (uint)-1 && self->sock->timeout_ms != 0) { + timed_out = self->sock->timeout_ms == 0 || supervisor_ticks_ms64() - start_ticks >= self->sock->timeout_ms; + } + RUN_BACKGROUND_TASKS; + size_t available = esp_tls_get_bytes_avail(self->tls); + if (available == 0) { + // This reads the raw socket buffer and is used for non-TLS connections + // and between encrypted TLS blocks. + status = lwip_ioctl(sockfd, FIONREAD, &available); + } + size_t remaining = len - received; + if (available > remaining) { + available = remaining; + } + if (available > 0) { + status = esp_tls_conn_read(self->tls, (void*) buf + received, available); + if (status == 0) { + // Reading zero when something is available indicates a closed + // connection. (The available bytes could have been TLS internal.) + break; + } + if (status > 0) { + received += status; + } + } + // In non-blocking mode, fail instead of timing out + if (received==0 && self->sock->timeout_ms == 0) { + mp_raise_OSError(MP_EAGAIN); + } + } + + if (timed_out) { + mp_raise_OSError(ETIMEDOUT); + } + return received; +} + +mp_uint_t common_hal_ssl_sslsocket_send(ssl_sslsocket_obj_t* self, const uint8_t* buf, mp_uint_t len) { + int sent = -1; + sent = esp_tls_conn_write(self->tls, buf, len); + + if (sent < 0) { + mp_raise_OSError(MP_ENOTCONN); + } + return sent; +} diff --git a/ports/esp32s2/common-hal/ssl/SSLSocket.h b/ports/esp32s2/common-hal/ssl/SSLSocket.h new file mode 100644 index 0000000000..e9e5bff062 --- /dev/null +++ b/ports/esp32s2/common-hal/ssl/SSLSocket.h @@ -0,0 +1,44 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Lucian Copeland 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 MICROPY_INCLUDED_ESP32S2_COMMON_HAL_SSL_SSLSOCKET_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_SSL_SSLSOCKET_H + +#include "py/obj.h" + +#include "common-hal/ssl/SSLContext.h" +#include "common-hal/socketpool/Socket.h" + +#include "components/esp-tls/esp_tls.h" + +typedef struct { + mp_obj_base_t base; + socketpool_socket_obj_t * sock; + esp_tls_t* tls; + ssl_sslcontext_obj_t* ssl_context; +} ssl_sslsocket_obj_t; + +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_SSL_SSLSOCKET_H diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 3ce7c01173..b208178f37 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -388,6 +388,7 @@ SRC_COMMON_HAL_ALL = \ socketpool/Socket.c \ ssl/__init__.c \ ssl/SSLContext.c \ + ssl/SSLSocket.c \ supervisor/Runtime.c \ supervisor/__init__.c \ watchdog/WatchDogMode.c \ diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index 0074173405..f169d6acac 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -3,8 +3,8 @@ * * The MIT License (MIT) * - * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George - * 2018 Nick Moore for Adafruit Industries + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2021 Lucian Copeland 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 @@ -64,6 +64,25 @@ STATIC mp_obj_t socketpool_socket___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket___exit___obj, 4, 4, socketpool_socket___exit__); +//| def accept(self) -> Tuple[Socket, Tuple[str, int]]: +//| """Accept a connection on a listening socket of type SOCK_STREAM, +//| creating a new socket of type SOCK_STREAM. +//| Returns a tuple of (new_socket, remote_address)""" +//| +STATIC mp_obj_t socketpool_socket_accept(mp_obj_t self_in) { + socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); + uint8_t ip[4]; + uint port; + + socketpool_socket_obj_t * sock = common_hal_socketpool_socket_accept(self, ip, &port); + + mp_obj_t tuple_contents[2]; + tuple_contents[0] = MP_OBJ_FROM_PTR(sock); + tuple_contents[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); + return mp_obj_new_tuple(2, tuple_contents); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(socketpool_socket_accept_obj, socketpool_socket_accept); + //| def bind(self, address: Tuple[str, int]) -> None: //| """Bind a socket to an address //| @@ -89,41 +108,6 @@ STATIC mp_obj_t socketpool_socket_bind(mp_obj_t self_in, mp_obj_t addr_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_bind_obj, socketpool_socket_bind); -//| def listen(self, backlog: int) -> None: -//| """Set socket to listen for incoming connections -//| -//| :param ~int backlog: length of backlog queue for waiting connetions""" -//| ... -//| -STATIC mp_obj_t socketpool_socket_listen(mp_obj_t self_in, mp_obj_t backlog_in) { - socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); - - int backlog = mp_obj_get_int(backlog_in); - - common_hal_socketpool_socket_listen(self, backlog); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_listen_obj, socketpool_socket_listen); - -//| def accept(self) -> Tuple[Socket, Tuple[str, int]]: -//| """Accept a connection on a listening socket of type SOCK_STREAM, -//| creating a new socket of type SOCK_STREAM. -//| Returns a tuple of (new_socket, remote_address)""" -//| -STATIC mp_obj_t socketpool_socket_accept(mp_obj_t self_in) { - socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); - uint8_t ip[4]; - uint port; - - socketpool_socket_obj_t * sock = common_hal_socketpool_socket_accept(self, ip, &port); - - mp_obj_t tuple_contents[2]; - tuple_contents[0] = MP_OBJ_FROM_PTR(sock); - tuple_contents[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); - return mp_obj_new_tuple(2, tuple_contents); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(socketpool_socket_accept_obj, socketpool_socket_accept); - //| def close(self) -> None: //| """Closes this Socket and makes its resources available to its SocketPool.""" //| @@ -159,31 +143,47 @@ STATIC mp_obj_t socketpool_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_connect_obj, socketpool_socket_connect); -//| def send(self, bytes: ReadableBuffer) -> int: -//| """Send some bytes to the connected remote address. -//| Suits sockets of type SOCK_STREAM +//| def listen(self, backlog: int) -> None: +//| """Set socket to listen for incoming connections //| -//| :param ~bytes bytes: some bytes to send""" +//| :param ~int backlog: length of backlog queue for waiting connetions""" //| ... //| -STATIC mp_obj_t socketpool_socket_send(mp_obj_t self_in, mp_obj_t buf_in) { +STATIC mp_obj_t socketpool_socket_listen(mp_obj_t self_in, mp_obj_t backlog_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); - if (common_hal_socketpool_socket_get_closed(self)) { - // Bad file number. - mp_raise_OSError(MP_EBADF); - } - if (!common_hal_socketpool_socket_get_connected(self)) { - mp_raise_BrokenPipeError(); - } - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); - mp_int_t ret = common_hal_socketpool_socket_send(self, bufinfo.buf, bufinfo.len); - if (ret == -1) { - mp_raise_BrokenPipeError(); - } - return mp_obj_new_int_from_uint(ret); + + int backlog = mp_obj_get_int(backlog_in); + + common_hal_socketpool_socket_listen(self, backlog); + return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_send_obj, socketpool_socket_send); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_listen_obj, socketpool_socket_listen); + +//| def recvfrom_into(self, buffer: WriteableBuffer) -> Tuple[int, Tuple[str, int]]: +//| """Reads some bytes from a remote address. +//| +//| Returns a tuple containing +//| * the number of bytes received into the given buffer +//| * a remote_address, which is a tuple of ip address and port number +//| +//| :param object buffer: buffer to read into""" +//| ... +//| +STATIC mp_obj_t socketpool_socket_recvfrom_into(mp_obj_t self_in, mp_obj_t data_in) { + socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data_in, &bufinfo, MP_BUFFER_WRITE); + + byte ip[4]; + mp_uint_t port; + mp_int_t ret = common_hal_socketpool_socket_recvfrom_into(self, + (byte*)bufinfo.buf, bufinfo.len, ip, &port); + mp_obj_t tuple_contents[2]; + tuple_contents[0] = mp_obj_new_int_from_uint(ret); + tuple_contents[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); + return mp_obj_new_tuple(2, tuple_contents); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_recvfrom_into_obj, socketpool_socket_recvfrom_into); //| def recv_into(self, buffer: WriteableBuffer, bufsize: int) -> int: //| """Reads some bytes from the connected remote address, writing @@ -199,7 +199,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_send_obj, socketpool_socket_s //| :param int bufsize: optionally, a maximum number of bytes to read.""" //| ... //| - STATIC mp_obj_t socketpool_socket_recv_into(size_t n_args, const mp_obj_t *args) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(args[0]); if (common_hal_socketpool_socket_get_closed(self)) { @@ -232,6 +231,32 @@ STATIC mp_obj_t socketpool_socket_recv_into(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket_recv_into_obj, 2, 3, socketpool_socket_recv_into); +//| def send(self, bytes: ReadableBuffer) -> int: +//| """Send some bytes to the connected remote address. +//| Suits sockets of type SOCK_STREAM +//| +//| :param ~bytes bytes: some bytes to send""" +//| ... +//| +STATIC mp_obj_t socketpool_socket_send(mp_obj_t self_in, mp_obj_t buf_in) { + socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (common_hal_socketpool_socket_get_closed(self)) { + // Bad file number. + mp_raise_OSError(MP_EBADF); + } + if (!common_hal_socketpool_socket_get_connected(self)) { + mp_raise_BrokenPipeError(); + } + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); + mp_int_t ret = common_hal_socketpool_socket_send(self, bufinfo.buf, bufinfo.len); + if (ret == -1) { + mp_raise_BrokenPipeError(); + } + return mp_obj_new_int_from_uint(ret); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_send_obj, socketpool_socket_send); + //| def sendto(self, bytes: ReadableBuffer, address: Tuple[str, int]) -> int: //| """Send some bytes to a specific address. //| Suits sockets of type SOCK_DGRAM @@ -240,7 +265,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket_recv_into_obj, 2, 3 //| :param ~tuple address: tuple of (remote_address, remote_port)""" //| ... //| - STATIC mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -264,37 +288,28 @@ STATIC mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_ } STATIC MP_DEFINE_CONST_FUN_OBJ_3(socketpool_socket_sendto_obj, socketpool_socket_sendto); -//| def recvfrom_into(self, buffer: WriteableBuffer) -> Tuple[int, Tuple[str, int]]: -//| """Reads some bytes from a remote address. +//| def setblocking(self, flag: bool) -> Optional[int]: +//| """Set the blocking behaviour of this socket. //| -//| Returns a tuple containing -//| * the number of bytes received into the given buffer -//| * a remote_address, which is a tuple of ip address and port number -//| -//| :param object buffer: buffer to read into""" +//| :param ~bool flag: False means non-blocking, True means block indefinitely.""" //| ... //| -STATIC mp_obj_t socketpool_socket_recvfrom_into(mp_obj_t self_in, mp_obj_t data_in) { +// method socket.setblocking(flag) +STATIC mp_obj_t socketpool_socket_setblocking(mp_obj_t self_in, mp_obj_t blocking) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data_in, &bufinfo, MP_BUFFER_WRITE); - - byte ip[4]; - mp_uint_t port; - mp_int_t ret = common_hal_socketpool_socket_recvfrom_into(self, - (byte*)bufinfo.buf, bufinfo.len, ip, &port); - mp_obj_t tuple_contents[2]; - tuple_contents[0] = mp_obj_new_int_from_uint(ret); - tuple_contents[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); - return mp_obj_new_tuple(2, tuple_contents); + if (mp_obj_is_true(blocking)) { + common_hal_socketpool_socket_settimeout(self, -1); + } else { + common_hal_socketpool_socket_settimeout(self, 0); + } + return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_recvfrom_into_obj, socketpool_socket_recvfrom_into); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_setblocking_obj, socketpool_socket_setblocking); // //| def setsockopt(self, level: int, optname: int, value: int) -> None: // //| """Sets socket options""" // //| ... // //| - // STATIC mp_obj_t socketpool_socket_setsockopt(size_t n_args, const mp_obj_t *args) { // // mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(args[0]); @@ -324,13 +339,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_recvfrom_into_obj, socketpool // } // STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket_setsockopt_obj, 4, 4, socketpool_socket_setsockopt); + //| def settimeout(self, value: int) -> None: //| """Set the timeout value for this socket. //| //| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely.""" //| ... //| - STATIC mp_obj_t socketpool_socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_uint_t timeout_ms; @@ -348,24 +363,6 @@ STATIC mp_obj_t socketpool_socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_ } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_settimeout_obj, socketpool_socket_settimeout); -// //| def setblocking(self, flag: bool) -> Optional[int]: -// //| """Set the blocking behaviour of this socket. -// //| -// //| :param ~bool flag: False means non-blocking, True means block indefinitely.""" -// //| ... -// //| - -// // method socket.setblocking(flag) -// STATIC mp_obj_t socketpool_socket_setblocking(mp_obj_t self_in, mp_obj_t blocking) { -// // if (mp_obj_is_true(blocking)) { -// // return socket_settimeout(self_in, mp_const_none); -// // } else { -// // return socket_settimeout(self_in, MP_OBJ_NEW_SMALL_INT(0)); -// // } -// return mp_const_none; -// } -// STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_setblocking_obj, socketpool_socket_setblocking); - //| def __hash__(self) -> int: //| """Returns a hash for the Socket.""" //| ... @@ -384,19 +381,19 @@ STATIC const mp_rom_map_elem_t socketpool_socket_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&socketpool_socket___exit___obj) }, { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&socketpool_socket_close_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&socketpool_socket_close_obj) }, - { MP_ROM_QSTR(MP_QSTR_bind), MP_ROM_PTR(&socketpool_socket_bind_obj) }, - { MP_ROM_QSTR(MP_QSTR_listen), MP_ROM_PTR(&socketpool_socket_listen_obj) }, { MP_ROM_QSTR(MP_QSTR_accept), MP_ROM_PTR(&socketpool_socket_accept_obj) }, + { MP_ROM_QSTR(MP_QSTR_bind), MP_ROM_PTR(&socketpool_socket_bind_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&socketpool_socket_close_obj) }, { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&socketpool_socket_connect_obj) }, - { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&socketpool_socket_send_obj) }, - { MP_ROM_QSTR(MP_QSTR_sendto), MP_ROM_PTR(&socketpool_socket_sendto_obj) }, + { MP_ROM_QSTR(MP_QSTR_listen), MP_ROM_PTR(&socketpool_socket_listen_obj) }, { MP_ROM_QSTR(MP_QSTR_recvfrom_into), MP_ROM_PTR(&socketpool_socket_recvfrom_into_obj) }, { MP_ROM_QSTR(MP_QSTR_recv_into), MP_ROM_PTR(&socketpool_socket_recv_into_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&socketpool_socket_send_obj) }, + { MP_ROM_QSTR(MP_QSTR_sendto), MP_ROM_PTR(&socketpool_socket_sendto_obj) }, + { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socketpool_socket_setblocking_obj) }, // { MP_ROM_QSTR(MP_QSTR_setsockopt), MP_ROM_PTR(&socketpool_socket_setsockopt_obj) }, { MP_ROM_QSTR(MP_QSTR_settimeout), MP_ROM_PTR(&socketpool_socket_settimeout_obj) }, - // { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socketpool_socket_setblocking_obj) }, }; STATIC MP_DEFINE_CONST_DICT(socketpool_socket_locals_dict, socketpool_socket_locals_dict_table); diff --git a/shared-bindings/socketpool/Socket.h b/shared-bindings/socketpool/Socket.h index b5dceb50f4..76af6e1e9b 100644 --- a/shared-bindings/socketpool/Socket.h +++ b/shared-bindings/socketpool/Socket.h @@ -31,22 +31,21 @@ extern const mp_obj_type_t socketpool_socket_type; -void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, mp_uint_t timeout_ms); - -bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t* self, const char* host, size_t hostlen, uint8_t port); -bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t* self, int backlog); socketpool_socket_obj_t * common_hal_socketpool_socket_accept(socketpool_socket_obj_t* self, uint8_t* ip, uint *port); - -bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const char* host, size_t hostlen, mp_int_t port); -mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len); -mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len); -mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, - const char* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len); -mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, - uint8_t* buf, mp_uint_t len, uint8_t* ip, uint *port); +bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t* self, const char* host, size_t hostlen, uint8_t port); void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self); +bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const char* host, size_t hostlen, mp_int_t port); bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t* self); bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t* self); mp_uint_t common_hal_socketpool_socket_get_hash(socketpool_socket_obj_t* self); +mp_uint_t common_hal_socketpool_socket_get_timeout(socketpool_socket_obj_t* self); +bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t* self, int backlog); +mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, + uint8_t* buf, mp_uint_t len, uint8_t* ip, uint *port); +mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len); +mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len); +mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, + const char* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len); +void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, mp_uint_t timeout_ms); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SOCKETPOOL_SOCKET_H diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index 8f4069faad..6ff6d5f98d 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George - * 2018 Nick Moore for Adafruit Industries + * Copyright (c) 2020 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 diff --git a/shared-bindings/ssl/SSLContext.h b/shared-bindings/ssl/SSLContext.h index f7f985af70..ad4d7e6a8c 100644 --- a/shared-bindings/ssl/SSLContext.h +++ b/shared-bindings/ssl/SSLContext.h @@ -30,12 +30,13 @@ #include "common-hal/ssl/SSLContext.h" #include "shared-bindings/socketpool/Socket.h" +#include "shared-bindings/ssl/SSLSocket.h" extern const mp_obj_type_t ssl_sslcontext_type; void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t* self); -socketpool_socket_obj_t* common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t* self, +ssl_sslsocket_obj_t* common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t* self, socketpool_socket_obj_t* sock, bool server_side, const char* server_hostname); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SSL_SSLCONTEXT_H diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c new file mode 100644 index 0000000000..154d3d1d44 --- /dev/null +++ b/shared-bindings/ssl/SSLSocket.c @@ -0,0 +1,320 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Lucian Copeland 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/ssl/SSLSocket.h" + +#include +#include + +#include "lib/utils/context_manager_helpers.h" +#include "py/objtuple.h" +#include "py/objlist.h" +#include "py/runtime.h" +#include "py/mperrno.h" + +#include "lib/netutils/netutils.h" + +//| class SSLSocket: +//| """Implements TLS security on a subset of `socketpool.socket` functions. Cannot be created +//| directly. Instead, call `context.wrap_socket` on an existing socket object. +//| +//| Provides a subset of CPython's `ssl.SSLSocket` API. It only implements the versions of +//| recv that do not allocate bytes objects.""" +//| + +//| def __enter__(self) -> Socket: +//| """No-op used by Context Managers.""" +//| ... +//| +// Provided by context manager helper. + +//| def __exit__(self) -> None: +//| """Automatically closes the Socket when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| +STATIC mp_obj_t ssl_sslsocket___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + common_hal_ssl_sslsocket_close(args[0]); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ssl_sslsocket___exit___obj, 4, 4, ssl_sslsocket___exit__); + +//| def accept(self) -> Tuple[Socket, Tuple[str, int]]: +//| """Accept a connection on a listening socket of type SOCK_STREAM, +//| creating a new socket of type SOCK_STREAM. +//| Returns a tuple of (new_socket, remote_address)""" +//| +STATIC mp_obj_t ssl_sslsocket_accept(mp_obj_t self_in) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); + uint8_t ip[4]; + uint port; + + ssl_sslsocket_obj_t * sslsock = common_hal_ssl_sslsocket_accept(self, ip, &port); + + mp_obj_t tuple_contents[2]; + tuple_contents[0] = MP_OBJ_FROM_PTR(sslsock); + tuple_contents[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); + return mp_obj_new_tuple(2, tuple_contents); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(ssl_sslsocket_accept_obj, ssl_sslsocket_accept); + +//| def bind(self, address: Tuple[str, int]) -> None: +//| """Bind a socket to an address +//| +//| :param ~tuple address: tuple of (remote_address, remote_port)""" +//| ... +//| +STATIC mp_obj_t ssl_sslsocket_bind(mp_obj_t self_in, mp_obj_t addr_in) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); + + mp_obj_t *addr_items; + mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); + + size_t hostlen; + const char* host = mp_obj_str_get_data(addr_items[0], &hostlen); + mp_int_t port = mp_obj_get_int(addr_items[1]); + + bool ok = common_hal_ssl_sslsocket_bind(self, host, hostlen, port); + if (!ok) { + mp_raise_ValueError(translate("Error: Failure to bind")); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_bind_obj, ssl_sslsocket_bind); + +//| def close(self) -> None: +//| """Closes this Socket""" +//| +STATIC mp_obj_t ssl_sslsocket_close(mp_obj_t self_in) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_ssl_sslsocket_close(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(ssl_sslsocket_close_obj, ssl_sslsocket_close); + +//| def connect(self, address: Tuple[str, int]) -> None: +//| """Connect a socket to a remote address +//| +//| :param ~tuple address: tuple of (remote_address, remote_port)""" +//| ... +//| +STATIC mp_obj_t ssl_sslsocket_connect(mp_obj_t self_in, mp_obj_t addr_in) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); + + mp_obj_t *addr_items; + mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); + + size_t hostlen; + const char* host = mp_obj_str_get_data(addr_items[0], &hostlen); + mp_int_t port = mp_obj_get_int(addr_items[1]); + + bool ok = common_hal_ssl_sslsocket_connect(self, host, hostlen, port); + if (!ok) { + mp_raise_OSError(0); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_connect_obj, ssl_sslsocket_connect); + +//| def listen(self, backlog: int) -> None: +//| """Set socket to listen for incoming connections +//| +//| :param ~int backlog: length of backlog queue for waiting connetions""" +//| ... +//| +STATIC mp_obj_t ssl_sslsocket_listen(mp_obj_t self_in, mp_obj_t backlog_in) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); + + int backlog = mp_obj_get_int(backlog_in); + + common_hal_ssl_sslsocket_listen(self, backlog); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_listen_obj, ssl_sslsocket_listen); + +//| def recv_into(self, buffer: WriteableBuffer, bufsize: int) -> int: +//| """Reads some bytes from the connected remote address, writing +//| into the provided buffer. If bufsize <= len(buffer) is given, +//| a maximum of bufsize bytes will be read into the buffer. If no +//| valid value is given for bufsize, the default is the length of +//| the given buffer. +//| +//| Suits sockets of type SOCK_STREAM +//| Returns an int of number of bytes read. +//| +//| :param bytearray buffer: buffer to receive into +//| :param int bufsize: optionally, a maximum number of bytes to read.""" +//| ... +//| +STATIC mp_obj_t ssl_sslsocket_recv_into(size_t n_args, const mp_obj_t *args) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(args[0]); + if (common_hal_ssl_sslsocket_get_closed(self)) { + // Bad file number. + mp_raise_OSError(MP_EBADF); + } + // if (!common_hal_ssl_sslsocket_get_connected(self)) { + // // not connected + // mp_raise_OSError(MP_ENOTCONN); + // } + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); + mp_int_t len = bufinfo.len; + if (n_args == 3) { + mp_int_t given_len = mp_obj_get_int(args[2]); + if (given_len > len) { + mp_raise_ValueError(translate("buffer too small for requested bytes")); + } + if (given_len > 0 && given_len < len) { + len = given_len; + } + } + + if (len == 0) { + return MP_OBJ_NEW_SMALL_INT(0); + } + + mp_int_t ret = common_hal_ssl_sslsocket_recv_into(self, (byte*)bufinfo.buf, len); + return mp_obj_new_int_from_uint(ret); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ssl_sslsocket_recv_into_obj, 2, 3, ssl_sslsocket_recv_into); + +//| def send(self, bytes: ReadableBuffer) -> int: +//| """Send some bytes to the connected remote address. +//| Suits sockets of type SOCK_STREAM +//| +//| :param ~bytes bytes: some bytes to send""" +//| ... +//| +STATIC mp_obj_t ssl_sslsocket_send(mp_obj_t self_in, mp_obj_t buf_in) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (common_hal_ssl_sslsocket_get_closed(self)) { + // Bad file number. + mp_raise_OSError(MP_EBADF); + } + if (!common_hal_ssl_sslsocket_get_connected(self)) { + mp_raise_BrokenPipeError(); + } + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); + mp_int_t ret = common_hal_ssl_sslsocket_send(self, bufinfo.buf, bufinfo.len); + if (ret == -1) { + mp_raise_BrokenPipeError(); + } + return mp_obj_new_int_from_uint(ret); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_send_obj, ssl_sslsocket_send); + +// //| def setsockopt(self, level: int, optname: int, value: int) -> None: +// //| """Sets socket options""" +// //| ... +// //| +// STATIC mp_obj_t ssl_sslsocket_setsockopt(size_t n_args, const mp_obj_t *args) { +// } +// STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ssl_sslsocket_setsockopt_obj, 4, 4, ssl_sslsocket_setsockopt); + +//| def settimeout(self, value: int) -> None: +//| """Set the timeout value for this socket. +//| +//| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely.""" +//| ... +//| +STATIC mp_obj_t ssl_sslsocket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_uint_t timeout_ms; + if (timeout_in == mp_const_none) { + timeout_ms = -1; + } else { + #if MICROPY_PY_BUILTINS_FLOAT + timeout_ms = 1000 * mp_obj_get_float(timeout_in); + #else + timeout_ms = 1000 * mp_obj_get_int(timeout_in); + #endif + } + common_hal_ssl_sslsocket_settimeout(self, timeout_ms); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_settimeout_obj, ssl_sslsocket_settimeout); + +//| def setblocking(self, flag: bool) -> Optional[int]: +//| """Set the blocking behaviour of this socket. +//| +//| :param ~bool flag: False means non-blocking, True means block indefinitely.""" +//| ... +//| +// method socket.setblocking(flag) +STATIC mp_obj_t ssl_sslsocket_setblocking(mp_obj_t self_in, mp_obj_t blocking) { + ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (mp_obj_is_true(blocking)) { + common_hal_ssl_sslsocket_settimeout(self, -1); + } else { + common_hal_ssl_sslsocket_settimeout(self, 0); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_setblocking_obj, ssl_sslsocket_setblocking); + +//| def __hash__(self) -> int: +//| """Returns a hash for the Socket.""" +//| ... +//| +STATIC mp_obj_t ssl_sslsocket_unary_op(mp_unary_op_t op, mp_obj_t self_in) { + switch (op) { + case MP_UNARY_OP_HASH: { + return MP_OBJ_NEW_SMALL_INT(common_hal_ssl_sslsocket_get_hash(MP_OBJ_TO_PTR(self_in))); + } + default: + return MP_OBJ_NULL; // op not supported + } +} + +STATIC const mp_rom_map_elem_t ssl_sslsocket_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&ssl_sslsocket___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&ssl_sslsocket_close_obj) }, + + { MP_ROM_QSTR(MP_QSTR_accept), MP_ROM_PTR(&ssl_sslsocket_accept_obj) }, + { MP_ROM_QSTR(MP_QSTR_bind), MP_ROM_PTR(&ssl_sslsocket_bind_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&ssl_sslsocket_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&ssl_sslsocket_connect_obj) }, + { MP_ROM_QSTR(MP_QSTR_listen), MP_ROM_PTR(&ssl_sslsocket_listen_obj) }, + { MP_ROM_QSTR(MP_QSTR_recv_into), MP_ROM_PTR(&ssl_sslsocket_recv_into_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&ssl_sslsocket_send_obj) }, + { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&ssl_sslsocket_setblocking_obj) }, + // { MP_ROM_QSTR(MP_QSTR_setsockopt), MP_ROM_PTR(&ssl_sslsocket_setsockopt_obj) }, + { MP_ROM_QSTR(MP_QSTR_settimeout), MP_ROM_PTR(&ssl_sslsocket_settimeout_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(ssl_sslsocket_locals_dict, ssl_sslsocket_locals_dict_table); + +const mp_obj_type_t ssl_sslsocket_type = { + { &mp_type_type }, + .name = MP_QSTR_SSLSocket, + .locals_dict = (mp_obj_dict_t*)&ssl_sslsocket_locals_dict, + .unary_op = ssl_sslsocket_unary_op, +}; diff --git a/shared-bindings/ssl/SSLSocket.h b/shared-bindings/ssl/SSLSocket.h new file mode 100644 index 0000000000..d8c589fd80 --- /dev/null +++ b/shared-bindings/ssl/SSLSocket.h @@ -0,0 +1,46 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Lucian Copeland 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 MICROPY_INCLUDED_SHARED_BINDINGS_SSL_SSLSOCKET_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_SSL_SSLSOCKET_H + +#include "common-hal/ssl/SSLSocket.h" + +extern const mp_obj_type_t ssl_sslsocket_type; + +ssl_sslsocket_obj_t * common_hal_ssl_sslsocket_accept(ssl_sslsocket_obj_t* self, uint8_t* ip, uint *port); +bool common_hal_ssl_sslsocket_bind(ssl_sslsocket_obj_t* self, const char* host, size_t hostlen, uint8_t port); +void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t* self); +bool common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t* self, const char* host, size_t hostlen, mp_int_t port); +bool common_hal_ssl_sslsocket_get_closed(ssl_sslsocket_obj_t* self); +bool common_hal_ssl_sslsocket_get_connected(ssl_sslsocket_obj_t* self); +mp_uint_t common_hal_ssl_sslsocket_get_hash(ssl_sslsocket_obj_t* self); +bool common_hal_ssl_sslsocket_listen(ssl_sslsocket_obj_t* self, int backlog); +mp_uint_t common_hal_ssl_sslsocket_recv_into(ssl_sslsocket_obj_t* self, const uint8_t* buf, mp_uint_t len); +mp_uint_t common_hal_ssl_sslsocket_send(ssl_sslsocket_obj_t* self, const uint8_t* buf, mp_uint_t len); +void common_hal_ssl_sslsocket_settimeout(ssl_sslsocket_obj_t* self, mp_uint_t timeout_ms); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_SSL_SSLSOCKET_H From fbfb7b68cce3fbcccc423c1013c0c3cabe6a89d0 Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Mon, 25 Jan 2021 20:37:58 -0600 Subject: [PATCH 06/78] Most of the code we need has been pulled in from the tinyusb webusb_serial demo. Still LOTS to do regarding descriptors. --- ports/esp32s2/Makefile | 4 +- ports/esp32s2/mpconfigport.mk | 2 + py/circuitpy_defns.mk | 3 ++ py/circuitpy_mpconfig.mk | 3 ++ supervisor/shared/serial.c | 30 ++++++++++++ supervisor/shared/usb/tusb_config.h | 1 + supervisor/shared/usb/usb.c | 76 +++++++++++++++++++++++++++++ supervisor/supervisor.mk | 18 +++++++ tools/gen_usb_descriptor.py | 53 ++++++++++++++++++-- 9 files changed, 184 insertions(+), 6 deletions(-) diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile index aac9347824..b4ff0612b3 100644 --- a/ports/esp32s2/Makefile +++ b/ports/esp32s2/Makefile @@ -164,7 +164,9 @@ LIBS += -lm endif # TinyUSB defines -CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32S2 -DCFG_TUSB_OS=OPT_OS_FREERTOS -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128 +CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32S2 -DCFG_TUSB_OS=OPT_OS_FREERTOS -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 +CFLAGS += -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128 +CFLAGS += -DCFG_TUD_VENDOR_RX_BUFSIZE=128 -DCFG_TUD_VENDOR_TX_BUFSIZE=128 ###################################### diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 562c60998c..2d324e1618 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -30,6 +30,8 @@ CIRCUITPY_ROTARYIO = 1 CIRCUITPY_NVM = 1 # We don't have enough endpoints to include MIDI. CIRCUITPY_USB_MIDI = 0 +# We have borrowed the VENDOR nomenclature from tinyusb. VENDOR AKA WEBUSB +CIRCUITPY_USB_VENDOR = 1 CIRCUITPY_WIFI = 1 CIRCUITPY_WATCHDOG ?= 1 CIRCUITPY_ESPIDF = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 21bd5b9658..5eb7992b10 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -288,6 +288,9 @@ endif ifeq ($(CIRCUITPY_USB_MIDI),1) SRC_PATTERNS += usb_midi/% endif +ifeq ($(CIRCUITPY_USB_VENDOR),1) +SRC_PATTERNS += usb_vendor/% +endif ifeq ($(CIRCUITPY_USTACK),1) SRC_PATTERNS += ustack/% endif diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index d0145a90f3..6e721e1bc8 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -270,6 +270,9 @@ CFLAGS += -DCIRCUITPY_USB_HID=$(CIRCUITPY_USB_HID) CIRCUITPY_USB_MIDI ?= 1 CFLAGS += -DCIRCUITPY_USB_MIDI=$(CIRCUITPY_USB_MIDI) +CIRCUITPY_USB_VENDOR ?= 1 +CFLAGS += -DCIRCUITPY_USB_VENDOR=$(CIRCUITPY_USB_VENDOR) + CIRCUITPY_PEW ?= 0 CFLAGS += -DCIRCUITPY_PEW=$(CIRCUITPY_PEW) diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 303f89e752..b9feb04f25 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -47,6 +47,10 @@ busio_uart_obj_t debug_uart; byte buf_array[64]; #endif +#if CIRCUITPY_USB_VENDOR +bool tud_vendor_connected(void); +#endif + void serial_early_init(void) { #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) debug_uart.base.type = &busio_uart_type; @@ -66,6 +70,12 @@ void serial_init(void) { } bool serial_connected(void) { +#if CIRCUITPY_USB_VENDOR + if (tud_vendor_connected()) { + return true; + } +#endif + #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) return true; #else @@ -74,6 +84,14 @@ bool serial_connected(void) { } char serial_read(void) { +#if CIRCUITPY_USB_VENDOR + if (tud_vendor_connected() && tud_vendor_available() > 0) { + char tiny_buffer; + tud_vendor_read(&tiny_buffer, 1); + return tiny_buffer; + } +#endif + #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) if (tud_cdc_connected() && tud_cdc_available() > 0) { return (char) tud_cdc_read_char(); @@ -88,6 +106,12 @@ char serial_read(void) { } bool serial_bytes_available(void) { +#if CIRCUITPY_USB_VENDOR + if (tud_vendor_connected() && tud_vendor_available() > 0) { + return true; + } +#endif + #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) return common_hal_busio_uart_rx_characters_available(&debug_uart) || (tud_cdc_available() > 0); #else @@ -104,6 +128,12 @@ void serial_write_substring(const char* text, uint32_t length) { common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t*) text, length, &errcode); #endif +#if CIRCUITPY_USB_VENDOR + if (tud_vendor_connected()) { + tud_vendor_write(text, length); + } +#endif + uint32_t count = 0; while (count < length && tud_cdc_connected()) { count += tud_cdc_write(text + count, length - count); diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h index 15d9fabafe..d3a35f5374 100644 --- a/supervisor/shared/usb/tusb_config.h +++ b/supervisor/shared/usb/tusb_config.h @@ -68,6 +68,7 @@ #define CFG_TUD_MSC 1 #define CFG_TUD_HID CIRCUITPY_USB_HID #define CFG_TUD_MIDI CIRCUITPY_USB_MIDI +#define CFG_TUD_VENDOR CIRCUITPY_USB_VENDOR #define CFG_TUD_CUSTOM_CLASS 0 /*------------------------------------------------------------------*/ diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index ff08ade18a..9b0cba8da3 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -37,6 +37,26 @@ #include "tusb.h" +#if CIRCUITPY_USB_VENDOR +#include "genhdr/autogen_usb_descriptor.h" + +// The WebUSB support being conditionally added to this file is based on the +// tinyusb demo examples/device/webusb_serial. + +enum +{ + VENDOR_REQUEST_WEBUSB = 1, + VENDOR_REQUEST_MICROSOFT = 2 +}; + +extern uint8_t const desc_ms_os_20[]; +extern const tusb_desc_webusb_url_t desc_webusb_url; + +static bool web_serial_connected = false; +#endif + + + // Serial number as hex characters. This writes directly to the USB // descriptor. extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2]; @@ -141,6 +161,62 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) { } } +#if CIRCUITPY_USB_VENDOR +//--------------------------------------------------------------------+ +// WebUSB use vendor class +//--------------------------------------------------------------------+ + +bool tud_vendor_connected(void) +{ + return web_serial_connected; +} + +// Invoked when a control transfer occurred on an interface of this class +// Driver response accordingly to the request and the transfer stage (setup/data/ack) +// return false to stall control endpoint (e.g unsupported request) +bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request) +{ + // nothing to with DATA & ACK stage + if (stage != CONTROL_STAGE_SETUP ) return true; + + switch (request->bRequest) + { + case VENDOR_REQUEST_WEBUSB: + // match vendor request in BOS descriptor + // Get landing page url + return tud_control_xfer(rhport, request, (void*) &desc_webusb_url, desc_webusb_url.bLength); + + case VENDOR_REQUEST_MICROSOFT: + if ( request->wIndex == 7 ) + { + // Get Microsoft OS 2.0 compatible descriptor + uint16_t total_len; + memcpy(&total_len, desc_ms_os_20+8, 2); + + return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len); + } else + { + return false; + } + + case 0x22: + // Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to + // connect and disconnect. + web_serial_connected = (request->wValue != 0); + + // response with status OK + return tud_control_status(rhport, request); + + default: + // stall unknown request + return false; + } + + return true; +} +#endif CIRCUITPY_USB_VENDOR + + #if MICROPY_KBD_EXCEPTION /** diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index a59e99e3de..70d3e146b2 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -102,6 +102,11 @@ else shared-module/usb_midi/PortOut.c endif + ifeq ($(CIRCUITPY_USB_VENDOR), 1) + SRC_SUPERVISOR += \ + lib/tinyusb/src/class/vendor/vendor_device.c + endif + CFLAGS += -DUSB_AVAILABLE endif @@ -119,6 +124,10 @@ ifndef USB_INTERFACE_NAME USB_INTERFACE_NAME = "CircuitPython" endif +ifndef USB_WEBUSB_URL +USB_WEBUSB_URL = "www.circuitpython.org" +endif + USB_DEVICES_COMPUTED := CDC,MSC ifeq ($(CIRCUITPY_USB_MIDI),1) USB_DEVICES_COMPUTED := $(USB_DEVICES_COMPUTED),AUDIO @@ -126,6 +135,9 @@ endif ifeq ($(CIRCUITPY_USB_HID),1) USB_DEVICES_COMPUTED := $(USB_DEVICES_COMPUTED),HID endif +ifeq ($(CIRCUITPY_USB_VENDOR),1) +USB_DEVICES_COMPUTED := $(USB_DEVICES_COMPUTED),VENDOR +endif USB_DEVICES ?= "$(USB_DEVICES_COMPUTED)" ifndef USB_HID_DEVICES @@ -198,6 +210,12 @@ USB_DESCRIPTOR_ARGS = \ --output_c_file $(BUILD)/autogen_usb_descriptor.c\ --output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h +ifeq ($(CIRCUITPY_USB_VENDOR), 1) +USB_DESCRIPTOR_ARGS += \ + --vendor_ep_num_out 0 --vendor_ep_num_in 0 \ + --webusb_url $(USB_WEBUSB_URL) +endif + ifeq ($(USB_RENUMBER_ENDPOINTS), 0) USB_DESCRIPTOR_ARGS += --no-renumber_endpoints endif diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 0f936597f4..86de86d1a3 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -484,6 +484,7 @@ h_file = args.output_h_file c_file.write("""\ #include +#include "tusb.h" #include "py/objtuple.h" #include "shared-bindings/usb_hid/Device.h" #include "{H_FILE_NAME}" @@ -628,11 +629,13 @@ extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}]; msc_vendor=args.manufacturer[:8], msc_product=args.product[:16])) -if 'VENDOR' in args.devices: - h_file.write("""\ -extern const tusb_desc_webusb_url_t desc_webusb_url; - -""") +# Currently getting compile-time errors in files like tusb_fifo.c +# if we try do define this here (TODO figure this out!) +#if 'VENDOR' in args.devices: +# h_file.write("""\ +#extern const tusb_desc_webusb_url_t desc_webusb_url; +# +#""") h_file.write("""\ #endif // MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H @@ -719,4 +722,44 @@ const tusb_desc_webusb_url_t desc_webusb_url = .bScheme = 1, // 0: http, 1: https, 255: "" .url = URL }}; + +// This next hardcoded descriptor was pulled from the usb_descriptor.c file of the +// tinyusb webusb_serial demo. TODO - this is probably something else to integrate +// into the adafruit_usb_descriptors project, especially with this next #define.. +#define ITF_NUM_VENDOR 6 // SWAG for now. + +#define MS_OS_20_DESC_LEN 0xB2 + +uint8_t const desc_ms_os_20[] = +{{ + // Set header: length, type, windows version, total length + U16_TO_U8S_LE(0x000A), U16_TO_U8S_LE(MS_OS_20_SET_HEADER_DESCRIPTOR), U32_TO_U8S_LE(0x06030000), U16_TO_U8S_LE(MS_OS_20_DESC_LEN), + + // Configuration subset header: length, type, configuration index, reserved, configuration total length + U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_CONFIGURATION), 0, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A), + + // Function Subset header: length, type, first interface, reserved, subset length + U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), ITF_NUM_VENDOR, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A-0x08), + + // MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID + U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sub-compatible + + // MS OS 2.0 Registry property descriptor: length, type + U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A-0x08-0x08-0x14), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), + U16_TO_U8S_LE(0x0007), U16_TO_U8S_LE(0x002A), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUIDs\0" in UTF-16 + 'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, + 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 's', 0x00, 0x00, 0x00, + U16_TO_U8S_LE(0x0050), // wPropertyDataLength + //bPropertyData: “{{975F44D9-0D08-43FD-8B3E-127CA8AFFF9D}}”. + '{{', 0x00, '9', 0x00, '7', 0x00, '5', 0x00, 'F', 0x00, '4', 0x00, '4', 0x00, 'D', 0x00, '9', 0x00, '-', 0x00, + '0', 0x00, 'D', 0x00, '0', 0x00, '8', 0x00, '-', 0x00, '4', 0x00, '3', 0x00, 'F', 0x00, 'D', 0x00, '-', 0x00, + '8', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, '-', 0x00, '1', 0x00, '2', 0x00, '7', 0x00, 'C', 0x00, 'A', 0x00, + '8', 0x00, 'A', 0x00, 'F', 0x00, 'F', 0x00, 'F', 0x00, '9', 0x00, 'D', 0x00, '}}', 0x00, 0x00, 0x00, 0x00, 0x00 +}}; + +TU_VERIFY_STATIC(sizeof(desc_ms_os_20) == MS_OS_20_DESC_LEN, "Incorrect size"); + +// End of section about desc_ms_os_20 + """.format(webusb_url=args.webusb_url)) From 815ab5277bf05b0ca85aa084f4e371c5532a7014 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 26 Jan 2021 14:13:12 -0500 Subject: [PATCH 07/78] Fix stubs error, out of sockets error, invalid TLS leak --- ports/esp32s2/common-hal/socketpool/Socket.c | 8 +++++++- ports/esp32s2/common-hal/ssl/SSLContext.c | 7 ++++--- shared-bindings/ssl/SSLContext.c | 2 +- shared-bindings/ssl/SSLSocket.c | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index 4cbf4cff26..0022c49c62 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -44,8 +44,8 @@ void socket_reset(void) { for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_handles); i++) { if (open_socket_handles[i]) { if (open_socket_handles[i]->num > 0) { + // Close automatically clears socket handle common_hal_socketpool_socket_close(open_socket_handles[i]); - open_socket_handles[i] = NULL; } else { open_socket_handles[i] = NULL; } @@ -136,6 +136,12 @@ void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self) { lwip_close(self->num); self->num = -1; } + // Remove socket record + for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_handles); i++) { + if (open_socket_handles[i] == self) { + open_socket_handles[i] = NULL; + } + } } bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, diff --git a/ports/esp32s2/common-hal/ssl/SSLContext.c b/ports/esp32s2/common-hal/ssl/SSLContext.c index c0179399de..6b05905aa6 100644 --- a/ports/esp32s2/common-hal/ssl/SSLContext.c +++ b/ports/esp32s2/common-hal/ssl/SSLContext.c @@ -38,14 +38,15 @@ void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t* self) { ssl_sslsocket_obj_t* common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t* self, socketpool_socket_obj_t* socket, bool server_side, const char* server_hostname) { + if (socket->type != SOCK_STREAM || socket->num != -1) { + mp_raise_RuntimeError(translate("Invalid socket for TLS")); + } + ssl_sslsocket_obj_t *sock = m_new_obj_with_finaliser(ssl_sslsocket_obj_t); sock->base.type = &ssl_sslsocket_type; sock->ssl_context = self; sock->sock = socket; - if (socket->type != SOCK_STREAM || socket->num != -1) { - mp_raise_RuntimeError(translate("Invalid socket for TLS")); - } esp_tls_t* tls_handle = esp_tls_init(); if (tls_handle == NULL) { mp_raise_espidf_MemoryError(); diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 9d4df72619..44e9e6bbf8 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -51,7 +51,7 @@ STATIC mp_obj_t ssl_sslcontext_make_new(const mp_obj_type_t *type, size_t n_args return MP_OBJ_FROM_PTR(s); } -//| def wrap_socket(sock: socketpool.Socket, *, server_side: bool = False, server_hostname: Optional[str] = None) -> socketpool.Socket: +//| def wrap_socket(sock: socketpool.Socket, *, server_side: bool = False, server_hostname: Optional[str] = None) -> ssl.SSLSocket: //| """Wraps the socket into a socket-compatible class that handles SSL negotiation. //| The socket must be of type SOCK_STREAM.""" //| ... diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c index 154d3d1d44..cd2daeb3e3 100644 --- a/shared-bindings/ssl/SSLSocket.c +++ b/shared-bindings/ssl/SSLSocket.c @@ -45,7 +45,7 @@ //| recv that do not allocate bytes objects.""" //| -//| def __enter__(self) -> Socket: +//| def __enter__(self) -> SSLSocket: //| """No-op used by Context Managers.""" //| ... //| @@ -63,7 +63,7 @@ STATIC mp_obj_t ssl_sslsocket___exit__(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ssl_sslsocket___exit___obj, 4, 4, ssl_sslsocket___exit__); -//| def accept(self) -> Tuple[Socket, Tuple[str, int]]: +//| def accept(self) -> Tuple[SSLSocket, Tuple[str, int]]: //| """Accept a connection on a listening socket of type SOCK_STREAM, //| creating a new socket of type SOCK_STREAM. //| Returns a tuple of (new_socket, remote_address)""" From b152c658e2538f2e2cb6c760c4b4dab6bb6cf357 Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Tue, 26 Jan 2021 18:18:39 -0600 Subject: [PATCH 08/78] Making WebUSB default to off (build unbreakage, caught by CI) --- py/circuitpy_mpconfig.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 6e721e1bc8..538d50e946 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -270,7 +270,10 @@ CFLAGS += -DCIRCUITPY_USB_HID=$(CIRCUITPY_USB_HID) CIRCUITPY_USB_MIDI ?= 1 CFLAGS += -DCIRCUITPY_USB_MIDI=$(CIRCUITPY_USB_MIDI) -CIRCUITPY_USB_VENDOR ?= 1 +# Defaulting this to OFF initially because it has only been tested on a +# limited number of platforms, and the other platforms do not have this +# setting in their mpconfigport.mk and/or mpconfigboard.mk files yet. +CIRCUITPY_USB_VENDOR ?= 0 CFLAGS += -DCIRCUITPY_USB_VENDOR=$(CIRCUITPY_USB_VENDOR) CIRCUITPY_PEW ?= 0 From 1b031508e14a3cdfa2ba9c5cf158126d3f002cba Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Tue, 26 Jan 2021 20:43:19 -0600 Subject: [PATCH 09/78] BOS and MS_OS_2.0 descriptors have been added. Still more descriptor work TODO. --- supervisor/shared/usb/usb.c | 7 ---- tools/gen_usb_descriptor.py | 74 +++++++++++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 9b0cba8da3..5db90d2fa9 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -43,13 +43,6 @@ // The WebUSB support being conditionally added to this file is based on the // tinyusb demo examples/device/webusb_serial. -enum -{ - VENDOR_REQUEST_WEBUSB = 1, - VENDOR_REQUEST_MICROSOFT = 2 -}; - -extern uint8_t const desc_ms_os_20[]; extern const tusb_desc_webusb_url_t desc_webusb_url; static bool web_serial_connected = false; diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 86de86d1a3..210ca19238 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -629,13 +629,21 @@ extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}]; msc_vendor=args.manufacturer[:8], msc_product=args.product[:16])) -# Currently getting compile-time errors in files like tusb_fifo.c -# if we try do define this here (TODO figure this out!) -#if 'VENDOR' in args.devices: -# h_file.write("""\ -#extern const tusb_desc_webusb_url_t desc_webusb_url; -# -#""") +if 'VENDOR' in args.devices: + h_file.write("""\ +enum +{ + VENDOR_REQUEST_WEBUSB = 1, + VENDOR_REQUEST_MICROSOFT = 2 +}; + +extern uint8_t const desc_ms_os_20[]; + +// Currently getting compile-time errors in files like tusb_fifo.c +// if we try do define this here (TODO figure this out!) +//extern const tusb_desc_webusb_url_t desc_webusb_url; + +""") h_file.write("""\ #endif // MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H @@ -711,7 +719,7 @@ c_file.write("""\ """) if 'VENDOR' in args.devices: - # Mimic what the tinyusb webusb demo does + # Mimic what the tinyusb webusb demo does in it's main.c file c_file.write(""" #define URL "{webusb_url}" @@ -723,13 +731,55 @@ const tusb_desc_webusb_url_t desc_webusb_url = .url = URL }}; -// This next hardcoded descriptor was pulled from the usb_descriptor.c file of the -// tinyusb webusb_serial demo. TODO - this is probably something else to integrate -// into the adafruit_usb_descriptors project, especially with this next #define.. -#define ITF_NUM_VENDOR 6 // SWAG for now. +// These next two hardcoded descriptor were pulled from the usb_descriptor.c file +// of the tinyusb webusb_serial demo. TODO - this is probably something else to +// integrate into the adafruit_usb_descriptors project, especially with this next +// #define.. + +// SWAG for now. Will have to be manually corrected until generated by gen_usb_descriptor.py +#define ITF_NUM_VENDOR 6i + +//--------------------------------------------------------------------+ +// BOS Descriptor +//--------------------------------------------------------------------+ + +/* Microsoft OS 2.0 registry property descriptor +Per MS requirements https://msdn.microsoft.com/en-us/library/windows/hardware/hh450799(v=vs.85).aspx +device should create DeviceInterfaceGUIDs. It can be done by driver and +in case of real PnP solution device should expose MS "Microsoft OS 2.0 +registry property descriptor". Such descriptor can insert any record +into Windows registry per device/configuration/interface. In our case it +will insert "DeviceInterfaceGUIDs" multistring property. + +GUID is freshly generated and should be OK to use. + +https://developers.google.com/web/fundamentals/native-hardware/build-for-webusb/ +(Section Microsoft OS compatibility descriptors) +*/ + +#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN) #define MS_OS_20_DESC_LEN 0xB2 +// BOS Descriptor is required for webUSB +uint8_t const desc_bos[] = +{{ + // total length, number of device caps + TUD_BOS_DESCRIPTOR(BOS_TOTAL_LEN, 2), + + // Vendor Code, iLandingPage + TUD_BOS_WEBUSB_DESCRIPTOR(VENDOR_REQUEST_WEBUSB, 1), + + // Microsoft OS 2.0 descriptor + TUD_BOS_MS_OS_20_DESCRIPTOR(MS_OS_20_DESC_LEN, VENDOR_REQUEST_MICROSOFT) +}}; + +uint8_t const * tud_descriptor_bos_cb(void) +{{ + return desc_bos; +}} + + uint8_t const desc_ms_os_20[] = {{ // Set header: length, type, windows version, total length From 63f9b12fe61c9df6e993f92d7cfef1038523d930 Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Thu, 28 Jan 2021 20:22:31 -0600 Subject: [PATCH 10/78] Partially hard-coded VENDOR descriptor has been added. First build to be accessed via WebUSB. NOTE - had to disable HID (EndPoint shortage?) --- ports/esp32s2/mpconfigport.mk | 1 + tools/gen_usb_descriptor.py | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 2d324e1618..7dcd3355f5 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -30,6 +30,7 @@ CIRCUITPY_ROTARYIO = 1 CIRCUITPY_NVM = 1 # We don't have enough endpoints to include MIDI. CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_USB_HID = 0 # We have borrowed the VENDOR nomenclature from tinyusb. VENDOR AKA WEBUSB CIRCUITPY_USB_VENDOR = 1 CIRCUITPY_WIFI = 1 diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 210ca19238..36c6f45a6e 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -390,8 +390,32 @@ audio_control_interface = standard.InterfaceDescriptor( audio_interfaces = [audio_control_interface] + cs_ac_interface.audio_streaming_interfaces + cs_ac_interface.midi_streaming_interfaces # TODO New code goes here to create vendor objects +# Starting out with a clone-and-modify of the HID descriptors +vendor_endpoint_in_descriptor = standard.EndpointDescriptor( + description="VENDOR in", + bEndpointAddress=args.vendor_ep_num_in | standard.EndpointDescriptor.DIRECTION_IN, + bmAttributes=standard.EndpointDescriptor.TYPE_BULK, + bInterval=16) -vendor_interfaces = [] # TODO Fix this! +vendor_endpoint_out_descriptor = standard.EndpointDescriptor( + description="VENDOR out", + bEndpointAddress=args.vendor_ep_num_out | standard.EndpointDescriptor.DIRECTION_OUT, + bmAttributes=standard.EndpointDescriptor.TYPE_BULK, + bInterval=16) + +vendor_interface = standard.InterfaceDescriptor( + description="VENDOR", + bInterfaceClass=0xff, # vendor.VENDOR_CLASS, + bInterfaceSubClass=0x00, #vendor.VENDOR_SUBCLASS_???,, + bInterfaceProtocol=0x00, #vendor.VENDOR_PROTOCOL_NONE, + iInterface=StringIndex.index("{} VENDOR".format(args.interface_name)), + subdescriptors=[ + vendor_endpoint_in_descriptor, + vendor_endpoint_out_descriptor, + ] +) + +vendor_interfaces = [vendor_interface] interfaces_to_join = [] @@ -737,7 +761,7 @@ const tusb_desc_webusb_url_t desc_webusb_url = // #define.. // SWAG for now. Will have to be manually corrected until generated by gen_usb_descriptor.py -#define ITF_NUM_VENDOR 6i +#define ITF_NUM_VENDOR 3 //--------------------------------------------------------------------+ // BOS Descriptor From a724f6f9545710531b415007f9aa93a7aa90060e Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 29 Jan 2021 11:18:50 -0500 Subject: [PATCH 11/78] Fix documentation builds --- ports/esp32s2/common-hal/ssl/SSLContext.c | 2 +- shared-bindings/ssl/SSLSocket.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/esp32s2/common-hal/ssl/SSLContext.c b/ports/esp32s2/common-hal/ssl/SSLContext.c index 6b05905aa6..afc3ecce22 100644 --- a/ports/esp32s2/common-hal/ssl/SSLContext.c +++ b/ports/esp32s2/common-hal/ssl/SSLContext.c @@ -38,7 +38,7 @@ void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t* self) { ssl_sslsocket_obj_t* common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t* self, socketpool_socket_obj_t* socket, bool server_side, const char* server_hostname) { - if (socket->type != SOCK_STREAM || socket->num != -1) { + if (socket->type != SOCK_STREAM) { mp_raise_RuntimeError(translate("Invalid socket for TLS")); } diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c index cd2daeb3e3..c184bceb3f 100644 --- a/shared-bindings/ssl/SSLSocket.c +++ b/shared-bindings/ssl/SSLSocket.c @@ -38,8 +38,8 @@ #include "lib/netutils/netutils.h" //| class SSLSocket: -//| """Implements TLS security on a subset of `socketpool.socket` functions. Cannot be created -//| directly. Instead, call `context.wrap_socket` on an existing socket object. +//| """Implements TLS security on a subset of `socketpool.Socket` functions. Cannot be created +//| directly. Instead, call `wrap_socket` on an existing socket object. //| //| Provides a subset of CPython's `ssl.SSLSocket` API. It only implements the versions of //| recv that do not allocate bytes objects.""" From 8277ffca861754b4df526c62126337c195cc0fee Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Sat, 30 Jan 2021 16:13:28 -0500 Subject: [PATCH 12/78] Fix hash, close, error bugs --- ports/esp32s2/common-hal/socketpool/Socket.c | 7 +------ ports/esp32s2/common-hal/ssl/SSLSocket.c | 19 +++++++++++++------ shared-bindings/socketpool/Socket.c | 2 +- shared-bindings/socketpool/Socket.h | 1 - shared-bindings/ssl/SSLSocket.c | 2 +- shared-bindings/ssl/SSLSocket.h | 1 - 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index 0022c49c62..cee940aafc 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -3,7 +3,6 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries * Copyright (c) 2020 Lucian Copeland for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -198,10 +197,6 @@ bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t* self) { return self->connected; } -mp_uint_t common_hal_socketpool_socket_get_hash(socketpool_socket_obj_t* self) { - return self->num; -} - bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t* self, int backlog) { return lwip_listen(self->num, backlog) == 0; } @@ -289,7 +284,7 @@ mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const } if (sent < 0) { - mp_raise_OSError(MP_ENOTCONN); + mp_raise_OSError(errno); } return sent; } diff --git a/ports/esp32s2/common-hal/ssl/SSLSocket.c b/ports/esp32s2/common-hal/ssl/SSLSocket.c index d8e48c3d59..33507e0f4e 100644 --- a/ports/esp32s2/common-hal/ssl/SSLSocket.c +++ b/ports/esp32s2/common-hal/ssl/SSLSocket.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries * Copyright (c) 2021 Lucian Copeland for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -51,7 +52,7 @@ bool common_hal_ssl_sslsocket_bind(ssl_sslsocket_obj_t* self, } void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t* self) { - self->sock->connected = false; + common_hal_socketpool_socket_close(self->sock); esp_tls_conn_destroy(self->tls); self->tls = NULL; } @@ -99,10 +100,6 @@ bool common_hal_ssl_sslsocket_get_connected(ssl_sslsocket_obj_t* self) { return self->sock->connected; } -mp_uint_t common_hal_ssl_sslsocket_get_hash(ssl_sslsocket_obj_t* self) { - return self->sock->num; -} - bool common_hal_ssl_sslsocket_listen(ssl_sslsocket_obj_t* self, int backlog) { return common_hal_socketpool_socket_listen(self->sock, backlog); } @@ -163,7 +160,17 @@ mp_uint_t common_hal_ssl_sslsocket_send(ssl_sslsocket_obj_t* self, const uint8_t sent = esp_tls_conn_write(self->tls, buf, len); if (sent < 0) { - mp_raise_OSError(MP_ENOTCONN); + int esp_tls_code; + int flags; + esp_err_t err = esp_tls_get_and_clear_last_error(self->tls->error_handle, &esp_tls_code, &flags); + + if (err == ESP_ERR_MBEDTLS_SSL_SETUP_FAILED) { + mp_raise_espidf_MemoryError(); + } else if (ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED) { + mp_raise_OSError_msg_varg(translate("Failed SSL handshake")); + } else { + mp_raise_OSError_msg_varg(translate("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, sent); + } } return sent; } diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index f169d6acac..27440487a7 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -370,7 +370,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_settimeout_obj, socketpool_so STATIC mp_obj_t socketpool_socket_unary_op(mp_unary_op_t op, mp_obj_t self_in) { switch (op) { case MP_UNARY_OP_HASH: { - return MP_OBJ_NEW_SMALL_INT(common_hal_socketpool_socket_get_hash(MP_OBJ_TO_PTR(self_in))); + return mp_obj_id(self_in); } default: return MP_OBJ_NULL; // op not supported diff --git a/shared-bindings/socketpool/Socket.h b/shared-bindings/socketpool/Socket.h index 76af6e1e9b..637a7a2146 100644 --- a/shared-bindings/socketpool/Socket.h +++ b/shared-bindings/socketpool/Socket.h @@ -37,7 +37,6 @@ void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self); bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const char* host, size_t hostlen, mp_int_t port); bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t* self); bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t* self); -mp_uint_t common_hal_socketpool_socket_get_hash(socketpool_socket_obj_t* self); mp_uint_t common_hal_socketpool_socket_get_timeout(socketpool_socket_obj_t* self); bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t* self, int backlog); mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c index c184bceb3f..a937952a5d 100644 --- a/shared-bindings/ssl/SSLSocket.c +++ b/shared-bindings/ssl/SSLSocket.c @@ -286,7 +286,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_setblocking_obj, ssl_sslsocket_se STATIC mp_obj_t ssl_sslsocket_unary_op(mp_unary_op_t op, mp_obj_t self_in) { switch (op) { case MP_UNARY_OP_HASH: { - return MP_OBJ_NEW_SMALL_INT(common_hal_ssl_sslsocket_get_hash(MP_OBJ_TO_PTR(self_in))); + return mp_obj_id(self_in); } default: return MP_OBJ_NULL; // op not supported diff --git a/shared-bindings/ssl/SSLSocket.h b/shared-bindings/ssl/SSLSocket.h index d8c589fd80..b1f2c513d7 100644 --- a/shared-bindings/ssl/SSLSocket.h +++ b/shared-bindings/ssl/SSLSocket.h @@ -37,7 +37,6 @@ void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t* self); bool common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t* self, const char* host, size_t hostlen, mp_int_t port); bool common_hal_ssl_sslsocket_get_closed(ssl_sslsocket_obj_t* self); bool common_hal_ssl_sslsocket_get_connected(ssl_sslsocket_obj_t* self); -mp_uint_t common_hal_ssl_sslsocket_get_hash(ssl_sslsocket_obj_t* self); bool common_hal_ssl_sslsocket_listen(ssl_sslsocket_obj_t* self, int backlog); mp_uint_t common_hal_ssl_sslsocket_recv_into(ssl_sslsocket_obj_t* self, const uint8_t* buf, mp_uint_t len); mp_uint_t common_hal_ssl_sslsocket_send(ssl_sslsocket_obj_t* self, const uint8_t* buf, mp_uint_t len); From e1618c21b20e82f2259118cd1baf67f6954b92ef Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Mon, 1 Feb 2021 17:56:38 -0600 Subject: [PATCH 13/78] Default WebUSB to OFF because other ports are not ready for it yet --- ports/esp32s2/mpconfigport.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 7dcd3355f5..b273c02ee8 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -29,10 +29,10 @@ CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_ROTARYIO = 1 CIRCUITPY_NVM = 1 # We don't have enough endpoints to include MIDI. -CIRCUITPY_USB_MIDI = 0 -CIRCUITPY_USB_HID = 0 +CIRCUITPY_USB_MIDI ?= 0 +CIRCUITPY_USB_HID ?= 1 # We have borrowed the VENDOR nomenclature from tinyusb. VENDOR AKA WEBUSB -CIRCUITPY_USB_VENDOR = 1 +CIRCUITPY_USB_VENDOR ?= 0 CIRCUITPY_WIFI = 1 CIRCUITPY_WATCHDOG ?= 1 CIRCUITPY_ESPIDF = 1 From 817ca39f59a539fff9e0bc29259b114e34cdf609 Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Mon, 1 Feb 2021 18:35:58 -0600 Subject: [PATCH 14/78] ITF_NUM_VENDOR is now automatically computed at run-time --- tools/gen_usb_descriptor.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 36c6f45a6e..bd77be5832 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -757,11 +757,7 @@ const tusb_desc_webusb_url_t desc_webusb_url = // These next two hardcoded descriptor were pulled from the usb_descriptor.c file // of the tinyusb webusb_serial demo. TODO - this is probably something else to -// integrate into the adafruit_usb_descriptors project, especially with this next -// #define.. - -// SWAG for now. Will have to be manually corrected until generated by gen_usb_descriptor.py -#define ITF_NUM_VENDOR 3 +// integrate into the adafruit_usb_descriptors project... //--------------------------------------------------------------------+ // BOS Descriptor @@ -804,6 +800,8 @@ uint8_t const * tud_descriptor_bos_cb(void) }} +#define ITF_NUM_VENOR {webusb_interface} // used in this next descriptor + uint8_t const desc_ms_os_20[] = {{ // Set header: length, type, windows version, total length @@ -836,4 +834,4 @@ TU_VERIFY_STATIC(sizeof(desc_ms_os_20) == MS_OS_20_DESC_LEN, "Incorrect size"); // End of section about desc_ms_os_20 -""".format(webusb_url=args.webusb_url)) +""".format(webusb_url=args.webusb_url, webusb_interface=vendor_interface.bInterfaceNumber)) From 1a9e4f5613d663d6bff29d21f5ff64bf653e56cc Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Mon, 1 Feb 2021 18:51:11 -0600 Subject: [PATCH 15/78] Restored accidentally deleted character --- tools/gen_usb_descriptor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index bd77be5832..cf74001088 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -800,7 +800,7 @@ uint8_t const * tud_descriptor_bos_cb(void) }} -#define ITF_NUM_VENOR {webusb_interface} // used in this next descriptor +#define ITF_NUM_VENDOR {webusb_interface} // used in this next descriptor uint8_t const desc_ms_os_20[] = {{ From e79283932ddaac4dd1cc663ff90f76080c18551f Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Mon, 1 Feb 2021 19:08:56 -0600 Subject: [PATCH 16/78] Moving control of USB compile-time options down to the BOARD level --- ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.mk b/ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.mk index 2dce038819..52c63cb9c7 100644 --- a/ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.mk +++ b/ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.mk @@ -14,4 +14,10 @@ CIRCUITPY_ESP_FLASH_MODE=dio CIRCUITPY_ESP_FLASH_FREQ=80m CIRCUITPY_ESP_FLASH_SIZE=4MB +# We only have enough endpoints available in hardware to +# enable ONE of these at a time. +CIRCUITPY_USB_MIDI = 1 +CIRCUITPY_USB_HID = 0 +CIRCUITPY_USB_VENDOR = 0 + CIRCUITPY_MODULE=wrover From 386deb2ac4eb3be454e0c3ad4f8cf32f030ce101 Mon Sep 17 00:00:00 2001 From: hexthat Date: Mon, 1 Feb 2021 20:53:58 +0000 Subject: [PATCH 17/78] Translated using Weblate (Chinese (Pinyin)) Currently translated at 100.0% (955 of 955 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 61 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 09def43300..8a13e52a11 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-01-30 02:32+0000\n" +"PO-Revision-Date: 2021-02-02 03:38+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -351,7 +351,7 @@ msgstr "Suǒyǒu shǐyòng de shìjiàn píndào" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "All state machines in use" -msgstr "" +msgstr "suǒ yǒu zhèng zài shǐ yòng de zhuàng tài jī" #: ports/atmel-samd/audio_dma.c ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "All sync event channels in use" @@ -1070,7 +1070,7 @@ msgstr "I2C chūshǐhuà cuòwù" #: ports/raspberrypi/common-hal/busio/I2C.c msgid "I2C peripheral in use" -msgstr "" +msgstr "I2C wài shè zhèng zài shǐ yòng zhōng" #: shared-bindings/audiobusio/I2SOut.c msgid "I2SOut not available" @@ -1099,7 +1099,7 @@ msgstr "Huǎnchōng qū dàxiǎo bù zhèngquè" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Init program size invalid" -msgstr "" +msgstr "Init chéng xù dà xiǎo wú xiào" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" @@ -1116,27 +1116,27 @@ msgstr "Shūrù/shūchū cuòwù" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d jumps on pin" -msgstr "" +msgstr "zhǐ lìng %d zài yǐn jiǎo shàng tiào zhuǎn" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d shifts in more bits than pin count" -msgstr "" +msgstr "zhǐ lìng %d yí wèi chāo guò yǐn jiǎo jì shù" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d shifts out more bits than pin count" -msgstr "" +msgstr "zhǐ lìng %d yí chū de wèi bǐ yǐn jiǎo shù duō" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d uses extra pin" -msgstr "" +msgstr "zhǐ lìng %d shǐ yòng é wài de yǐn jiǎo" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d waits on input outside of count" -msgstr "" +msgstr "zhǐ lìng %d děng dài jì shù zhī wài de shū rù" #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient authentication" @@ -1409,32 +1409,33 @@ msgstr "Quēshǎo MISO huò MOSI yǐn jiǎo" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_in_pin. Instruction %d reads pin(s)" -msgstr "" +msgstr "shǒu xiān zài yǐn jiǎo zhōng quē shī. zhǐ lìng %d dú qǔ yǐn jiǎo" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_in_pin. Instruction %d shifts in from pin(s)" -msgstr "" +msgstr "shǒu xiān zài yǐn jiǎo zhōng quē shī. zhǐ lìng %d cóng yǐn jiǎo yí wèi" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_in_pin. Instruction %d waits based on pin" msgstr "" +"shǒu xiān zài yǐn jiǎo zhōng quē shī. jī yú yǐn jiǎo de zhǐ lìng %d děng dài" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_out_pin. Instruction %d shifts out to pin(s)" -msgstr "" +msgstr "xiān lòu chū yǐn jiǎo. zhǐ lìng %d yí chū dào yǐn jiǎo" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_out_pin. Instruction %d writes pin(s)" -msgstr "" +msgstr "xiān lòu chū yǐn jiǎo. zhǐ lìng %d xiě rù yǐn jiǎo" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_set_pin. Instruction %d sets pin(s)" -msgstr "" +msgstr "quē shǎo dì yī zǔ yǐn jiǎo. zhǐ lìng %d shè zhì yǐn jiǎo" #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." @@ -1555,7 +1556,7 @@ msgstr "Méiyǒu wǎngluò yǔ gāi ssid" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "No out in program" -msgstr "" +msgstr "chéng xù zhōng wèi tuì chū" #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" @@ -1615,7 +1616,7 @@ msgstr "Zhǐyǒu 8 huò 16 wèi dānwèi " #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Only IN/OUT of up to 8 supported" -msgstr "" +msgstr "jǐn zhī chí zuì duō 8 gè IN/OUT" #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" @@ -1709,11 +1710,11 @@ msgstr "Quánxiàn bèi jùjué" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Pin count must be at least 1" -msgstr "" +msgstr "yǐn jiǎo jì shù bì xū zhì shǎo wéi 1" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Pin count too large" -msgstr "" +msgstr "yǐn jiǎo jì shù tài dà" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c #: ports/cxd56/common-hal/analogio/AnalogIn.c @@ -1789,23 +1790,23 @@ msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Program does IN without loading ISR" -msgstr "" +msgstr "chéng xù zài bù jiā zǎi ISR de qíng kuàng xià wán chéng" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Program does OUT without loading OSR" -msgstr "" +msgstr "chéng xù zài bù jiā zǎi Osr de qíng kuàng xià zhí xíng OUT" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Program must contain at least one 16-bit instruction." -msgstr "" +msgstr "chéng xù bì xū zhì shǎo bāo hán yí gè 16 wèi zhǐ lìng ." #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Program size invalid" -msgstr "" +msgstr "chéng xù dà xiǎo wú xiào" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Program too large" -msgstr "" +msgstr "chéng xù tài dà" #: shared-bindings/digitalio/DigitalInOut.c msgid "Pull not used when direction is output." @@ -1813,7 +1814,7 @@ msgstr "Fāngxiàng shūchū shí Pull méiyǒu shǐyòng." #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" -msgstr "" +msgstr "wèi shí xiàn tí shēng mó shì" #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" @@ -1921,7 +1922,7 @@ msgstr "SPI chóngxīn chūshǐhuà cuòwù" #: ports/raspberrypi/common-hal/busio/SPI.c msgid "SPI peripheral in use" -msgstr "" +msgstr "SPI wài shè zhèng zài shǐ yòng zhōng" #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" @@ -1955,11 +1956,11 @@ msgstr "Fúwùqì duān shàngxiàwén bùnéng jùyǒu zhǔjī míng" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Set pin count must be between 1 and 5" -msgstr "" +msgstr "shè zhì yǐn jiǎo shù bì xū jiè yú 1 hé 5 zhī jiān" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Side set pin count must be between 1 and 5" -msgstr "" +msgstr "cè miàn shè zhì yǐn jiǎo shù bì xū jiè yú 1 hé 5 zhī jiān" #: ports/cxd56/common-hal/camera/Camera.c msgid "Size not supported" @@ -2136,7 +2137,7 @@ msgstr "UART chóngxīn chūshǐhuà cuòwù" #: ports/raspberrypi/common-hal/busio/UART.c msgid "UART not yet supported" -msgstr "" +msgstr "UART shàng wèi shòu zhī chí" #: ports/stm/common-hal/busio/UART.c msgid "UART write error" @@ -3712,11 +3713,11 @@ msgstr "zài qǐdòng shí tóngshí àn xià liǎng gè ànniǔ.\n" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "pull_threshold must be between 1 and 32" -msgstr "" +msgstr "lā lì yù zhí bì xū jiè yú 1 hé 32 zhī jiān" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "push_threshold must be between 1 and 32" -msgstr "" +msgstr "tuī sòng yù zhí bì xū jiè yú 1 hé 32 zhī jiān" #: extmod/modutimeq.c msgid "queue overflow" From a4eabdb79d4ac548c1787d1cc82ca9f870844295 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 2 Feb 2021 04:38:29 +0100 Subject: [PATCH 18/78] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 6 +++++- locale/cs.po | 6 +++++- locale/de_DE.po | 6 +++++- locale/el.po | 6 +++++- locale/es.po | 6 +++++- locale/fil.po | 6 +++++- locale/fr.po | 6 +++++- locale/hi.po | 6 +++++- locale/it_IT.po | 6 +++++- locale/ja.po | 6 +++++- locale/ko.po | 6 +++++- locale/nl.po | 6 +++++- locale/pl.po | 6 +++++- locale/pt_BR.po | 6 +++++- locale/sv.po | 6 +++++- locale/zh_Latn_pinyin.po | 6 +++++- 16 files changed, 80 insertions(+), 16 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 3e07620698..b4bdfdb480 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -1825,6 +1825,10 @@ msgstr "Kesalahan DeInit RNG" msgid "RNG Init Error" msgstr "Kesalahan Init RNG" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1840,7 +1844,7 @@ msgid "RTC is not supported on this board" msgstr "RTC tidak didukung di board ini" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "RTS/CTS/RS485 Belum didukung pada perangkat ini" diff --git a/locale/cs.po b/locale/cs.po index e6ad0a83f7..f7bd9fb73d 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -1796,6 +1796,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1811,7 +1815,7 @@ msgid "RTC is not supported on this board" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index e23f27bfe3..db04c99519 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -1824,6 +1824,10 @@ msgstr "RNG DeInit-Fehler" msgid "RNG Init Error" msgstr "RNG Init Fehler" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1839,7 +1843,7 @@ msgid "RTC is not supported on this board" msgstr "Eine RTC wird auf diesem Board nicht unterstützt" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "RTS / CTS / RS485 Wird von diesem Gerät noch nicht unterstützt" diff --git a/locale/el.po b/locale/el.po index 0c7cb5f6bb..ac2046a974 100644 --- a/locale/el.po +++ b/locale/el.po @@ -1793,6 +1793,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1808,7 +1812,7 @@ msgid "RTC is not supported on this board" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "" diff --git a/locale/es.po b/locale/es.po index b446ceb484..7670486ac9 100644 --- a/locale/es.po +++ b/locale/es.po @@ -1828,6 +1828,10 @@ msgstr "Error de desinicialización de RNG" msgid "RNG Init Error" msgstr "Error de inicialización de RNG" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1843,7 +1847,7 @@ msgid "RTC is not supported on this board" msgstr "RTC no soportado en esta placa" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "Sin capacidad de RTS/CTS/RS485 para este dispositivo" diff --git a/locale/fil.po b/locale/fil.po index bba9761ad9..78ded9cf9c 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -1812,6 +1812,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1827,7 +1831,7 @@ msgid "RTC is not supported on this board" msgstr "Hindi supportado ang RTC sa board na ito" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 83af1f9f7c..882d7d8074 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -1850,6 +1850,10 @@ msgstr "Erreur de désinitiation du RNG (RNG DeInit)" msgid "RNG Init Error" msgstr "Erreur d'initialisation du RNG (RNG Init)" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1865,7 +1869,7 @@ msgid "RTC is not supported on this board" msgstr "RTC non supporté sur cette carte" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "RTS / CTS / RS485 Pas encore supporté sur cet appareil" diff --git a/locale/hi.po b/locale/hi.po index 5150d164e1..dd8fa6c76e 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -1793,6 +1793,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1808,7 +1812,7 @@ msgid "RTC is not supported on this board" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index cecfe11298..7d756b931f 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -1822,6 +1822,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1837,7 +1841,7 @@ msgid "RTC is not supported on this board" msgstr "RTC non supportato su questa scheda" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index c139ec3cc8..96e8340f23 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -1809,6 +1809,10 @@ msgstr "RNG解体エラー" msgid "RNG Init Error" msgstr "乱数生成器の初期化エラー" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1824,7 +1828,7 @@ msgid "RTC is not supported on this board" msgstr "このボードはRTCに対応していません" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "RTS/CTS/RS485はこのデバイスでは未対応" diff --git a/locale/ko.po b/locale/ko.po index 54e57f191f..bd0e8cf427 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -1796,6 +1796,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1811,7 +1815,7 @@ msgid "RTC is not supported on this board" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index de9aed9e7d..afa4b77423 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -1825,6 +1825,10 @@ msgstr "RNG DeInit Fout" msgid "RNG Init Error" msgstr "RNG Init Fout" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1840,7 +1844,7 @@ msgid "RTC is not supported on this board" msgstr "RTC is niet ondersteund door dit board" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "RTS/CTS/RS485 Nog niet ondersteund door dit apparaat" diff --git a/locale/pl.po b/locale/pl.po index e9a794cac8..60bf3e7d60 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -1807,6 +1807,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1822,7 +1826,7 @@ msgid "RTC is not supported on this board" msgstr "Brak obsługi RTC" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 2b9f9afa2e..d5a3684a5e 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -1846,6 +1846,10 @@ msgstr "Erro DeInit RNG" msgid "RNG Init Error" msgstr "Houve um erro na inicialização do RNG" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1861,7 +1865,7 @@ msgid "RTC is not supported on this board" msgstr "O RTC não é suportado nesta placa" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "RTS/CTS/RS485 Ainda não é compatível neste dispositivo" diff --git a/locale/sv.po b/locale/sv.po index c4c51fcc00..0519dad4f6 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -1828,6 +1828,10 @@ msgstr "RNG DeInit-fel" msgid "RNG Init Error" msgstr "RNG Init-fel" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1843,7 +1847,7 @@ msgid "RTC is not supported on this board" msgstr "RTC stöds inte av detta kort" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "RTS/CTS/RS485 Stöds ännu inte på den här enheten" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 8a13e52a11..1e6e91f007 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -1824,6 +1824,10 @@ msgstr "RNG qǔxiāo chūshǐhuà cuòwù" msgid "RNG Init Error" msgstr "RNG chūshǐhuà cuòwù" +#: ports/nrf/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" @@ -1839,7 +1843,7 @@ msgid "RTC is not supported on this board" msgstr "Cǐ bǎn bù zhīchí RTC" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c -#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" msgstr "RTS/CTS/RS485 gāi shèbèi shàng bù zhīchí" From 829a88d2041ddcda6a8894cad7cc8141ff2a4dda Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 2 Feb 2021 04:47:51 +0100 Subject: [PATCH 19/78] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 1 + locale/cs.po | 1 + locale/de_DE.po | 1 + locale/el.po | 1 + locale/es.po | 1 + locale/fil.po | 1 + locale/fr.po | 1 + locale/hi.po | 1 + locale/it_IT.po | 1 + locale/ja.po | 1 + locale/ko.po | 1 + locale/nl.po | 1 + locale/pl.po | 1 + locale/pt_BR.po | 1 + locale/sv.po | 1 + locale/zh_Latn_pinyin.po | 1 + 16 files changed, 16 insertions(+) diff --git a/locale/ID.po b/locale/ID.po index b4bdfdb480..4bf5baded5 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -1836,6 +1836,7 @@ msgstr "Pembalikan RS485 ditentukan saat tidak dalam mode RS485" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Kalibrasi RTC tidak didukung pada board ini" diff --git a/locale/cs.po b/locale/cs.po index f7bd9fb73d..99dd05e9e7 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -1807,6 +1807,7 @@ msgstr "" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index db04c99519..62d67443bb 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -1835,6 +1835,7 @@ msgstr "RS485-Inversion angegeben, wenn nicht im RS485-Modus" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Die RTC-Kalibrierung wird auf diesem Board nicht unterstützt" diff --git a/locale/el.po b/locale/el.po index ac2046a974..6de90c1dfb 100644 --- a/locale/el.po +++ b/locale/el.po @@ -1804,6 +1804,7 @@ msgstr "" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" diff --git a/locale/es.po b/locale/es.po index 7670486ac9..c174b5b2b3 100644 --- a/locale/es.po +++ b/locale/es.po @@ -1839,6 +1839,7 @@ msgstr "Se especifica inversión de RS485 si no está en modo RS485" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Calibración de RTC no es soportada en esta placa" diff --git a/locale/fil.po b/locale/fil.po index 78ded9cf9c..50697437fe 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -1823,6 +1823,7 @@ msgstr "" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "RTC calibration ay hindi supportado ng board na ito" diff --git a/locale/fr.po b/locale/fr.po index 882d7d8074..23c028da94 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -1861,6 +1861,7 @@ msgstr "Inversion RS485 spécifiée sans être en mode RS485" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "La calibration du RTC non supportée sur cette carte" diff --git a/locale/hi.po b/locale/hi.po index dd8fa6c76e..ec1317580b 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -1804,6 +1804,7 @@ msgstr "" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 7d756b931f..ff36307f94 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -1833,6 +1833,7 @@ msgstr "" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "calibrazione RTC non supportata su questa scheda" diff --git a/locale/ja.po b/locale/ja.po index 96e8340f23..69bbcb08fc 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -1820,6 +1820,7 @@ msgstr "" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "このボードはRTCのキャリブレーションに非対応" diff --git a/locale/ko.po b/locale/ko.po index bd0e8cf427..a761e9ab9d 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -1807,6 +1807,7 @@ msgstr "" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index afa4b77423..e52d73356c 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -1836,6 +1836,7 @@ msgstr "RS485 inversie gespecificeerd terwijl niet in RS485 modus" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "RTC calibratie niet ondersteund door dit board" diff --git a/locale/pl.po b/locale/pl.po index 60bf3e7d60..5c9fcc3871 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -1818,6 +1818,7 @@ msgstr "" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Brak obsługi kalibracji RTC" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index d5a3684a5e..b6bb9d5e5e 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -1857,6 +1857,7 @@ msgstr "A definição da inversão do RS485 quando não está no modo RS485" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "A calibração RTC não é suportada nesta placa" diff --git a/locale/sv.po b/locale/sv.po index 0519dad4f6..32c7af7adf 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -1839,6 +1839,7 @@ msgstr "RS485-inversion specificerad när den inte är i RS485-läge" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "RTC-kalibrering stöds inte av detta kort" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 1e6e91f007..968315704c 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -1835,6 +1835,7 @@ msgstr "Wèi chǔyú RS485 móshì shí zhǐdìngle RS485 fǎn zhuǎn" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Cǐ bǎn bù zhīchí RTC jiàozhǔn" From 8fd6bff7274335d139691d2ce0438b01e58b3ec2 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 1 Feb 2021 20:03:23 -0800 Subject: [PATCH 20/78] Add .spi accessor to SPIDevice Fixes #4108 --- .../adafruit_bus_device/SPIDevice.c | 34 +++++++++++++++++-- .../adafruit_bus_device/SPIDevice.h | 3 +- shared-module/adafruit_bus_device/SPIDevice.c | 7 +++- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/shared-bindings/adafruit_bus_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/SPIDevice.c index e127e39b81..e37f883682 100644 --- a/shared-bindings/adafruit_bus_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/SPIDevice.c @@ -34,6 +34,7 @@ #include "lib/utils/buffer_helper.h" #include "lib/utils/context_manager_helpers.h" +#include "py/objproperty.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" @@ -100,22 +101,51 @@ STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type return (mp_obj_t)self; } +//| def __enter__(self) -> busio.SPI: +//| """Starts a SPI transaction by configuring the SPI and asserting chip select.""" +//| ... +//| STATIC mp_obj_t adafruit_bus_device_spidevice_obj___enter__(mp_obj_t self_in) { adafruit_bus_device_spidevice_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_adafruit_bus_device_spidevice_enter(self); - return self->spi; + return common_hal_adafruit_bus_device_spidevice_enter(self); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(adafruit_bus_device_spidevice___enter___obj, adafruit_bus_device_spidevice_obj___enter__); + +//| def __exit__(self) -> None: +//| """Ends a SPI transaction by deasserting chip select. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t adafruit_bus_device_spidevice_obj___exit__(size_t n_args, const mp_obj_t *args) { common_hal_adafruit_bus_device_spidevice_exit(MP_OBJ_TO_PTR(args[0])); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_spidevice___exit___obj, 4, 4, adafruit_bus_device_spidevice_obj___exit__); +//| spi: busio.SPI +//| """The underlying SPI bus. Useful for weird uses like clocking an SD card without chip select. +//| +//| You shouldn't normally need this.""" +//| +STATIC mp_obj_t adafruit_bus_device_spidevice_obj_get_spi(mp_obj_t self_in) { + adafruit_bus_device_spidevice_obj_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_adafruit_bus_device_spidevice_get_spi(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(adafruit_bus_device_spidevice_get_spi_obj, adafruit_bus_device_spidevice_obj_get_spi); + +const mp_obj_property_t adafruit_bus_device_spidevice_spi_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&adafruit_bus_device_spidevice_get_spi_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + STATIC const mp_rom_map_elem_t adafruit_bus_device_spidevice_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&adafruit_bus_device_spidevice___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&adafruit_bus_device_spidevice___exit___obj) }, + + { MP_ROM_QSTR(MP_QSTR_spi), MP_ROM_PTR(&adafruit_bus_device_spidevice_spi_obj) }, }; STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_spidevice_locals_dict, adafruit_bus_device_spidevice_locals_dict_table); diff --git a/shared-bindings/adafruit_bus_device/SPIDevice.h b/shared-bindings/adafruit_bus_device/SPIDevice.h index 5596b157f0..baa9ec464a 100644 --- a/shared-bindings/adafruit_bus_device/SPIDevice.h +++ b/shared-bindings/adafruit_bus_device/SPIDevice.h @@ -44,7 +44,8 @@ extern const mp_obj_type_t adafruit_bus_device_spidevice_type; // Initializes the hardware peripheral. extern void common_hal_adafruit_bus_device_spidevice_construct(adafruit_bus_device_spidevice_obj_t *self, busio_spi_obj_t *spi, digitalio_digitalinout_obj_t *cs, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t extra_clocks); -extern void common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spidevice_obj_t *self); +extern mp_obj_t common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spidevice_obj_t *self); extern void common_hal_adafruit_bus_device_spidevice_exit(adafruit_bus_device_spidevice_obj_t *self); +extern mp_obj_t common_hal_adafruit_bus_device_spidevice_get_spi(adafruit_bus_device_spidevice_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_SPIDEVICE_H diff --git a/shared-module/adafruit_bus_device/SPIDevice.c b/shared-module/adafruit_bus_device/SPIDevice.c index e489fc7c07..5c1a69b128 100644 --- a/shared-module/adafruit_bus_device/SPIDevice.c +++ b/shared-module/adafruit_bus_device/SPIDevice.c @@ -41,7 +41,7 @@ void common_hal_adafruit_bus_device_spidevice_construct(adafruit_bus_device_spid self->chip_select = cs; } -void common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spidevice_obj_t *self) { +mp_obj_t common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spidevice_obj_t *self) { bool success = false; while (!success) { success = common_hal_busio_spi_try_lock(self->spi); @@ -54,6 +54,7 @@ void common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spidevic if (self->chip_select != MP_OBJ_NULL) { common_hal_digitalio_digitalinout_set_value(MP_OBJ_TO_PTR(self->chip_select), false); } + return self->spi; } void common_hal_adafruit_bus_device_spidevice_exit(adafruit_bus_device_spidevice_obj_t *self) { @@ -83,3 +84,7 @@ void common_hal_adafruit_bus_device_spidevice_exit(adafruit_bus_device_spidevice common_hal_busio_spi_unlock(self->spi); } + +mp_obj_t common_hal_adafruit_bus_device_spidevice_get_spi(adafruit_bus_device_spidevice_obj_t *self) { + return self->spi; +} From 2afb58f2e7563505ab744df0374205f8a0fc5380 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 2 Feb 2021 19:35:23 +0100 Subject: [PATCH 21/78] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 24 ++++++++++-------------- locale/cs.po | 24 ++++++++++-------------- locale/de_DE.po | 24 ++++++++++-------------- locale/el.po | 24 ++++++++++-------------- locale/es.po | 24 ++++++++++-------------- locale/fil.po | 24 ++++++++++-------------- locale/fr.po | 30 ++++++++++++++++-------------- locale/hi.po | 24 ++++++++++-------------- locale/it_IT.po | 24 ++++++++++-------------- locale/ja.po | 24 ++++++++++-------------- locale/ko.po | 24 ++++++++++-------------- locale/nl.po | 24 ++++++++++-------------- locale/pl.po | 24 ++++++++++-------------- locale/pt_BR.po | 30 ++++++++++++++++-------------- locale/sv.po | 30 ++++++++++++++++-------------- locale/zh_Latn_pinyin.po | 30 ++++++++++++++++-------------- 16 files changed, 184 insertions(+), 224 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 4bf5baded5..3b35cd7684 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -642,6 +642,10 @@ msgstr "" "Tidak dapat melakukan reset ke bootloader karena tidak ada bootloader yang " "terisi" +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "Tidak dapat menetapkan nilai saat arah input." @@ -884,7 +888,7 @@ msgstr "Channel EXTINT sedang digunakan" msgid "Error in regex" msgstr "Error pada regex" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -943,7 +947,7 @@ msgstr "FFT didefinisikan hanya untuk ndarrays" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1316,7 +1320,7 @@ msgstr "security_mode tidak valid" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1324,10 +1328,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "Suara tidak valid" @@ -1344,10 +1344,6 @@ msgstr "File wave tidak valid" msgid "Invalid word/bit length" msgstr "Panjang kata/bit tidak valid" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "Panjang kunci harus 16, 24, atau 32 byte" @@ -1674,7 +1670,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2208,7 +2204,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "Tipe urf nrfx tak sesuai" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2517,7 +2513,7 @@ msgstr "" msgid "buffer too small" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index 99dd05e9e7..0cf77058c3 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -632,6 +632,10 @@ msgstr "" msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "" @@ -868,7 +872,7 @@ msgstr "" msgid "Error in regex" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -927,7 +931,7 @@ msgstr "" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1298,7 +1302,7 @@ msgstr "" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1306,10 +1310,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "" @@ -1326,10 +1326,6 @@ msgstr "" msgid "Invalid word/bit length" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "" @@ -1650,7 +1646,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2170,7 +2166,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2469,7 +2465,7 @@ msgstr "" msgid "buffer too small" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 62d67443bb..980de84e7b 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -638,6 +638,10 @@ msgstr "Kann '/' nicht remounten when USB aktiv ist." msgid "Cannot reset into bootloader because no bootloader is present." msgstr "Reset zum bootloader nicht möglich da bootloader nicht vorhanden." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "Der Wert kann nicht gesetzt werden, wenn die Richtung input ist." @@ -880,7 +884,7 @@ msgstr "EXTINT Kanal ist schon in Benutzung" msgid "Error in regex" msgstr "Fehler in regex" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -940,7 +944,7 @@ msgstr "FFT ist nur für ndarrays definiert" msgid "FFT is implemented for linear arrays only" msgstr "FFT ist nur für lineare Arrays implementiert" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "SSL Handshake fehlgeschlagen" @@ -1315,7 +1319,7 @@ msgstr "Ungültiger security_mode" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1323,10 +1327,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "Ungültige Stimme" @@ -1343,10 +1343,6 @@ msgstr "Ungültige wave Datei" msgid "Invalid word/bit length" msgstr "Ungültige Wort- / Bitlänge" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "Der Schlüssel muss 16, 24 oder 32 Byte lang sein" @@ -1675,7 +1671,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2212,7 +2208,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "Unerwarteter nrfx uuid-Typ" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2526,7 +2522,7 @@ msgstr "Puffersegmente müssen gleich lang sein" msgid "buffer too small" msgstr "Der Puffer ist zu klein" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/el.po b/locale/el.po index 6de90c1dfb..0e53c33781 100644 --- a/locale/el.po +++ b/locale/el.po @@ -629,6 +629,10 @@ msgstr "" msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "" @@ -865,7 +869,7 @@ msgstr "" msgid "Error in regex" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -924,7 +928,7 @@ msgstr "" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1295,7 +1299,7 @@ msgstr "" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1303,10 +1307,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "" @@ -1323,10 +1323,6 @@ msgstr "" msgid "Invalid word/bit length" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "" @@ -1647,7 +1643,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2167,7 +2163,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2466,7 +2462,7 @@ msgstr "" msgid "buffer too small" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/es.po b/locale/es.po index c174b5b2b3..6be69f5b6d 100644 --- a/locale/es.po +++ b/locale/es.po @@ -642,6 +642,10 @@ msgstr "No se puede volver a montar '/' cuando el USB esta activo." msgid "Cannot reset into bootloader because no bootloader is present." msgstr "No se puede reiniciar a bootloader porque no hay bootloader presente." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "No se puede asignar un valor cuando la dirección es input." @@ -882,7 +886,7 @@ msgstr "El canal EXTINT ya está siendo utilizado" msgid "Error in regex" msgstr "Error en regex" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -941,7 +945,7 @@ msgstr "FFT se define solo para ndarrays" msgid "FFT is implemented for linear arrays only" msgstr "FFT solo esta implementado para arrays lineales" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "Fallo en saludo SSL" @@ -1315,7 +1319,7 @@ msgstr "'security_mode' no válido" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1323,10 +1327,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "Voz inválida" @@ -1343,10 +1343,6 @@ msgstr "Archivo wave inválido" msgid "Invalid word/bit length" msgstr "Tamaño no válido de palabra/bit" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "La llave debe tener 16, 24 o 32 bytes de longitud" @@ -1673,7 +1669,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "Se acabaron los enchufes" @@ -2216,7 +2212,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "Tipo de uuid nrfx inesperado" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Error no manejado de ESP TLS %d %d %x %d" @@ -2526,7 +2522,7 @@ msgstr "Las secciones del buffer necesitan tener longitud igual" msgid "buffer too small" msgstr "buffer demasiado pequeño" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "búfer muy pequeño para los bytes solicitados" diff --git a/locale/fil.po b/locale/fil.po index 50697437fe..eeb9a1432d 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -636,6 +636,10 @@ msgstr "Hindi ma-remount '/' kapag aktibo ang USB." msgid "Cannot reset into bootloader because no bootloader is present." msgstr "Hindi ma-reset sa bootloader dahil walang bootloader." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "Hindi ma i-set ang value kapag ang direksyon ay input." @@ -876,7 +880,7 @@ msgstr "Ginagamit na ang EXTINT channel" msgid "Error in regex" msgstr "May pagkakamali sa REGEX" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -937,7 +941,7 @@ msgstr "" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1310,7 +1314,7 @@ msgstr "" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1318,10 +1322,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "" @@ -1338,10 +1338,6 @@ msgstr "May hindi tama sa wave file" msgid "Invalid word/bit length" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "" @@ -1665,7 +1661,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2188,7 +2184,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "hindi inaasahang indent" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2497,7 +2493,7 @@ msgstr "aarehas na haba dapat ang buffer slices" msgid "buffer too small" msgstr "masyadong maliit ang buffer" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 23c028da94..b24122c036 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -654,6 +654,10 @@ msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" "Ne peut être redémarré vers le bootloader car il n'y a pas de bootloader." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "" @@ -897,7 +901,7 @@ msgstr "Canal EXTINT déjà utilisé" msgid "Error in regex" msgstr "Erreur dans l'expression régulière" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "Erreur : Impossible de lier" @@ -957,7 +961,7 @@ msgstr "La FFT est définie uniquement pour les ndarrays" msgid "FFT is implemented for linear arrays only" msgstr "FFT n'est implémenté que pour les tableaux linéaires" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "Échec du handshake SSL" @@ -1332,7 +1336,7 @@ msgstr "'security_mode' invalide" msgid "Invalid size" msgstr "Taille invalide" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "Socket non valide pour TLS" @@ -1340,10 +1344,6 @@ msgstr "Socket non valide pour TLS" msgid "Invalid state" msgstr "État invalide" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "Utilisation incorrecte de socket TLS" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "Voix invalide" @@ -1360,10 +1360,6 @@ msgstr "Fichier WAVE invalide" msgid "Invalid word/bit length" msgstr "Longueur de mot / bit invalide" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "Problème en activant SO_REUSEADDR" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "La clé doit comporter 16, 24 ou 32 octets" @@ -1690,7 +1686,7 @@ msgstr "Timeout de l'opération" msgid "Out of memory" msgstr "Hors de mémoire" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "Plus de sockets" @@ -2239,7 +2235,7 @@ msgstr "Écriture impossible vers sleep_memory." msgid "Unexpected nrfx uuid type" msgstr "Type inattendu pour l'uuid nrfx" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Erreur ESP TLS non gérée %d %d %x %d" @@ -2551,7 +2547,7 @@ msgstr "les tranches de tampon doivent être de longueurs égales" msgid "buffer too small" msgstr "tampon trop petit" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "tampon trop petit pour le nombre d'octets demandé" @@ -4267,6 +4263,12 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "Invalid use of TLS Socket" +#~ msgstr "Utilisation incorrecte de socket TLS" + +#~ msgid "Issue setting SO_REUSEADDR" +#~ msgstr "Problème en activant SO_REUSEADDR" + #~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" #~ msgstr "" #~ "Les broches d'adresse %d et les broches RVB %d indiquent une hauteur de " diff --git a/locale/hi.po b/locale/hi.po index ec1317580b..6a41118c74 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -629,6 +629,10 @@ msgstr "" msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "" @@ -865,7 +869,7 @@ msgstr "" msgid "Error in regex" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -924,7 +928,7 @@ msgstr "" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1295,7 +1299,7 @@ msgstr "" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1303,10 +1307,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "" @@ -1323,10 +1323,6 @@ msgstr "" msgid "Invalid word/bit length" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "" @@ -1647,7 +1643,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2167,7 +2163,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2466,7 +2462,7 @@ msgstr "" msgid "buffer too small" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index ff36307f94..a28293a62f 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -637,6 +637,10 @@ msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" "Impossibile resettare nel bootloader poiché nessun bootloader è presente." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "non si può impostare un valore quando direzione è input" @@ -876,7 +880,7 @@ msgstr "Canale EXTINT già in uso" msgid "Error in regex" msgstr "Errore nella regex" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -937,7 +941,7 @@ msgstr "" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1312,7 +1316,7 @@ msgstr "" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1320,10 +1324,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "" @@ -1341,10 +1341,6 @@ msgstr "File wave non valido" msgid "Invalid word/bit length" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "" @@ -1670,7 +1666,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2200,7 +2196,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "indentazione inaspettata" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2503,7 +2499,7 @@ msgstr "slice del buffer devono essere della stessa lunghezza" msgid "buffer too small" msgstr "buffer troppo piccolo" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index 69bbcb08fc..63256ec21c 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -638,6 +638,10 @@ msgstr "USBがアクティブの時に'/'を再マウントできません" msgid "Cannot reset into bootloader because no bootloader is present." msgstr "ブートローダが存在しないためブートローダへとリセットできません" +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "方向がinputのときは値を設定できません" @@ -876,7 +880,7 @@ msgstr "EXTINTチャネルはすでに使用されています" msgid "Error in regex" msgstr "正規表現にエラーがあります" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -935,7 +939,7 @@ msgstr "FFTはndarrayでのみ使えます" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1308,7 +1312,7 @@ msgstr "不正なsecurity_mode" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1316,10 +1320,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "不正なボイス" @@ -1336,10 +1336,6 @@ msgstr "不正なwaveファイル" msgid "Invalid word/bit length" msgstr "不正なワード/ビット長" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "Keyの長さは、16, 24, 32バイトのいずれかでなければなりません" @@ -1662,7 +1658,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2190,7 +2186,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "想定されていないnrfx UUID型" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2489,7 +2485,7 @@ msgstr "バッファのスライスは同じ長さでなければなりません msgid "buffer too small" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index a761e9ab9d..9e52a29ca5 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -632,6 +632,10 @@ msgstr "" msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "" @@ -868,7 +872,7 @@ msgstr "" msgid "Error in regex" msgstr "Regex에 오류가 있습니다." -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -927,7 +931,7 @@ msgstr "" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1298,7 +1302,7 @@ msgstr "" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1306,10 +1310,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "" @@ -1326,10 +1326,6 @@ msgstr "" msgid "Invalid word/bit length" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "" @@ -1650,7 +1646,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2171,7 +2167,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2470,7 +2466,7 @@ msgstr "" msgid "buffer too small" msgstr "" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index e52d73356c..ba03299ead 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -636,6 +636,10 @@ msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" "Kan niet resetten naar bootloader omdat er geen bootloader aanwezig is." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "Kan de waarde niet toewijzen als de richting input is." @@ -876,7 +880,7 @@ msgstr "EXTINT kanaal al in gebruik" msgid "Error in regex" msgstr "Fout in regex" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -935,7 +939,7 @@ msgstr "FFT alleen voor ndarrays gedefineerd" msgid "FFT is implemented for linear arrays only" msgstr "FFT is alleen geïmplementeerd voor lineaire arrays" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "SSL handdruk mislukt" @@ -1309,7 +1313,7 @@ msgstr "Ongeldige security_mode" msgid "Invalid size" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1317,10 +1321,6 @@ msgstr "" msgid "Invalid state" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "Ongeldige stem" @@ -1337,10 +1337,6 @@ msgstr "Ongeldig wave bestand" msgid "Invalid word/bit length" msgstr "Ongeldig woord/bit lengte" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "Sleutel moet 16, 24, of 32 bytes lang zijn" @@ -1667,7 +1663,7 @@ msgstr "" msgid "Out of memory" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "Geen sockets meer beschikbaar" @@ -2209,7 +2205,7 @@ msgstr "Kan niet naar sleep_memory schrijven." msgid "Unexpected nrfx uuid type" msgstr "Onverwacht mrfx uuid type" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Niet behandelde ESP TLS fout %d %d %x %d" @@ -2519,7 +2515,7 @@ msgstr "buffer slices moeten van gelijke grootte zijn" msgid "buffer too small" msgstr "buffer te klein" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "buffer te klein voor gevraagde bytes" diff --git a/locale/pl.po b/locale/pl.po index 5c9fcc3871..06c397d029 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -636,6 +636,10 @@ msgstr "Nie można przemontować '/' gdy USB działa." msgid "Cannot reset into bootloader because no bootloader is present." msgstr "Nie można zrestartować -- nie ma bootloadera." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "Nie można ustawić wartości w trybie wejścia." @@ -876,7 +880,7 @@ msgstr "Kanał EXTINT w użyciu" msgid "Error in regex" msgstr "Błąd w regex" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "" @@ -935,7 +939,7 @@ msgstr "" msgid "FFT is implemented for linear arrays only" msgstr "" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "" @@ -1308,7 +1312,7 @@ msgstr "Nieprawidłowy security_mode" msgid "Invalid size" msgstr "Nieprawidłowy rozmiar" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "" @@ -1316,10 +1320,6 @@ msgstr "" msgid "Invalid state" msgstr "Nieprawidłowy stan" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "" @@ -1336,10 +1336,6 @@ msgstr "Zły plik wave" msgid "Invalid word/bit length" msgstr "Niepoprawna długość słowa/bitu" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "Klucz musi mieć długość 16, 24 lub 32 bajtów" @@ -1661,7 +1657,7 @@ msgstr "" msgid "Out of memory" msgstr "Brak pamięci" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "" @@ -2181,7 +2177,7 @@ msgstr "" msgid "Unexpected nrfx uuid type" msgstr "Nieoczekiwany typ nrfx uuid" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" @@ -2486,7 +2482,7 @@ msgstr "fragmenty bufora muszą mieć tę samą długość" msgid "buffer too small" msgstr "zbyt mały bufor" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index b6bb9d5e5e..18e469c6ac 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -654,6 +654,10 @@ msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" "Não é possível redefinir para o bootloader porque o mesmo não está presente." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "Não é possível definir o valor quando a direção é inserida." @@ -894,7 +898,7 @@ msgstr "Canal EXTINT em uso" msgid "Error in regex" msgstr "Erro no regex" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "Erro: Falha na vinculação" @@ -953,7 +957,7 @@ msgstr "O FFT é definido apenas para ndarrays" msgid "FFT is implemented for linear arrays only" msgstr "O FFT é implementado apenas para matrizes lineares" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "Houve uma falha no handshake do SSL" @@ -1327,7 +1331,7 @@ msgstr "O Security_mode é inválido" msgid "Invalid size" msgstr "Tamanho inválido" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "Soquete inválido para o TLS" @@ -1335,10 +1339,6 @@ msgstr "Soquete inválido para o TLS" msgid "Invalid state" msgstr "Estado inválido" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "Uso inválido do soquete TLS" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "A voz é inválida" @@ -1355,10 +1355,6 @@ msgstr "Aqruivo de ondas inválido" msgid "Invalid word/bit length" msgstr "O comprimento do bit/palavra são inválidos" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "Problema na configuração do SO_REUSEADDR" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "A chave deve ter 16, 24 ou 32 bytes de comprimento" @@ -1684,7 +1680,7 @@ msgstr "A operação expirou" msgid "Out of memory" msgstr "Sem memória" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "Sem soquetes" @@ -2235,7 +2231,7 @@ msgstr "Não foi possível escrever no sleep_memory." msgid "Unexpected nrfx uuid type" msgstr "Tipo uuid nrfx inesperado" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Erro não tratado do ESP TLS %d %d %x %d" @@ -2546,7 +2542,7 @@ msgstr "as fatias do buffer devem ter o mesmo comprimento" msgid "buffer too small" msgstr "o buffer é muito pequeno" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "o buffer é pequeno demais para os bytes requisitados" @@ -4256,6 +4252,12 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "Invalid use of TLS Socket" +#~ msgstr "Uso inválido do soquete TLS" + +#~ msgid "Issue setting SO_REUSEADDR" +#~ msgstr "Problema na configuração do SO_REUSEADDR" + #~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" #~ msgstr "" #~ "%d endereços dos pinos e %d pinos rgb indicam uma altura do %d, não %d" diff --git a/locale/sv.po b/locale/sv.po index 32c7af7adf..031c34f144 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -641,6 +641,10 @@ msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" "Det går inte att återställa till bootloader eftersom bootloader saknas." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "Kan inte sätta värde när riktning är input." @@ -881,7 +885,7 @@ msgstr "EXTINT-kanalen används redan" msgid "Error in regex" msgstr "Fel i regex" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "Fel: Bind misslyckades" @@ -940,7 +944,7 @@ msgstr "FFT är enbart definierade för ndarrays" msgid "FFT is implemented for linear arrays only" msgstr "FTT är enbart implementerad för linjära matriser" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "Misslyckad SSL-handskakning" @@ -1313,7 +1317,7 @@ msgstr "Ogiltigt säkerhetsläge" msgid "Invalid size" msgstr "Ogiltig storlek" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "Ogiltig socket för TLS" @@ -1321,10 +1325,6 @@ msgstr "Ogiltig socket för TLS" msgid "Invalid state" msgstr "Ogiltigt tillstånd" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "Ogiltig användning av TLS Socket" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "Ogiltig kanal" @@ -1341,10 +1341,6 @@ msgstr "Ogiltig wave-fil" msgid "Invalid word/bit length" msgstr "Ogiltig word-/bitlängd" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "Misslyckades att sätta SO_REUSEADDR" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "Nyckeln måste vara 16, 24 eller 32 byte lång" @@ -1671,7 +1667,7 @@ msgstr "Åtgärden orsakade timeout" msgid "Out of memory" msgstr "Slut på minne" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "Slut på sockets" @@ -2212,7 +2208,7 @@ msgstr "Det gick inte att skriva till sleep_memory." msgid "Unexpected nrfx uuid type" msgstr "Oväntad nrfx uuid-typ" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Ej hanterat ESP TLS-fel %d-%d-%x-%d" @@ -2519,7 +2515,7 @@ msgstr "buffertsegmenten måste vara lika långa" msgid "buffer too small" msgstr "buffert för liten" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "buffert för liten för begärd längd" @@ -4218,6 +4214,12 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "Invalid use of TLS Socket" +#~ msgstr "Ogiltig användning av TLS Socket" + +#~ msgid "Issue setting SO_REUSEADDR" +#~ msgstr "Misslyckades att sätta SO_REUSEADDR" + #~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" #~ msgstr "%d adresspinnar och %d RGB-pinnar indikerar en höjd av %d, inte %d" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 968315704c..29feefac60 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -643,6 +643,10 @@ msgstr "USB jīhuó shí wúfǎ chóngxīn bǎng ding '/'." msgid "Cannot reset into bootloader because no bootloader is present." msgstr "Wúfǎ chóng zhì wèi bootloader, yīnwèi méiyǒu bootloader cúnzài." +#: ports/esp32s2/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." msgstr "Dāng fāngxiàng xiàng nèi shí, bùnéng shèzhì gāi zhí." @@ -881,7 +885,7 @@ msgstr "EXTINT píndào yǐjīng shǐyòng" msgid "Error in regex" msgstr "Zhèngzé biǎodá shì cuòwù" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" msgstr "cuò wù: bǎng dìng shī bài" @@ -940,7 +944,7 @@ msgstr "FFT jǐn wéi ndarrays dìng yì" msgid "FFT is implemented for linear arrays only" msgstr "FFT jǐn shì yòng yú xiàn xìng zhèn liè" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" msgstr "SSL wòshǒu shībài" @@ -1313,7 +1317,7 @@ msgstr "Ānquán móshì wúxiào" msgid "Invalid size" msgstr "dà xiǎo wú xiào" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLContext.c msgid "Invalid socket for TLS" msgstr "TLS de chā zuò wú xiào" @@ -1321,10 +1325,6 @@ msgstr "TLS de chā zuò wú xiào" msgid "Invalid state" msgstr "wú xiào zhuàng tài" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Invalid use of TLS Socket" -msgstr "TLS tào jiē zì de wú xiào shǐ yòng" - #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" msgstr "Yǔyīn wúxiào" @@ -1341,10 +1341,6 @@ msgstr "Wúxiào de làng làngcháo wénjiàn" msgid "Invalid word/bit length" msgstr "Wúxiào de zì/wèi chángdù" -#: ports/esp32s2/common-hal/socketpool/Socket.c -msgid "Issue setting SO_REUSEADDR" -msgstr "wèn tí shè zhì SO_REUSEADDR" - #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" msgstr "mì yào bì xū wéi 16, 24 huò 32 zì jié cháng" @@ -1671,7 +1667,7 @@ msgstr "cāo zuò yǐ fēn shí" msgid "Out of memory" msgstr "nèi cún bù zú" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" msgstr "tào jiē zì wài" @@ -2207,7 +2203,7 @@ msgstr "wú fǎ xiě rù sleep_memory。" msgid "Unexpected nrfx uuid type" msgstr "Yìwài de nrfx uuid lèixíng" -#: ports/esp32s2/common-hal/socketpool/Socket.c +#: ports/esp32s2/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Wèi chǔlǐ de ESP TLS cuòwù %d %d %x %d" @@ -2515,7 +2511,7 @@ msgstr "huǎnchōng qū qiēpiàn bìxū chángdù xiāngděng" msgid "buffer too small" msgstr "huǎnchōng qū tài xiǎo" -#: shared-bindings/socketpool/Socket.c +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" msgstr "huǎn chōng qū tài xiǎo, duì yú qǐng qiú de zì jié" @@ -4212,6 +4208,12 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "Invalid use of TLS Socket" +#~ msgstr "TLS tào jiē zì de wú xiào shǐ yòng" + +#~ msgid "Issue setting SO_REUSEADDR" +#~ msgstr "wèn tí shè zhì SO_REUSEADDR" + #~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" #~ msgstr "" #~ "%d dìzhǐ yǐn jiǎo hé %d rgb yǐn jiǎo jiāng gāodù biǎoshì wèi %d, ér bùshì " From 2656c84b01197835f277bf624f992e7931f133df Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 3 Feb 2021 05:49:40 +0700 Subject: [PATCH 22/78] Initial commit. Edited error messages in .c files --- ports/atmel-samd/common-hal/busio/I2C.c | 2 +- ports/esp32s2/common-hal/busio/I2C.c | 2 +- ports/mimxrt10xx/common-hal/busio/I2C.c | 2 +- ports/nrf/common-hal/busio/I2C.c | 2 +- ports/raspberrypi/common-hal/busio/I2C.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index ffe74a2743..2551f7bf17 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -97,7 +97,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (!gpio_get_pin_level(sda->number) || !gpio_get_pin_level(scl->number)) { reset_pin_number(sda->number); reset_pin_number(scl->number); - mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); + mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); } #endif diff --git a/ports/esp32s2/common-hal/busio/I2C.c b/ports/esp32s2/common-hal/busio/I2C.c index 772262d0a5..8372eb8c30 100644 --- a/ports/esp32s2/common-hal/busio/I2C.c +++ b/ports/esp32s2/common-hal/busio/I2C.c @@ -85,7 +85,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (gpio_get_level(sda->number) == 0 || gpio_get_level(scl->number) == 0) { reset_pin_number(sda->number); reset_pin_number(scl->number); - mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); + mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); } #endif diff --git a/ports/mimxrt10xx/common-hal/busio/I2C.c b/ports/mimxrt10xx/common-hal/busio/I2C.c index aaa2549a81..c8daddc4bb 100644 --- a/ports/mimxrt10xx/common-hal/busio/I2C.c +++ b/ports/mimxrt10xx/common-hal/busio/I2C.c @@ -110,7 +110,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if( !GPIO_PinRead(sda->gpio, sda->number) || !GPIO_PinRead(scl->gpio, scl->number)) { common_hal_reset_pin(sda); common_hal_reset_pin(scl); - mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); + mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); } #endif diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index 37cb192df8..654fa857ff 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -131,7 +131,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t * if (!nrf_gpio_pin_read(sda->number) || !nrf_gpio_pin_read(scl->number)) { reset_pin_number(sda->number); reset_pin_number(scl->number); - mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); + mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); } #endif diff --git a/ports/raspberrypi/common-hal/busio/I2C.c b/ports/raspberrypi/common-hal/busio/I2C.c index fa49e375e2..26a7f3807f 100644 --- a/ports/raspberrypi/common-hal/busio/I2C.c +++ b/ports/raspberrypi/common-hal/busio/I2C.c @@ -90,7 +90,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (!gpio_get(sda->number) || !gpio_get(scl->number)) { reset_pin_number(sda->number); reset_pin_number(scl->number); - mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); + mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); } #endif From 042c09dab233f629e0faffbab75da9b12138c3f0 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 3 Feb 2021 05:57:03 +0700 Subject: [PATCH 23/78] Ran make translate to generate circuitpython.pot --- locale/circuitpython.pot | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 4a43759a7b..529bc6d52c 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -1535,6 +1535,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1866,12 +1872,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" From e699a598905c95eb8249e89e436030376a518239 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 3 Feb 2021 11:01:33 +0700 Subject: [PATCH 24/78] hack to fix 3986 just a proof to show that issue analysis is correct --- supervisor/shared/background_callback.c | 8 ++++++-- supervisor/shared/usb/usb.c | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c index 288c9a4df2..44709b60b5 100644 --- a/supervisor/shared/background_callback.c +++ b/supervisor/shared/background_callback.c @@ -33,7 +33,7 @@ #include "supervisor/shared/tick.h" #include "shared-bindings/microcontroller/__init__.h" -STATIC volatile background_callback_t *callback_head, *callback_tail; +STATIC volatile background_callback_t * volatile callback_head, * volatile callback_tail; #define CALLBACK_CRITICAL_BEGIN (common_hal_mcu_disable_interrupts()) #define CALLBACK_CRITICAL_END (common_hal_mcu_enable_interrupts()) @@ -50,7 +50,6 @@ void background_callback_add_core(background_callback_t *cb) { cb->prev = (background_callback_t*)callback_tail; if (callback_tail) { callback_tail->next = cb; - cb->prev = (background_callback_t*)callback_tail; } if (!callback_head) { callback_head = cb; @@ -106,6 +105,9 @@ void background_callback_end_critical_section() { CALLBACK_CRITICAL_END; } +extern background_callback_t usb_callback; +extern void usb_background_do(void* unused); + void background_callback_reset() { CALLBACK_CRITICAL_BEGIN; background_callback_t *cb = (background_callback_t*)callback_head; @@ -118,6 +120,8 @@ void background_callback_reset() { callback_tail = NULL; in_background_callback = false; CALLBACK_CRITICAL_END; + + background_callback_add(&usb_callback, usb_background_do, NULL); } void background_callback_gc_collect(void) { diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 07c6aee6c1..af34f25987 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -93,13 +93,13 @@ void usb_background(void) { } } -static background_callback_t usb_callback; -static void usb_background_do(void* unused) { +/*static*/ background_callback_t usb_callback; +/*static*/ void usb_background_do(void* unused) { usb_background(); } void usb_irq_handler(void) { - tud_int_handler(0); + tud_int_handler(0); \ background_callback_add(&usb_callback, usb_background_do, NULL); } From 4eb396806c9423d43ba1ac2d4601737f03ce7ede Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 3 Feb 2021 11:47:56 +0700 Subject: [PATCH 25/78] Updated trinket_m0 make file to squeeze all translations as per Dan Halbert. --- ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk index 735d422973..1f88fbeade 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -11,14 +11,5 @@ LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 SUPEROPT_VM = 0 -endif +CFLAGS_INLINE_LIMIT = 45 From a4fa9219a903ada4fcd55a078201adf059d76fb4 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Tue, 2 Feb 2021 22:59:10 +0000 Subject: [PATCH 26/78] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (955 of 955 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 18e469c6ac..ccbe421910 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-02-01 17:50+0000\n" +"PO-Revision-Date: 2021-02-03 12:57+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -656,7 +656,7 @@ msgstr "" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Cannot set socket options" -msgstr "" +msgstr "Não foi possível definir as opções do socket" #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." @@ -1844,7 +1844,7 @@ msgstr "Houve um erro na inicialização do RNG" #: ports/nrf/common-hal/busio/UART.c msgid "RS485 Not yet supported on this device" -msgstr "" +msgstr "Ainda não há suporte para o RS485 neste dispositivo" #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c From 7083161261f839f6d5affe9ea5682ee159e41a53 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 3 Feb 2021 13:57:12 +0100 Subject: [PATCH 27/78] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 15 +++++++++------ locale/cs.po | 12 ++++++------ locale/de_DE.po | 15 +++++++++------ locale/el.po | 12 ++++++------ locale/es.po | 15 +++++++++------ locale/fil.po | 15 +++++++++------ locale/fr.po | 15 +++++++++------ locale/hi.po | 12 ++++++------ locale/it_IT.po | 15 +++++++++------ locale/ja.po | 15 +++++++++------ locale/ko.po | 12 ++++++------ locale/nl.po | 15 +++++++++------ locale/pl.po | 15 +++++++++------ locale/pt_BR.po | 15 +++++++++------ locale/sv.po | 15 +++++++++------ locale/zh_Latn_pinyin.po | 15 +++++++++------ 16 files changed, 132 insertions(+), 96 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 3b35cd7684..c592acf9f7 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -1556,6 +1556,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Tidak ada pull-down pada pin; 1Mohm direkomendasikan" @@ -1899,12 +1905,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA atau SCL membutuhkan pull up" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4203,6 +4203,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA atau SCL membutuhkan pull up" + #~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" #~ msgstr "pin alamat %d dan pin rgb %d menunjukkan tinggi %d, bukan %d" diff --git a/locale/cs.po b/locale/cs.po index 0cf77058c3..870b82c732 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -1538,6 +1538,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1869,12 +1875,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" diff --git a/locale/de_DE.po b/locale/de_DE.po index 980de84e7b..ad0fdba702 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -1557,6 +1557,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Kein Pulldown Widerstand am Pin; 1Mohm wird vorgeschlagen" @@ -1897,12 +1903,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA oder SCL brauchen pull up" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4240,6 +4240,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA oder SCL brauchen pull up" + #~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" #~ msgstr "" #~ "%d Adress-Pins und %d rgb-Pins zeigen eine Höhe von %d, nicht von %d" diff --git a/locale/el.po b/locale/el.po index 0e53c33781..fe281db4e4 100644 --- a/locale/el.po +++ b/locale/el.po @@ -1535,6 +1535,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1866,12 +1872,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" diff --git a/locale/es.po b/locale/es.po index 6be69f5b6d..0a02df3b56 100644 --- a/locale/es.po +++ b/locale/es.po @@ -1555,6 +1555,12 @@ msgstr "No hay una red con ese ssid" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "No hay pulldown en el pin; 1Mohm recomendado" @@ -1901,12 +1907,6 @@ msgstr "¡Corriendo en modo seguro! " msgid "SD card CSD format not supported" msgstr "Sin capacidad para formato CSD para tarjeta SD" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA o SCL necesitan una pull up" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4226,6 +4226,9 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA o SCL necesitan una pull up" + #~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" #~ msgstr "" #~ "%d pines de dirección y %d pines rgb indican una altura de %d, no de %d" diff --git a/locale/fil.po b/locale/fil.po index eeb9a1432d..71d5ef8f1f 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -1550,6 +1550,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1886,12 +1892,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "Kailangan ng pull up resistors ang SDA o SCL" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4205,6 +4205,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "Kailangan ng pull up resistors ang SDA o SCL" + #~ msgid "tuple index out of range" #~ msgstr "indeks ng tuple wala sa sakop" diff --git a/locale/fr.po b/locale/fr.po index b24122c036..895c87f5ec 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -1572,6 +1572,12 @@ msgstr "Aucun réseau avec ce ssid" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Pas de pulldown sur la broche ; 1Mohm recommandé" @@ -1923,12 +1929,6 @@ msgstr "Exécution en mode sécurisé! " msgid "SD card CSD format not supported" msgstr "Le format de carte SD CSD n'est pas supporté" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA ou SCL a besoin d'une résistance de tirage ('pull up')" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4263,6 +4263,9 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA ou SCL a besoin d'une résistance de tirage ('pull up')" + #~ msgid "Invalid use of TLS Socket" #~ msgstr "Utilisation incorrecte de socket TLS" diff --git a/locale/hi.po b/locale/hi.po index 6a41118c74..fe77821334 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -1535,6 +1535,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1866,12 +1872,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" diff --git a/locale/it_IT.po b/locale/it_IT.po index a28293a62f..1c91b08927 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -1554,6 +1554,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1896,12 +1902,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA o SCL necessitano un pull-up" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4213,6 +4213,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA o SCL necessitano un pull-up" + #~ msgid "tuple index out of range" #~ msgstr "indice della tupla fuori intervallo" diff --git a/locale/ja.po b/locale/ja.po index 63256ec21c..0fb8a6f481 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -1548,6 +1548,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "ピンにプルダウンがありません。1Mオーム推奨" @@ -1882,12 +1888,6 @@ msgstr "セーフモードで実行中! " msgid "SD card CSD format not supported" msgstr "SDカードのCSDフォーマットは非対応" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDAとSCLにプルアップが必要" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4181,6 +4181,9 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDAとSCLにプルアップが必要" + #~ msgid "" #~ "\n" #~ "Code done running. Waiting for reload.\n" diff --git a/locale/ko.po b/locale/ko.po index 9e52a29ca5..ce662ad5f4 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -1538,6 +1538,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1869,12 +1875,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" diff --git a/locale/nl.po b/locale/nl.po index ba03299ead..821f338cac 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -1549,6 +1549,12 @@ msgstr "Geen netwerk met dat SSID gevonden" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Geen pulldown op pin; 1MOhm aangeraden" @@ -1898,12 +1904,6 @@ msgstr "Veilige modus wordt uitgevoerd! " msgid "SD card CSD format not supported" msgstr "SD kaart CSD formaat niet ondersteund" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA of SCL hebben een pullup nodig" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4214,6 +4214,9 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA of SCL hebben een pullup nodig" + #~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" #~ msgstr "%d adres pins en %d RGB pins geven een hoogte van %d aan, niet %d" diff --git a/locale/pl.po b/locale/pl.po index 06c397d029..67eb288167 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -1549,6 +1549,12 @@ msgstr "" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1880,12 +1886,6 @@ msgstr "" msgid "SD card CSD format not supported" msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA lub SCL wymagają podciągnięcia" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4173,6 +4173,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA lub SCL wymagają podciągnięcia" + #~ msgid "tuple index out of range" #~ msgstr "indeks krotki poza zakresem" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index ccbe421910..5355d3340d 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -1567,6 +1567,12 @@ msgstr "Não há rede com este ssid" msgid "No out in program" msgstr "Sem saída no programa" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Não há pulldown no pino; É recomendável utilizar um resistor de 1M ohm" @@ -1919,12 +1925,6 @@ msgstr "Executando no modo de segurança! " msgid "SD card CSD format not supported" msgstr "O formato CSD do Cartão SD não é compatível" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA ou SCL precisa de um pull up" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4252,6 +4252,9 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA ou SCL precisa de um pull up" + #~ msgid "Invalid use of TLS Socket" #~ msgstr "Uso inválido do soquete TLS" diff --git a/locale/sv.po b/locale/sv.po index 031c34f144..9ab97a6392 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -1554,6 +1554,12 @@ msgstr "Inget nätverk med sådant ssid" msgid "No out in program" msgstr "" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Ingen pulldown på pinnen; 1Mohm rekommenderas" @@ -1901,12 +1907,6 @@ msgstr "Kör i säkert läge! " msgid "SD card CSD format not supported" msgstr "SD-kort CSD-format stöds inte" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA eller SCL behöver en pullup" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4214,6 +4214,9 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA eller SCL behöver en pullup" + #~ msgid "Invalid use of TLS Socket" #~ msgstr "Ogiltig användning av TLS Socket" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 29feefac60..fa175ca571 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -1554,6 +1554,12 @@ msgstr "Méiyǒu wǎngluò yǔ gāi ssid" msgid "No out in program" msgstr "chéng xù zhōng wèi tuì chū" +#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Yǐn jiǎo shàng méiyǒu xiàlā; 1Mohm tuījiàn" @@ -1897,12 +1903,6 @@ msgstr "Zài ānquán móshì xià yùnxíng! " msgid "SD card CSD format not supported" msgstr "Bù zhīchí SD kǎ CSD géshì" -#: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c -#: ports/raspberrypi/common-hal/busio/I2C.c -msgid "SDA or SCL needs a pull up" -msgstr "SDA huò SCL xūyào lādòng" - #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" @@ -4208,6 +4208,9 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "SDA or SCL needs a pull up" +#~ msgstr "SDA huò SCL xūyào lādòng" + #~ msgid "Invalid use of TLS Socket" #~ msgstr "TLS tào jiē zì de wú xiào shǐ yòng" From 00926b687a619f18deb08c1f59f868a4e9b8514a Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Wed, 3 Feb 2021 11:16:19 -0600 Subject: [PATCH 28/78] Trying to keep two ARM builds from overflowing their FLASH --- tools/gen_usb_descriptor.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index cf74001088..05d35ffc45 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -403,19 +403,21 @@ vendor_endpoint_out_descriptor = standard.EndpointDescriptor( bmAttributes=standard.EndpointDescriptor.TYPE_BULK, bInterval=16) -vendor_interface = standard.InterfaceDescriptor( - description="VENDOR", - bInterfaceClass=0xff, # vendor.VENDOR_CLASS, - bInterfaceSubClass=0x00, #vendor.VENDOR_SUBCLASS_???,, - bInterfaceProtocol=0x00, #vendor.VENDOR_PROTOCOL_NONE, - iInterface=StringIndex.index("{} VENDOR".format(args.interface_name)), - subdescriptors=[ - vendor_endpoint_in_descriptor, - vendor_endpoint_out_descriptor, - ] -) +# We do the following conditionally to avoid adding unused entries to the StringIndex table +if 'VENDOR' in args.devices: + vendor_interface = standard.InterfaceDescriptor( + description="VENDOR", + bInterfaceClass=0xff, # vendor.VENDOR_CLASS, + bInterfaceSubClass=0x00, #vendor.VENDOR_SUBCLASS_???,, + bInterfaceProtocol=0x00, #vendor.VENDOR_PROTOCOL_NONE, + iInterface=StringIndex.index("{} VENDOR".format(args.interface_name)), + subdescriptors=[ + vendor_endpoint_in_descriptor, + vendor_endpoint_out_descriptor, + ] + ) -vendor_interfaces = [vendor_interface] + vendor_interfaces = [vendor_interface] interfaces_to_join = [] From f2067730cb1986d0b325cd22545da1a0d48920aa Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Wed, 3 Feb 2021 18:51:48 -0600 Subject: [PATCH 29/78] Code cleanup and added a WEBUSB_README file --- WEBUSB_README.md | 91 +++++++++++++++++++++++++++++++++++++ tools/gen_usb_descriptor.py | 25 ++-------- 2 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 WEBUSB_README.md diff --git a/WEBUSB_README.md b/WEBUSB_README.md new file mode 100644 index 0000000000..a4b9c4c3e9 --- /dev/null +++ b/WEBUSB_README.md @@ -0,0 +1,91 @@ + + +# WebUSB Serial Support + +To date, this has only been tested on one port (esp32s2), on one board (espressif_kaluga_1). + +## What it does + +If you have ever used CircuitPython on a platform with a graphical LCD display, you have probably +already seen multiple "consoles" in use (although the LCD console is "output only"). + +New compile-time option CIRCUITPY_USB_VENDOR enables an additional "console" that can be used in +parallel with the original (CDC) serial console. + +Web pages that support the WebUSB standard can connect to the "vendor" interface and activate +this WebUSB serial console at any time. + +You can type into either console, and CircuitPython output is sent to all active consoles. + +## How to enable + +Update your platform's mpconfigboard.mk file to enable and disable specific types of USB interfaces. + +CIRCUITPY_USB_HID = xxx +CIRCUITPY_USB_MIDI = xxx +CIRCUITPY_USB_VENDOR = xxx + +On at least some of the hardware platforms, the maximum number of USB endpoints is fixed. +For example, on the ESP32S2, you must pick only one of the above 3 interfaces to be enabled. + +Original espressif_kaluga_1 mpconfigboard.mk settings: + +CIRCUITPY_USB_HID = 1 +CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_USB_VENDOR = 0 + +Settings to enable WebUSB instead: + +CIRCUITPY_USB_HID = 0 +CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_USB_VENDOR = 1 + +Notice that to enable VENDOR, we had to give up HID. There may be platforms that can have both. + +## Implementation Notes + +CircuitPython uses the tinyusb library. + +The tinyusb library already has support for WebUSB serial. +The tinyusb examples already include a "WebUSB serial" example. + + Sidenote - The use of the term "vendor" instead of "WebUSB" was done to match tinyusb. + +Basically, this feature was ported into CircuitPython by pulling code snippets out of the +tinyusb example, and putting them where they best belonged in the CircuitPython codebase. + +There was one complication: + +tinyusb uses C preprocessor macros to define things like USB descriptors. + +CircuitPython uses a Python program (tools/gen_usb_descriptor.py) to create USB descriptors (etc.) +using "helper objects" from another repo (adafruit_usb_descriptor). This means some of the example +code had to be adapted to the new programing model, and gen_usb_descriptor gained new command-line +options to control the generated code. + +The generated files go into the "build" directory, look for autogen_usb_descriptor.c and +genhdr/autogen_usb_descriptor.h. + + +Also worth pointing out - the re-use of the CDC connect/disconnect mechanism is not actually part +of the WebUSB standard, it's more of "common idiom". We make use of it here because we need to know +when we should be paying attention to the WebUSB serial interface,and when we should ignore it.. + +## Possible future work areas + +The current code uses the existing Python infrastructure to create the Interface descriptor, but +simply outputs the code snippets from the original tinyusb demo code to create the WEBUSB_URL, +BOS, and MS_OS_20 descriptors. I suppose additional work could be done to add these to the +adafruit_usb_descriptor project, and then gen_usb_descriptor.py could be modified to make use +of them. + +Program gen_usb_descriptor.py creates objects for most interface types, regardless of whether or +not they are actually enabled. This increases the size of a generated string table. I made the +new vendor-interface-related code not do this (because some of the ARM platforms would no longer +build), but I did not go back and do this for the other interface types (CDC, MIDI, HID, etc.) +Some FLASH savings are probably possible if this is done. + diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 05d35ffc45..ad68d0ea94 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -2,21 +2,6 @@ # # SPDX-License-Identifier: MIT -def fix_note(note): - index = note.rfind(" object at") - if index >= 0: - note = note[:index] + ">" - return note - -def fix_notes(notes): - count = len(notes) - index = 0 - while index < count: - notes[index] = fix_note(notes[index]) - index += 1 - - return notes - import argparse import os @@ -389,8 +374,7 @@ audio_control_interface = standard.InterfaceDescriptor( # Audio streaming interfaces must occur before MIDI ones. audio_interfaces = [audio_control_interface] + cs_ac_interface.audio_streaming_interfaces + cs_ac_interface.midi_streaming_interfaces -# TODO New code goes here to create vendor objects -# Starting out with a clone-and-modify of the HID descriptors +# Vendor-specific interface, for example WebUSB vendor_endpoint_in_descriptor = standard.EndpointDescriptor( description="VENDOR in", bEndpointAddress=args.vendor_ep_num_in | standard.EndpointDescriptor.DIRECTION_IN, @@ -407,9 +391,9 @@ vendor_endpoint_out_descriptor = standard.EndpointDescriptor( if 'VENDOR' in args.devices: vendor_interface = standard.InterfaceDescriptor( description="VENDOR", - bInterfaceClass=0xff, # vendor.VENDOR_CLASS, - bInterfaceSubClass=0x00, #vendor.VENDOR_SUBCLASS_???,, - bInterfaceProtocol=0x00, #vendor.VENDOR_PROTOCOL_NONE, + bInterfaceClass=0xff, # Vendor-specific + bInterfaceSubClass=0x00, + bInterfaceProtocol=0x00, iInterface=StringIndex.index("{} VENDOR".format(args.interface_name)), subdescriptors=[ vendor_endpoint_in_descriptor, @@ -546,7 +530,6 @@ for descriptor in descriptor_list: b = bytes(descriptor) notes = descriptor.notes() - notes = fix_notes(notes) # for comparision of files beteen runs i = 0 # This prints each subdescriptor on a separate line. From 4d90f198ecad900cc71745087e895bcbea63b12c Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Wed, 3 Feb 2021 18:54:03 -0600 Subject: [PATCH 30/78] (I could have sworn I deleted that line...) --- tools/gen_usb_descriptor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index ad68d0ea94..fb4372f0dd 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -558,7 +558,6 @@ for idx, descriptor in enumerate(string_descriptors): b = bytes(descriptor) notes = descriptor.notes() - notes = fix_notes(notes) # for comparision of files beteen runs i = 0 # This prints each subdescriptor on a separate line. From 8d7b1f9e8c9545468305443ae6cae3d653ead8d2 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 4 Feb 2021 16:00:14 +0700 Subject: [PATCH 31/78] add usb_background_schedule() unconditionally schedule usb background after background_callback_reset() --- main.c | 1 + supervisor/shared/background_callback.c | 5 ----- supervisor/shared/usb/usb.c | 13 +++++++++---- supervisor/usb.h | 3 +++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index d9cdcca1da..f85109e2fd 100755 --- a/main.c +++ b/main.c @@ -184,6 +184,7 @@ STATIC void stop_mp(void) { #endif background_callback_reset(); + usb_background_schedule(); gc_deinit(); } diff --git a/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c index 44709b60b5..68a0a9667d 100644 --- a/supervisor/shared/background_callback.c +++ b/supervisor/shared/background_callback.c @@ -105,9 +105,6 @@ void background_callback_end_critical_section() { CALLBACK_CRITICAL_END; } -extern background_callback_t usb_callback; -extern void usb_background_do(void* unused); - void background_callback_reset() { CALLBACK_CRITICAL_BEGIN; background_callback_t *cb = (background_callback_t*)callback_head; @@ -120,8 +117,6 @@ void background_callback_reset() { callback_tail = NULL; in_background_callback = false; CALLBACK_CRITICAL_END; - - background_callback_add(&usb_callback, usb_background_do, NULL); } void background_callback_gc_collect(void) { diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index af34f25987..9cbb295c8a 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -93,16 +93,21 @@ void usb_background(void) { } } -/*static*/ background_callback_t usb_callback; -/*static*/ void usb_background_do(void* unused) { +static background_callback_t usb_callback; +static void usb_background_do(void* unused) { usb_background(); } -void usb_irq_handler(void) { - tud_int_handler(0); \ +void usb_background_schedule(void) +{ background_callback_add(&usb_callback, usb_background_do, NULL); } +void usb_irq_handler(void) { + tud_int_handler(0); + usb_background_schedule(); +} + //--------------------------------------------------------------------+ // tinyusb callbacks //--------------------------------------------------------------------+ diff --git a/supervisor/usb.h b/supervisor/usb.h index ccb35470cd..1c709926a7 100644 --- a/supervisor/usb.h +++ b/supervisor/usb.h @@ -35,6 +35,9 @@ // it may be necessary to call it directly. void usb_background(void); +// Schedule usb background +void usb_background_schedule(void); + // Ports must call this from their particular USB IRQ handler void usb_irq_handler(void); From 3bf8ef4c143e13cf9281a64c3f169a939e7ed5bc Mon Sep 17 00:00:00 2001 From: Kevin Banks Date: Thu, 4 Feb 2021 08:09:35 -0600 Subject: [PATCH 32/78] Making WEBUSB_README.md standalone for now --- WEBUSB_README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/WEBUSB_README.md b/WEBUSB_README.md index a4b9c4c3e9..fbad701732 100644 --- a/WEBUSB_README.md +++ b/WEBUSB_README.md @@ -1,3 +1,4 @@ +:orphan: