summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2018-08-16 19:22:45 -0700
committerGitHub <noreply@github.com>2018-08-16 19:22:45 -0700
commit5dd420f7ff2c87a5412a55fea29eb21615a89e14 (patch)
tree93c0afa00ee8f6317600301c01b1ddbf086d7e73 /ports
parent92ed5d7bf223212e8db04af3f6712770ec2c86ea (diff)
parente8cf6a907236bb06a6f8d734b8d829e3dba91825 (diff)
Merge pull request #1121 from tannewt/huffman
Compress all translated strings with Huffman coding.
Diffstat (limited to 'ports')
-rw-r--r--ports/atmel-samd/audio_dma.c5
-rw-r--r--ports/atmel-samd/bindings/samd/Clock.c4
-rw-r--r--ports/atmel-samd/board_busses.c7
-rw-r--r--ports/atmel-samd/common-hal/analogio/AnalogOut.c2
-rw-r--r--ports/atmel-samd/common-hal/audiobusio/PDMIn.c3
-rw-r--r--ports/atmel-samd/common-hal/audioio/AudioOut.c4
-rw-r--r--ports/atmel-samd/common-hal/busio/SPI.c2
m---------ports/atmel-samd/peripherals0
-rw-r--r--ports/esp8266/common-hal/analogio/AnalogIn.c3
-rw-r--r--ports/esp8266/common-hal/analogio/AnalogOut.c7
-rw-r--r--ports/esp8266/common-hal/busio/SPI.c3
-rw-r--r--ports/esp8266/common-hal/busio/UART.c7
-rw-r--r--ports/esp8266/common-hal/digitalio/DigitalInOut.c9
-rw-r--r--ports/esp8266/common-hal/microcontroller/__init__.c5
-rw-r--r--ports/esp8266/common-hal/pulseio/PWMOut.c13
-rw-r--r--ports/esp8266/common-hal/pulseio/PulseIn.c9
-rw-r--r--ports/esp8266/common-hal/storage/__init__.c5
-rw-r--r--ports/esp8266/esp8266.ld2
-rw-r--r--ports/esp8266/esp_mphal.c3
-rw-r--r--ports/esp8266/machine_adc.c3
-rw-r--r--ports/esp8266/machine_hspi.c5
-rw-r--r--ports/esp8266/machine_pin.c10
-rw-r--r--ports/esp8266/machine_pwm.c3
-rw-r--r--ports/esp8266/machine_rtc.c9
-rw-r--r--ports/esp8266/machine_uart.c9
-rw-r--r--ports/esp8266/makeimg.py1
-rw-r--r--ports/esp8266/modesp.c9
-rw-r--r--ports/esp8266/modmachine.c3
-rw-r--r--ports/esp8266/modnetwork.c37
-rw-r--r--ports/nrf/common-hal/analogio/AnalogIn.c3
-rw-r--r--ports/nrf/common-hal/analogio/AnalogOut.c8
-rw-r--r--ports/nrf/common-hal/busio/I2C.c3
-rw-r--r--ports/nrf/common-hal/busio/UART.c19
-rw-r--r--ports/nrf/common-hal/digitalio/DigitalInOut.c3
-rw-r--r--ports/nrf/common-hal/microcontroller/Processor.c3
-rw-r--r--ports/nrf/common-hal/pulseio/PWMOut.c4
-rw-r--r--ports/nrf/common-hal/usb_hid/Device.c8
-rw-r--r--ports/nrf/drivers/bluetooth/ble_drv.c49
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_characteristic.c3
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_service.c7
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_uuid.c5
-rw-r--r--ports/unix/Makefile2
-rw-r--r--ports/unix/file.c3
-rw-r--r--ports/unix/modffi.c12
-rw-r--r--ports/unix/modmachine.c4
-rw-r--r--ports/unix/modusocket.c4
46 files changed, 186 insertions, 136 deletions
diff --git a/ports/atmel-samd/audio_dma.c b/ports/atmel-samd/audio_dma.c
index 0cd931c2e..45d698c17 100644
--- a/ports/atmel-samd/audio_dma.c
+++ b/ports/atmel-samd/audio_dma.c
@@ -33,6 +33,7 @@
#include "shared-bindings/audioio/WaveFile.h"
#include "py/mpstate.h"
+#include "py/runtime.h"
static audio_dma_t* audio_dma_state[AUDIO_DMA_CHANNEL_COUNT];
@@ -279,6 +280,10 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t* dma,
// We're likely double buffering so set up the block interrupts.
turn_on_event_system();
dma->event_channel = find_sync_event_channel();
+
+ if (dma->event_channel >= EVSYS_SYNCH_NUM) {
+ mp_raise_RuntimeError(translate("All sync event channels in use"));
+ }
init_event_channel_interrupt(dma->event_channel, CORE_GCLK, EVSYS_ID_GEN_DMAC_CH_0 + dma_channel);
// We keep the audio_dma_t for internal use and the sample as a root pointer because it
diff --git a/ports/atmel-samd/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c
index 28eb7949f..be597c444 100644
--- a/ports/atmel-samd/bindings/samd/Clock.c
+++ b/ports/atmel-samd/bindings/samd/Clock.c
@@ -132,9 +132,9 @@ STATIC mp_obj_t samd_clock_set_calibration(mp_obj_t self_in, mp_obj_t calibratio
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);
int ret = clock_set_calibration(self->type, self->index, mp_obj_get_int(calibration));
if (ret == -2)
- mp_raise_AttributeError("calibration is read only");
+ mp_raise_AttributeError(translate("calibration is read only"));
if (ret == -1)
- mp_raise_ValueError("calibration is out of range");
+ mp_raise_ValueError(translate("calibration is out of range"));
return mp_const_none;
}
diff --git a/ports/atmel-samd/board_busses.c b/ports/atmel-samd/board_busses.c
index 4bf1a40fa..e36541ca9 100644
--- a/ports/atmel-samd/board_busses.c
+++ b/ports/atmel-samd/board_busses.c
@@ -29,13 +29,14 @@
#include "shared-bindings/busio/UART.h"
#include "shared-bindings/microcontroller/Pin.h"
+#include "supervisor/shared/translate.h"
#include "mpconfigboard.h"
#include "samd/pins.h"
#include "py/runtime.h"
#if !defined(DEFAULT_I2C_BUS_SDA) || !defined(DEFAULT_I2C_BUS_SCL)
STATIC mp_obj_t board_i2c(void) {
- mp_raise_NotImplementedError("No default I2C bus");
+ mp_raise_NotImplementedError(translate("No default I2C bus"));
return NULL;
}
#else
@@ -60,7 +61,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
#if !defined(DEFAULT_SPI_BUS_SCK) || !defined(DEFAULT_SPI_BUS_MISO) || !defined(DEFAULT_SPI_BUS_MOSI)
STATIC mp_obj_t board_spi(void) {
- mp_raise_NotImplementedError("No default SPI bus");
+ mp_raise_NotImplementedError(translate("No default SPI bus"));
return NULL;
}
#else
@@ -87,7 +88,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi);
#if !defined(DEFAULT_UART_BUS_RX) || !defined(DEFAULT_UART_BUS_TX)
STATIC mp_obj_t board_uart(void) {
- mp_raise_NotImplementedError("No default UART bus");
+ mp_raise_NotImplementedError(translate("No default UART bus"));
return NULL;
}
#else
diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c
index 4e50e2827..9be8c3936 100644
--- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c
+++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c
@@ -46,7 +46,7 @@
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
const mcu_pin_obj_t *pin) {
#if defined(SAMD21) && !defined(PIN_PA02)
- mp_raise_NotImplementedError("No DAC on chip");
+ mp_raise_NotImplementedError(translate("No DAC on chip"));
#else
if (pin->number != PIN_PA02
#ifdef SAMD51
diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c
index 90fbeb9e8..0adc3fb52 100644
--- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c
+++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c
@@ -357,6 +357,9 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se
uint16_t* output_buffer, uint32_t output_buffer_length) {
uint8_t dma_channel = find_free_audio_dma_channel();
uint8_t event_channel = find_sync_event_channel();
+ if (event_channel >= EVSYS_SYNCH_NUM) {
+ mp_raise_RuntimeError(translate("All sync event channels in use"));
+ }
// We allocate two buffers on the stack to use for double buffering.
const uint8_t samples_per_buffer = SAMPLES_PER_BUFFER;
diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c
index bef19b2cc..7df328a6a 100644
--- a/ports/atmel-samd/common-hal/audioio/AudioOut.c
+++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c
@@ -211,6 +211,10 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
// Find a free event channel. We start at the highest channels because we only need and async
// path.
uint8_t channel = find_async_event_channel();
+ if (channel >= EVSYS_CHANNELS) {
+ mp_raise_RuntimeError(translate("All event channels in use"));
+ }
+
#ifdef SAMD51
connect_event_user_to_channel(EVSYS_ID_USER_DAC_START_1, channel);
#define EVSYS_ID_USER_DAC_START EVSYS_ID_USER_DAC_START_0
diff --git a/ports/atmel-samd/common-hal/busio/SPI.c b/ports/atmel-samd/common-hal/busio/SPI.c
index b372a2f92..fd7f81cc2 100644
--- a/ports/atmel-samd/common-hal/busio/SPI.c
+++ b/ports/atmel-samd/common-hal/busio/SPI.c
@@ -129,7 +129,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
}
#endif
if (sercom == NULL) {
- mp_raise_ValueError("Invalid pins");
+ mp_raise_ValueError(translate("Invalid pins"));
}
// Set up SPI clocks on SERCOM.
diff --git a/ports/atmel-samd/peripherals b/ports/atmel-samd/peripherals
-Subproject 1140ff6d7ed413aa1e2f34c5d847dcc41c924bb
+Subproject 156279784cb3d22f7f8a8d93b4bb55e2d912a5f
diff --git a/ports/esp8266/common-hal/analogio/AnalogIn.c b/ports/esp8266/common-hal/analogio/AnalogIn.c
index e01eceabd..63580c07c 100644
--- a/ports/esp8266/common-hal/analogio/AnalogIn.c
+++ b/ports/esp8266/common-hal/analogio/AnalogIn.c
@@ -33,13 +33,14 @@
#include "py/mphal.h"
#include "common-hal/microcontroller/__init__.h"
#include "shared-bindings/analogio/AnalogIn.h"
+#include "supervisor/shared/translate.h"
#include "user_interface.h"
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self,
const mcu_pin_obj_t *pin) {
if (pin != &pin_TOUT) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Pin %q does not have ADC capabilities", pin->name));
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("Pin %q does not have ADC capabilities"), pin->name));
}
claim_pin(pin);
}
diff --git a/ports/esp8266/common-hal/analogio/AnalogOut.c b/ports/esp8266/common-hal/analogio/AnalogOut.c
index 15e9ee277..b01d8edb8 100644
--- a/ports/esp8266/common-hal/analogio/AnalogOut.c
+++ b/ports/esp8266/common-hal/analogio/AnalogOut.c
@@ -24,18 +24,19 @@
* THE SOFTWARE.
*/
+#include "shared-bindings/analogio/AnalogOut.h"
+
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "py/runtime.h"
-
-#include "shared-bindings/analogio/AnalogOut.h"
+#include "supervisor/shared/translate.h"
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
const mcu_pin_obj_t *pin) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
- "No hardware support for analog out."));
+ translate("No hardware support for analog out.")));
}
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
diff --git a/ports/esp8266/common-hal/busio/SPI.c b/ports/esp8266/common-hal/busio/SPI.c
index e1eeecc2a..d00997820 100644
--- a/ports/esp8266/common-hal/busio/SPI.c
+++ b/ports/esp8266/common-hal/busio/SPI.c
@@ -27,6 +27,7 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "common-hal/busio/SPI.h"
#include "py/nlr.h"
+#include "supervisor/shared/translate.h"
#include "eagle_soc.h"
#include "ets_alt_task.h"
@@ -68,7 +69,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
(mosi == MP_OBJ_TO_PTR(mp_const_none) && miso == &pin_MTDI) ||
(mosi == &pin_MTCK && miso == &pin_MTDI))) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Pins not valid for SPI"));
+ translate("Pins not valid for SPI")));
}
busio_spi_init_gpio(SPI_CLK_USE_DIV, clock, mosi, miso);
diff --git a/ports/esp8266/common-hal/busio/UART.c b/ports/esp8266/common-hal/busio/UART.c
index 5540e3573..7a4ca6e0d 100644
--- a/ports/esp8266/common-hal/busio/UART.c
+++ b/ports/esp8266/common-hal/busio/UART.c
@@ -27,6 +27,7 @@
#include "common-hal/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/busio/UART.h"
+#include "supervisor/shared/translate.h"
#include "ets_sys.h"
#include "uart.h"
@@ -41,7 +42,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout,
uint8_t receiver_buffer_size) {
if (rx != mp_const_none || tx != &pin_GPIO2) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Only tx supported on UART1 (GPIO2)."));
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, translate("Only tx supported on UART1 (GPIO2).")));
}
// set baudrate
@@ -63,7 +64,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
UartDev.data_bits = UART_EIGHT_BITS;
break;
default:
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid data bits"));
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("invalid data bits")));
break;
}
@@ -87,7 +88,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
UartDev.stop_bits = UART_TWO_STOP_BIT;
break;
default:
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid stop bits"));
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("invalid stop bits")));
break;
}
diff --git a/ports/esp8266/common-hal/digitalio/DigitalInOut.c b/ports/esp8266/common-hal/digitalio/DigitalInOut.c
index 96945737b..80584bb5f 100644
--- a/ports/esp8266/common-hal/digitalio/DigitalInOut.c
+++ b/ports/esp8266/common-hal/digitalio/DigitalInOut.c
@@ -33,6 +33,7 @@
#include "py/mphal.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
+#include "supervisor/shared/translate.h"
#include "common-hal/microcontroller/Pin.h"
extern volatile bool gpio16_in_use;
@@ -45,9 +46,9 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
WRITE_PERI_REG(RTC_GPIO_CONF, READ_PERI_REG(RTC_GPIO_CONF) & ~1); //mux configuration for out enable
WRITE_PERI_REG(RTC_GPIO_ENABLE, READ_PERI_REG(RTC_GPIO_ENABLE) & ~1); //out disable
claim_pin(pin);
- } else {
+ } else {
PIN_FUNC_SELECT(self->pin->peripheral, self->pin->gpio_function);
- }
+ }
return DIGITALINOUT_OK;
}
@@ -196,7 +197,7 @@ void common_hal_digitalio_digitalinout_set_pull(
digitalio_digitalinout_obj_t* self, digitalio_pull_t pull) {
if (pull == PULL_DOWN) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
- "ESP8266 does not support pull down."));
+ translate("ESP8266 does not support pull down.")));
return;
}
if (self->pin->gpio_number == 16) {
@@ -206,7 +207,7 @@ void common_hal_digitalio_digitalinout_set_pull(
// raise the exception so the user knows PULL_UP is not available
if (pull != PULL_NONE){
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
- "GPIO16 does not support pull up."));
+ translate("GPIO16 does not support pull up.")));
}
return;
}
diff --git a/ports/esp8266/common-hal/microcontroller/__init__.c b/ports/esp8266/common-hal/microcontroller/__init__.c
index 6d446ceac..de9288a77 100644
--- a/ports/esp8266/common-hal/microcontroller/__init__.c
+++ b/ports/esp8266/common-hal/microcontroller/__init__.c
@@ -32,6 +32,7 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/microcontroller/Processor.h"
+#include "supervisor/shared/translate.h"
#include "eagle_soc.h"
#include "ets_alt_task.h"
@@ -60,9 +61,9 @@ void common_hal_mcu_enable_interrupts() {
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
if (runmode == RUNMODE_BOOTLOADER) {
- mp_raise_ValueError("Cannot reset into bootloader because no bootloader is present.");
+ mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present."));
} else if (runmode == RUNMODE_SAFE_MODE) {
- mp_raise_ValueError("ESP8226 does not support safe mode.");
+ mp_raise_ValueError(translate("ESP8226 does not support safe mode."));
}
}
diff --git a/ports/esp8266/common-hal/pulseio/PWMOut.c b/ports/esp8266/common-hal/pulseio/PWMOut.c
index 9cc869794..f3a7bbc5a 100644
--- a/ports/esp8266/common-hal/pulseio/PWMOut.c
+++ b/ports/esp8266/common-hal/pulseio/PWMOut.c
@@ -31,6 +31,7 @@
#include "py/runtime.h"
#include "shared-bindings/pulseio/PWMOut.h"
+#include "supervisor/shared/translate.h"
#include "eagle_soc.h"
#include "c_types.h"
@@ -50,10 +51,10 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, const mcu_p
bool variable_frequency) {
if (frequency > PWM_FREQ_MAX) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Maximum PWM frequency is %dhz.", PWM_FREQ_MAX));
+ translate("Maximum PWM frequency is %dhz."), PWM_FREQ_MAX));
} else if (frequency < 1) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
- "Minimum PWM frequency is 1hz."));
+ translate("Minimum PWM frequency is 1hz.")));
}
// start the PWM subsystem if it's not already running
@@ -64,7 +65,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, const mcu_p
first_channel_variable = variable_frequency;
} else if (first_channel_variable || pwm_get_freq(0) != frequency) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Multiple PWM frequencies not supported. PWM already set to %dhz.", pwm_get_freq(0)));
+ translate("Multiple PWM frequencies not supported. PWM already set to %dhz."), pwm_get_freq(0)));
}
self->channel = pwm_add(pin->gpio_number,
@@ -73,7 +74,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, const mcu_p
self->pin = pin;
if (self->channel == -1) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "PWM not supported on pin %d", pin->gpio_number));
+ translate("PWM not supported on pin %d"), pin->gpio_number));
}
}
@@ -109,10 +110,10 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
if (frequency > PWM_FREQ_MAX) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Maximum PWM frequency is %dhz.", PWM_FREQ_MAX));
+ translate("Maximum PWM frequency is %dhz."), PWM_FREQ_MAX));
} else if (frequency < 1) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
- "Minimum PWM frequency is 1hz."));
+ translate("Minimum PWM frequency is 1hz.")));
}
pwm_set_freq(frequency, 0);
}
diff --git a/ports/esp8266/common-hal/pulseio/PulseIn.c b/ports/esp8266/common-hal/pulseio/PulseIn.c
index 9720eaad5..40ba39e5f 100644
--- a/ports/esp8266/common-hal/pulseio/PulseIn.c
+++ b/ports/esp8266/common-hal/pulseio/PulseIn.c
@@ -35,6 +35,7 @@
#include "py/runtime.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/pulseio/PulseIn.h"
+#include "supervisor/shared/translate.h"
#include "common-hal/microcontroller/__init__.h"
static void pulsein_set_interrupt(pulseio_pulsein_obj_t *self, bool rising, bool falling) {
@@ -74,7 +75,7 @@ void pulseio_pulsein_interrupt_handler(void *data) {
void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
const mcu_pin_obj_t* pin, uint16_t maxlen, bool idle_state) {
if (pin->gpio_number == NO_GPIO || pin->gpio_function == SPECIAL_CASE) {
- mp_raise_msg_varg(&mp_type_ValueError, "No PulseIn support for %q", pin->name );
+ mp_raise_msg_varg(&mp_type_ValueError, translate("No PulseIn support for %q"), pin->name );
}
PIN_FUNC_SELECT(pin->peripheral, pin->gpio_function);
PIN_PULLUP_DIS(pin->peripheral);
@@ -82,7 +83,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
self->buffer = (uint16_t *) m_malloc(maxlen * sizeof(uint16_t), false);
if (self->buffer == NULL) {
- mp_raise_msg_varg(&mp_type_MemoryError, "Failed to allocate RX buffer of %d bytes", maxlen * sizeof(uint16_t));
+ mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), maxlen * sizeof(uint16_t));
}
self->maxlen = maxlen;
@@ -147,7 +148,7 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) {
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
if (self->len == 0) {
- mp_raise_IndexError("pop from an empty PulseIn");
+ mp_raise_IndexError(translate("pop from an empty PulseIn"));
}
common_hal_mcu_disable_interrupts();
uint16_t value = self->buffer[self->start];
@@ -178,7 +179,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self,
}
if (index < 0 || index >= self->len) {
common_hal_mcu_enable_interrupts();
- mp_raise_IndexError("index out of range");
+ mp_raise_IndexError(translate("index out of range"));
}
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
common_hal_mcu_enable_interrupts();
diff --git a/ports/esp8266/common-hal/storage/__init__.c b/ports/esp8266/common-hal/storage/__init__.c
index b800ad2bd..71a2aca39 100644
--- a/ports/esp8266/common-hal/storage/__init__.c
+++ b/ports/esp8266/common-hal/storage/__init__.c
@@ -28,11 +28,12 @@
#include "py/runtime.h"
#include "shared-bindings/storage/__init__.h"
+#include "supervisor/shared/translate.h"
void common_hal_storage_remount(const char* mount_path, bool readonly) {
- mp_raise_NotImplementedError("");
+ mp_raise_NotImplementedError(translate("Unable to remount filesystem"));
}
void common_hal_storage_erase_filesystem() {
- mp_raise_NotImplementedError("Use esptool to erase flash and re-upload Python instead");
+ mp_raise_NotImplementedError(translate("Use esptool to erase flash and re-upload Python instead"));
}
diff --git a/ports/esp8266/esp8266.ld b/ports/esp8266/esp8266.ld
index deeb82b45..3d244f6ad 100644
--- a/ports/esp8266/esp8266.ld
+++ b/ports/esp8266/esp8266.ld
@@ -5,7 +5,7 @@ MEMORY
dport0_0_seg : org = 0x3ff00000, len = 0x10
dram0_0_seg : org = 0x3ffe8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
- irom0_0_seg : org = 0x40209000, len = 0x8f000
+ irom0_0_seg : org = 0x40209000, len = 0x91000
}
/* define common sections and symbols */
diff --git a/ports/esp8266/esp_mphal.c b/ports/esp8266/esp_mphal.c
index fe669265e..33d7f2d84 100644
--- a/ports/esp8266/esp_mphal.c
+++ b/ports/esp8266/esp_mphal.c
@@ -34,6 +34,7 @@
#include "py/runtime.h"
#include "extmod/misc.h"
#include "lib/utils/pyexec.h"
+#include "supervisor/shared/translate.h"
STATIC byte input_buf_array[256];
ringbuf_t stdin_ringbuf = {input_buf_array, sizeof(input_buf_array)};
@@ -150,7 +151,7 @@ void ets_event_poll(void) {
void __assert_func(const char *file, int line, const char *func, const char *expr) {
printf("assert:%s:%d:%s: %s\n", file, line, func, expr);
nlr_raise(mp_obj_new_exception_msg(&mp_type_AssertionError,
- "C-level assert"));
+ translate("C-level assert")));
}
void mp_hal_signal_input(void) {
diff --git a/ports/esp8266/machine_adc.c b/ports/esp8266/machine_adc.c
index b422f0f9e..2d31ed8ea 100644
--- a/ports/esp8266/machine_adc.c
+++ b/ports/esp8266/machine_adc.c
@@ -28,6 +28,7 @@
#include <string.h>
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#include "user_interface.h"
const mp_obj_type_t pyb_adc_type;
@@ -53,7 +54,7 @@ STATIC mp_obj_t pyb_adc_make_new(const mp_obj_type_t *type_in, size_t n_args, si
return &pyb_adc_vdd3;
default:
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "not a valid ADC Channel: %d", chn));
+ translate("not a valid ADC Channel: %d"), chn));
}
}
diff --git a/ports/esp8266/machine_hspi.c b/ports/esp8266/machine_hspi.c
index 07770c8c8..ac464da45 100644
--- a/ports/esp8266/machine_hspi.c
+++ b/ports/esp8266/machine_hspi.c
@@ -37,6 +37,7 @@
#include "py/mphal.h"
#include "extmod/machine_spi.h"
#include "modmachine.h"
+#include "supervisor/shared/translate.h"
#include "hspi.h"
#if MICROPY_PY_MACHINE_SPI
@@ -127,13 +128,13 @@ STATIC void machine_hspi_init(mp_obj_base_t *self_in, size_t n_args, const mp_ob
spi_init_gpio(HSPI, SPI_CLK_80MHZ_NODIV);
spi_clock(HSPI, 0, 0);
} else if (self->baudrate > 40000000L) {
- mp_raise_ValueError("impossible baudrate");
+ mp_raise_ValueError(translate("impossible baudrate"));
} else {
uint32_t divider = 40000000L / self->baudrate;
uint16_t prediv = MIN(divider, SPI_CLKDIV_PRE + 1);
uint16_t cntdiv = (divider / prediv) * 2; // cntdiv has to be even
if (cntdiv > SPI_CLKCNT_N + 1 || cntdiv == 0 || prediv == 0) {
- mp_raise_ValueError("impossible baudrate");
+ mp_raise_ValueError(translate("impossible baudrate"));
}
self->baudrate = 80000000L / (prediv * cntdiv);
spi_init_gpio(HSPI, SPI_CLK_USE_DIV);
diff --git a/ports/esp8266/machine_pin.c b/ports/esp8266/machine_pin.c
index 14505c8f0..0467ffb4b 100644
--- a/ports/esp8266/machine_pin.c
+++ b/ports/esp8266/machine_pin.c
@@ -39,6 +39,8 @@
#include "extmod/virtpin.h"
#include "modmachine.h"
+#include "supervisor/shared/translate.h"
+
#define GET_TRIGGER(phys_port) \
GPIO_PIN_INT_TYPE_GET(GPIO_REG_READ(GPIO_PIN_ADDR(phys_port)))
#define SET_TRIGGER(phys_port, trig) \
@@ -124,7 +126,7 @@ void pin_intr_handler(uint32_t status) {
pyb_pin_obj_t *mp_obj_get_pin_obj(mp_obj_t pin_in) {
if (mp_obj_get_type(pin_in) != &pyb_pin_type) {
- mp_raise_ValueError("expecting a pin");
+ mp_raise_ValueError(translate("expecting a pin"));
}
pyb_pin_obj_t *self = pin_in;
return self;
@@ -279,7 +281,7 @@ STATIC mp_obj_t pyb_pin_obj_init_helper(pyb_pin_obj_t *self, size_t n_args, cons
// only pull-down seems to be supported by the hardware, and
// we only expose pull-up behaviour in software
if (pull != GPIO_PULL_NONE) {
- mp_raise_ValueError("Pin(16) doesn't support pull");
+ mp_raise_ValueError(translate("Pin(16) doesn't support pull"));
}
} else {
PIN_FUNC_SELECT(self->periph, self->func);
@@ -318,7 +320,7 @@ mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw,
pin = (pyb_pin_obj_t*)&pyb_pin_obj[wanted_pin];
}
if (pin == NULL || pin->base.type == NULL) {
- mp_raise_ValueError("invalid pin");
+ mp_raise_ValueError(translate("invalid pin"));
}
if (n_args > 1 || n_kw > 0) {
@@ -384,7 +386,7 @@ STATIC mp_obj_t pyb_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
if (self->phys_port >= 16) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "pin does not have IRQ capabilities"));
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, translate("pin does not have IRQ capabilities")));
}
if (n_args > 1 || kw_args->used != 0) {
diff --git a/ports/esp8266/machine_pwm.c b/ports/esp8266/machine_pwm.c
index 961b8e547..a117a41d5 100644
--- a/ports/esp8266/machine_pwm.c
+++ b/ports/esp8266/machine_pwm.c
@@ -31,6 +31,7 @@
#include "py/runtime.h"
#include "modmachine.h"
+#include "supervisor/shared/translate.h"
typedef struct _pyb_pwm_obj_t {
mp_obj_base_t base;
@@ -66,7 +67,7 @@ STATIC void pyb_pwm_init_helper(pyb_pwm_obj_t *self, size_t n_args, const mp_obj
int channel = pwm_add(self->pin->phys_port, self->pin->periph, self->pin->func);
if (channel == -1) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "PWM not supported on pin %d", self->pin->phys_port));
+ translate("PWM not supported on pin %d"), self->pin->phys_port));
}
self->channel = channel;
diff --git a/ports/esp8266/machine_rtc.c b/ports/esp8266/machine_rtc.c
index bbfc172cd..9197efb7a 100644
--- a/ports/esp8266/machine_rtc.c
+++ b/ports/esp8266/machine_rtc.c
@@ -29,6 +29,7 @@
#include "py/runtime.h"
#include "lib/timeutils/timeutils.h"
+#include "supervisor/shared/translate.h"
#include "user_interface.h"
#include "modmachine.h"
@@ -181,7 +182,7 @@ STATIC mp_obj_t pyb_rtc_memory(size_t n_args, const mp_obj_t *args) {
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
if (bufinfo.len > MEM_USER_MAXLEN) {
- mp_raise_ValueError("buffer too long");
+ mp_raise_ValueError(translate("buffer too long"));
}
len = bufinfo.len;
@@ -205,7 +206,7 @@ STATIC mp_obj_t pyb_rtc_alarm(mp_obj_t self_in, mp_obj_t alarm_id, mp_obj_t time
// check we want alarm0
if (mp_obj_get_int(alarm_id) != 0) {
- mp_raise_ValueError("invalid alarm");
+ mp_raise_ValueError(translate("invalid alarm"));
}
// set expiry time (in microseconds)
@@ -219,7 +220,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_rtc_alarm_obj, pyb_rtc_alarm);
STATIC mp_obj_t pyb_rtc_alarm_left(size_t n_args, const mp_obj_t *args) {
// check we want alarm0
if (n_args > 1 && mp_obj_get_int(args[1]) != 0) {
- mp_raise_ValueError("invalid alarm");
+ mp_raise_ValueError(translate("invalid alarm"));
}
uint64_t now = pyb_rtc_get_us_since_2000();
@@ -242,7 +243,7 @@ STATIC mp_obj_t pyb_rtc_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
// check we want alarm0
if (args[ARG_trigger].u_int != 0) {
- mp_raise_ValueError("invalid alarm");
+ mp_raise_ValueError(translate("invalid alarm"));
}
// set the wake value
diff --git a/ports/esp8266/machine_uart.c b/ports/esp8266/machine_uart.c
index e8be5e538..c6a4e1ba1 100644
--- a/ports/esp8266/machine_uart.c
+++ b/ports/esp8266/machine_uart.c
@@ -34,6 +34,7 @@
#include "py/runtime.h"
#include "py/stream.h"
#include "py/mperrno.h"
+#include "supervisor/shared/translate.h"
#include "modmachine.h"
// UartDev is defined and initialized in rom code.
@@ -104,7 +105,7 @@ STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_o
self->bits = 8;
break;
default:
- mp_raise_ValueError("invalid data bits");
+ mp_raise_ValueError(translate("invalid data bits"));
break;
}
@@ -140,7 +141,7 @@ STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_o
self->stop = 2;
break;
default:
- mp_raise_ValueError("invalid stop bits");
+ mp_raise_ValueError(translate("invalid stop bits"));
break;
}
@@ -165,7 +166,7 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size
// get uart id
mp_int_t uart_id = mp_obj_get_int(args[0]);
if (uart_id != 0 && uart_id != 1) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "UART(%d) does not exist", uart_id));
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("UART(%d) does not exist"), uart_id));
}
// create instance
@@ -215,7 +216,7 @@ STATIC mp_uint_t pyb_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, i
pyb_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (self->uart_id == 1) {
- mp_raise_msg(&mp_type_OSError, "UART(1) can't read");
+ mp_raise_msg(&mp_type_OSError, translate("UART(1) can't read"));
}
// make sure we want at least 1 char
diff --git a/ports/esp8266/makeimg.py b/ports/esp8266/makeimg.py
index 091854fa4..1071f83e1 100644
--- a/ports/esp8266/makeimg.py
+++ b/ports/esp8266/makeimg.py
@@ -21,6 +21,7 @@ with open(sys.argv[3], 'wb') as fout:
with open(sys.argv[2], 'rb') as f:
data_rom = f.read()
+ print(SEGS_MAX_SIZE, len(data_flash))
pad = b'\xff' * (SEGS_MAX_SIZE - len(data_flash))
assert len(pad) >= 4
fout.write(pad[:-4])
diff --git a/ports/esp8266/modesp.c b/ports/esp8266/modesp.c
index 76aa2cc21..b1b30cd8b 100644
--- a/ports/esp8266/modesp.c
+++ b/ports/esp8266/modesp.c
@@ -30,6 +30,7 @@
#include "py/runtime.h"
#include "py/mperrno.h"
#include "py/mphal.h"
+#include "supervisor/shared/translate.h"
#include "uart.h"
#include "user_interface.h"
#include "mem.h"
@@ -37,7 +38,7 @@
#define MODESP_INCLUDE_CONSTANTS (1)
-void error_check(bool status, const char *msg) {
+void error_check(bool status, const compressed_string_t *msg) {
if (!status) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, msg));
}
@@ -115,7 +116,7 @@ STATIC mp_obj_t esp_flash_write(mp_obj_t offset_in, const mp_obj_t buf_in) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
if (bufinfo.len & 0x3) {
- mp_raise_ValueError("len must be multiple of 4");
+ mp_raise_ValueError(translate("len must be multiple of 4"));
}
SpiFlashOpResult res = spi_flash_write(offset, bufinfo.buf, bufinfo.len);
if (res == SPI_FLASH_RESULT_OK) {
@@ -270,7 +271,7 @@ void *esp_native_code_commit(void *buf, size_t len) {
len = (len + 3) & ~3;
if (esp_native_code_cur + len > esp_native_code_end) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_MemoryError,
- "memory allocation failed, allocating %u bytes for native code", (uint)len));
+ translate("memory allocation failed, allocating %u bytes for native code"), (uint)len));
}
void *dest;
@@ -313,7 +314,7 @@ STATIC mp_obj_t esp_set_native_code_location(mp_obj_t start_in, mp_obj_t len_in)
esp_native_code_erased = esp_native_code_start;
// memory-mapped flash is limited in extents to 1MByte
if (esp_native_code_end > FLASH_END - FLASH_START) {
- mp_raise_ValueError("flash location must be below 1MByte");
+ mp_raise_ValueError(translate("flash location must be below 1MByte"));
}
}
return mp_const_none;
diff --git a/ports/esp8266/modmachine.c b/ports/esp8266/modmachine.c
index 7e5f6714b..dc7bad1c6 100644
--- a/ports/esp8266/modmachine.c
+++ b/ports/esp8266/modmachine.c
@@ -35,6 +35,7 @@
#include "extmod/machine_pulse.h"
#include "extmod/machine_i2c.h"
#include "modmachine.h"
+#include "supervisor/shared/translate.h"
#include "xtirq.h"
#include "os_type.h"
@@ -59,7 +60,7 @@ STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
// set
mp_int_t freq = mp_obj_get_int(args[0]) / 1000000;
if (freq != 80 && freq != 160) {
- mp_raise_ValueError("frequency can only be either 80Mhz or 160MHz");
+ mp_raise_ValueError(translate("frequency can only be either 80Mhz or 160MHz"));
}
system_update_cpu_freq(freq);
return mp_const_none;
diff --git a/ports/esp8266/modnetwork.c b/ports/esp8266/modnetwork.c
index c7f3397c4..1a41aa4d6 100644
--- a/ports/esp8266/modnetwork.c
+++ b/ports/esp8266/modnetwork.c
@@ -32,6 +32,7 @@
#include "py/runtime.h"
#include "py/mphal.h"
#include "lib/netutils/netutils.h"
+#include "supervisor/shared/translate.h"
#include "queue.h"
#include "user_interface.h"
#include "espconn.h"
@@ -46,7 +47,7 @@ typedef struct _wlan_if_obj_t {
int if_id;
} wlan_if_obj_t;
-void error_check(bool status, const char *msg);
+void error_check(bool status, const compressed_string_t *msg);
const mp_obj_type_t wlan_if_type;
STATIC const wlan_if_obj_t wlan_objs[] = {
@@ -57,7 +58,7 @@ STATIC const wlan_if_obj_t wlan_objs[] = {
STATIC void require_if(mp_obj_t wlan_if, int if_no) {
wlan_if_obj_t *self = MP_OBJ_TO_PTR(wlan_if);
if (self->if_id != if_no) {
- error_check(false, if_no == STATION_IF ? "STA required" : "AP required");
+ error_check(false, if_no == STATION_IF ? translate("STA required") : translate("AP required"));
}
}
@@ -83,7 +84,7 @@ STATIC mp_obj_t esp_active(size_t n_args, const mp_obj_t *args) {
} else {
mode &= ~mask;
}
- error_check(wifi_set_opmode(mode), "Cannot update i/f status");
+ error_check(wifi_set_opmode(mode), translate("Cannot update i/f status"));
return mp_const_none;
}
@@ -138,9 +139,9 @@ STATIC mp_obj_t esp_connect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
}
if (set_config) {
- error_check(wifi_station_set_config(&config), "Cannot set STA config");
+ error_check(wifi_station_set_config(&config), translate("Cannot set STA config"));
}
- error_check(wifi_station_connect(), "Cannot connect to AP");
+ error_check(wifi_station_connect(), translate("Cannot connect to AP"));
return mp_const_none;
}
@@ -148,7 +149,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(esp_connect_obj, 1, esp_connect);
STATIC mp_obj_t esp_disconnect(mp_obj_t self_in) {
require_if(self_in, STATION_IF);
- error_check(wifi_station_disconnect(), "Cannot disconnect from AP");
+ error_check(wifi_station_disconnect(), translate("Cannot disconnect from AP"));
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_disconnect_obj, esp_disconnect);
@@ -169,7 +170,7 @@ STATIC mp_obj_t esp_status(size_t n_args, const mp_obj_t *args) {
return MP_OBJ_NEW_SMALL_INT(wifi_station_get_rssi());
}
}
- mp_raise_ValueError("unknown status param");
+ mp_raise_ValueError(translate("unknown status param"));
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_status_obj, 1, 2, esp_status);
@@ -218,7 +219,7 @@ STATIC mp_obj_t esp_scan(mp_obj_t self_in) {
require_if(self_in, STATION_IF);
if ((wifi_get_opmode() & STATION_MODE) == 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
- "STA must be active"));
+ translate("STA must be active")));
}
mp_obj_t list = mp_obj_new_list(0, NULL);
esp_scan_list = &list;
@@ -235,7 +236,7 @@ STATIC mp_obj_t esp_scan(mp_obj_t self_in) {
ets_loop_iter();
}
if (list == MP_OBJ_NULL) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "scan failed"));
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, translate("scan failed")));
}
return list;
}
@@ -302,7 +303,7 @@ STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) {
}
if (!wifi_set_ip_info(self->if_id, &info)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
- "wifi_set_ip_info() failed"));
+ translate("wifi_set_ip_info() failed")));
}
dns_setserver(0, &dns_addr);
if (restart_dhcp_server) {
@@ -315,7 +316,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_ifconfig_obj, 1, 2, esp_ifconfig)
STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
if (n_args != 1 && kwargs->used != 0) {
- mp_raise_TypeError("either pos or kw args are allowed");
+ mp_raise_TypeError(translate("either pos or kw args are allowed"));
}
wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]);
@@ -325,9 +326,9 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
} cfg;
if (self->if_id == STATION_IF) {
- error_check(wifi_station_get_config(&cfg.sta), "can't get STA config");
+ error_check(wifi_station_get_config(&cfg.sta), translate("can't get STA config"));
} else {
- error_check(wifi_softap_get_config(&cfg.ap), "can't get AP config");
+ error_check(wifi_softap_get_config(&cfg.ap), translate("can't get AP config"));
}
int req_if = -1;
@@ -342,7 +343,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(kwargs->table[i].value, &bufinfo, MP_BUFFER_READ);
if (bufinfo.len != 6) {
- mp_raise_ValueError("invalid buffer length");
+ mp_raise_ValueError(translate("invalid buffer length"));
}
wifi_set_macaddr(self->if_id, bufinfo.buf);
break;
@@ -401,9 +402,9 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
}
if (self->if_id == STATION_IF) {
- error_check(wifi_station_set_config(&cfg.sta), "can't set STA config");
+ error_check(wifi_station_set_config(&cfg.sta), translate("can't set STA config"));
} else {
- error_check(wifi_softap_set_config(&cfg.ap), "can't set AP config");
+ error_check(wifi_softap_set_config(&cfg.ap), translate("can't set AP config"));
}
return mp_const_none;
@@ -412,7 +413,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
// Get config
if (n_args != 2) {
- mp_raise_TypeError("can query only one param");
+ mp_raise_TypeError(translate("can query only one param"));
}
mp_obj_t val;
@@ -465,7 +466,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
return val;
unknown:
- mp_raise_ValueError("unknown config param");
+ mp_raise_ValueError(translate("unknown config param"));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(esp_config_obj, 1, esp_config);
diff --git a/ports/nrf/common-hal/analogio/AnalogIn.c b/ports/nrf/common-hal/analogio/AnalogIn.c
index a2f452b35..795191084 100644
--- a/ports/nrf/common-hal/analogio/AnalogIn.c
+++ b/ports/nrf/common-hal/analogio/AnalogIn.c
@@ -27,6 +27,7 @@
#include "common-hal/analogio/AnalogIn.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#include "nrfx_saadc.h"
#include "nrf_gpio.h"
@@ -35,7 +36,7 @@
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin) {
if (pin->adc_channel == 0)
- mp_raise_ValueError("Pin does not have ADC capabilities");
+ mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
nrf_gpio_cfg_default(NRF_GPIO_PIN_MAP(pin->port, pin->pin));
diff --git a/ports/nrf/common-hal/analogio/AnalogOut.c b/ports/nrf/common-hal/analogio/AnalogOut.c
index d1fd4982b..654639b59 100644
--- a/ports/nrf/common-hal/analogio/AnalogOut.c
+++ b/ports/nrf/common-hal/analogio/AnalogOut.c
@@ -24,17 +24,17 @@
* THE SOFTWARE.
*/
+#include "shared-bindings/analogio/AnalogOut.h"
+
#include <stdint.h>
#include <string.h>
#include "py/mperrno.h"
#include "py/runtime.h"
-
-#include "shared-bindings/analogio/AnalogOut.h"
-
+#include "supervisor/shared/translate.h"
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin) {
- mp_raise_RuntimeError("AnalogOut functionality not supported");
+ mp_raise_RuntimeError(translate("AnalogOut functionality not supported"));
}
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c
index f42189162..7a29da153 100644
--- a/ports/nrf/common-hal/busio/I2C.c
+++ b/ports/nrf/common-hal/busio/I2C.c
@@ -29,6 +29,7 @@
#include "shared-bindings/busio/I2C.h"
#include "py/mperrno.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#include "nrfx_twim.h"
#include "nrf_gpio.h"
@@ -54,7 +55,7 @@ static uint8_t twi_error_to_mp(const nrfx_err_t err) {
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t frequency, uint32_t timeout) {
if (scl->pin == sda->pin)
- mp_raise_ValueError("Invalid pins");
+ mp_raise_ValueError(translate("Invalid pins"));
const nrfx_twim_t instance = NRFX_TWIM_INSTANCE(INST_NO);
self->twim = instance;
diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c
index dbc6a8533..765c987b5 100644
--- a/ports/nrf/common-hal/busio/UART.c
+++ b/ports/nrf/common-hal/busio/UART.c
@@ -32,6 +32,7 @@
#include "py/mperrno.h"
#include "py/runtime.h"
#include "py/stream.h"
+#include "supervisor/shared/translate.h"
#include "tick.h"
@@ -41,15 +42,15 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout,
uint8_t receiver_buffer_size) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
}
bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
}
void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
if (common_hal_busio_uart_deinited(self)) {
return;
}
@@ -58,32 +59,32 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
// Read characters.
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return 0;
}
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return 0;
}
uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return self->baudrate;
}
void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
self->baudrate = baudrate;
}
uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return 0;
}
bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return false;
}
diff --git a/ports/nrf/common-hal/digitalio/DigitalInOut.c b/ports/nrf/common-hal/digitalio/DigitalInOut.c
index b84877703..4db9e5efa 100644
--- a/ports/nrf/common-hal/digitalio/DigitalInOut.c
+++ b/ports/nrf/common-hal/digitalio/DigitalInOut.c
@@ -26,6 +26,7 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#include "nrf_gpio.h"
@@ -154,7 +155,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
NRF_GPIO_Type *reg = nrf_gpio_pin_port_decode(&pin);
if (nrf_gpio_pin_dir_get(pin) == NRF_GPIO_PIN_DIR_OUTPUT) {
- mp_raise_AttributeError("Cannot get pull while in output mode");
+ mp_raise_AttributeError(translate("Cannot get pull while in output mode"));
return PULL_NONE;
}
diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c
index 0cceb6a66..2ce3e8bf5 100644
--- a/ports/nrf/common-hal/microcontroller/Processor.c
+++ b/ports/nrf/common-hal/microcontroller/Processor.c
@@ -26,6 +26,7 @@
#include "common-hal/microcontroller/Processor.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#ifdef BLUETOOTH_SD
#include "nrf_sdm.h"
@@ -45,7 +46,7 @@ float common_hal_mcu_processor_get_temperature(void) {
uint32_t err_code = sd_temp_get(&temp);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not get temperature. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not get temperature. status: 0x%02x"), (uint16_t)err_code));
return 0;
}
diff --git a/ports/nrf/common-hal/pulseio/PWMOut.c b/ports/nrf/common-hal/pulseio/PWMOut.c
index d23662948..c85b77fcd 100644
--- a/ports/nrf/common-hal/pulseio/PWMOut.c
+++ b/ports/nrf/common-hal/pulseio/PWMOut.c
@@ -32,6 +32,7 @@
#include "common-hal/pulseio/PWMOut.h"
#include "nrf_gpio.h"
#include "shared-bindings/pulseio/PWMOut.h"
+#include "supervisor/shared/translate.h"
#define PWM_MAX_MODULE 3
#define PWM_MAX_CHANNEL 4
@@ -223,7 +224,7 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
if (frequency == 0 || frequency > 16000000) {
- mp_raise_ValueError("Invalid PWM frequency");
+ mp_raise_ValueError(translate("Invalid PWM frequency"));
}
self->freq = frequency;
@@ -238,4 +239,3 @@ uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
return self->variable_freq;
}
-
diff --git a/ports/nrf/common-hal/usb_hid/Device.c b/ports/nrf/common-hal/usb_hid/Device.c
index c2fff7001..6acb2717f 100644
--- a/ports/nrf/common-hal/usb_hid/Device.c
+++ b/ports/nrf/common-hal/usb_hid/Device.c
@@ -29,6 +29,7 @@
#include "common-hal/usb_hid/Device.h"
#include "py/runtime.h"
#include "shared-bindings/usb_hid/Device.h"
+#include "supervisor/shared/translate.h"
#include "tusb.h"
uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self) {
@@ -41,7 +42,7 @@ uint8_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self) {
void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t* report, uint8_t len) {
if (len != self->report_length) {
- mp_raise_ValueError_varg("Buffer incorrect size. Should be %d bytes.", self->report_length);
+ mp_raise_ValueError_varg(translate("Buffer incorrect size. Should be %d bytes."), self->report_length);
}
// Wait until interface is ready, timeout = 2 seconds
@@ -49,13 +50,13 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t*
while ( (ticks_ms < end_ticks) && !tud_hid_generic_ready() ) { }
if ( !tud_hid_generic_ready() ) {
- mp_raise_msg(&mp_type_OSError, "USB Busy");
+ mp_raise_msg(&mp_type_OSError, translate("USB Busy"));
}
memcpy(self->report_buffer, report, len);
if ( !tud_hid_generic_report(self->report_id, self->report_buffer, len) ) {
- mp_raise_msg(&mp_type_OSError, "USB Error");
+ mp_raise_msg(&mp_type_OSError, translate("USB Error"));
}
}
@@ -85,4 +86,3 @@ void tud_hid_generic_set_report_cb(uint8_t report_id, hid_report_type_t report_t
}
}
}
-
diff --git a/ports/nrf/drivers/bluetooth/ble_drv.c b/ports/nrf/drivers/bluetooth/ble_drv.c
index 28d728d71..7e95c2eab 100644
--- a/ports/nrf/drivers/bluetooth/ble_drv.c
+++ b/ports/nrf/drivers/bluetooth/ble_drv.c
@@ -35,6 +35,7 @@
#endif
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#include "ble_drv.h"
#include "mpconfigport.h"
#include "nrf_sdm.h"
@@ -195,7 +196,7 @@ uint32_t ble_drv_stack_enable(void) {
(const uint8_t *)device_name,
strlen(device_name))) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Cannot apply GAP parameters."));
+ translate("Cannot apply GAP parameters.")));
}
// set connection parameters
@@ -209,7 +210,7 @@ uint32_t ble_drv_stack_enable(void) {
if (sd_ble_gap_ppcp_set(&gap_conn_params) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Cannot set PPCP parameters."));
+ translate("Cannot set PPCP parameters.")));
}
return err_code;
@@ -241,7 +242,7 @@ void ble_drv_address_get(ble_drv_addr_t * p_addr) {
if (err_code != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not query for the device address."));
+ translate("Can not query for the device address.")));
}
BLE_DRIVER_LOG("ble address, type: " HEX2_FMT ", " \
@@ -260,7 +261,7 @@ bool ble_drv_uuid_add_vs(uint8_t * p_uuid, uint8_t * idx) {
if (sd_ble_uuid_vs_add((ble_uuid128_t const *)p_uuid, idx) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not add Vendor Specific 128-bit UUID."));
+ translate("Can not add Vendor Specific 128-bit UUID.")));
}
return true;
@@ -280,7 +281,7 @@ bool ble_drv_service_add(ubluepy_service_obj_t * p_service_obj) {
&uuid,
&p_service_obj->handle) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not add Service."));
+ translate("Can not add Service.")));
}
} else if (p_service_obj->p_uuid->type == BLE_UUID_TYPE_BLE) {
BLE_DRIVER_LOG("adding service\n");
@@ -294,7 +295,7 @@ bool ble_drv_service_add(ubluepy_service_obj_t * p_service_obj) {
&uuid,
&p_service_obj->handle) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not add Service."));
+ translate("Can not add Service.")));
}
}
return true;
@@ -369,7 +370,7 @@ bool ble_drv_characteristic_add(ubluepy_characteristic_obj_t * p_char_obj) {
&attr_char_value,
&handles) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not add Characteristic."));
+ translate("Can not add Characteristic.")));
}
// apply handles to object instance
@@ -396,7 +397,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
p_adv_params->p_device_name,
p_adv_params->device_name_len) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not apply device name in the stack."));
+ translate("Can not apply device name in the stack.")));
}
BLE_DRIVER_LOG("Device name applied\n");
@@ -460,13 +461,13 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
// calculate total size of uuids
if (sd_ble_uuid_encode(&uuid, &encoded_size, NULL) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not encode UUID, to check length."));
+ translate("Can not encode UUID, to check length.")));
}
// do encoding into the adv buffer
if (sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can encode UUID into the advertisment packet."));
+ translate("Can encode UUID into the advertisment packet.")));
}
BLE_DRIVER_LOG("encoded uuid for service %u: ", 0);
@@ -510,13 +511,13 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
// calculate total size of uuids
if (sd_ble_uuid_encode(&uuid, &encoded_size, NULL) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not encode UUID, to check length."));
+ translate("Can not encode UUID, to check length.")));
}
// do encoding into the adv buffer
if (sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can encode UUID into the advertisment packet."));
+ translate("Can encode UUID into the advertisment packet.")));
}
BLE_DRIVER_LOG("encoded uuid for service %u: ", 0);
@@ -541,7 +542,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
if ((p_adv_params->data_len > 0) && (p_adv_params->p_data != NULL)) {
if (p_adv_params->data_len + byte_pos > BLE_GAP_ADV_MAX_SIZE) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not fit data into the advertisment packet."));
+ translate("Can not fit data into the advertisment packet.")));
}
memcpy(adv_data, p_adv_params->p_data, p_adv_params->data_len);
@@ -554,7 +555,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
if ((err_code = sd_ble_gap_adv_data_set(adv_data, byte_pos, NULL, 0)) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not apply advertisment data. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not apply advertisment data. status: 0x%02x"), (uint16_t)err_code));
}
BLE_DRIVER_LOG("Set Adv data size: " UINT_FMT "\n", byte_pos);
#endif
@@ -600,7 +601,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
if ((err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params)) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not apply advertisment data. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not apply advertisment data. status: 0x%02x"), (uint16_t)err_code));
}
err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_DEFAULT);
#elif (BLUETOOTH_SD == 132 && BLE_API_VERSION == 4)
@@ -610,7 +611,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
#endif
if (err_code != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not start advertisment. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not start advertisment. status: 0x%02x"), (uint16_t)err_code));
}
m_adv_in_progress = true;
@@ -627,7 +628,7 @@ void ble_drv_advertise_stop(void) {
if ((err_code = sd_ble_gap_adv_stop()) != 0) {
#endif
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not stop advertisment. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not stop advertisment. status: 0x%02x"), (uint16_t)err_code));
}
}
m_adv_in_progress = false;
@@ -646,7 +647,7 @@ void ble_drv_attr_s_read(uint16_t conn_handle, uint16_t handle, uint16_t len, ui
&gatts_value);
if (err_code != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not read attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not read attribute value. status: 0x%02x"), (uint16_t)err_code));
}
}
@@ -663,7 +664,7 @@ void ble_drv_attr_s_write(uint16_t conn_handle, uint16_t handle, uint16_t len, u
if (err_code != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not write attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not write attribute value. status: 0x%02x"), (uint16_t)err_code));
}
}
@@ -687,7 +688,7 @@ void ble_drv_attr_s_notify(uint16_t conn_handle, uint16_t handle, uint16_t len,
uint32_t err_code;
if ((err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params)) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not notify attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not notify attribute value. status: 0x%02x"), (uint16_t)err_code));
}
}
@@ -722,7 +723,7 @@ void ble_drv_attr_c_read(uint16_t conn_handle, uint16_t handle, mp_obj_t obj, bl
0);
if (err_code != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not read attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not read attribute value. status: 0x%02x"), (uint16_t)err_code));
}
while (gattc_char_data_handle != NULL) {
@@ -752,7 +753,7 @@ void ble_drv_attr_c_write(uint16_t conn_handle, uint16_t handle, uint16_t len, u
if (err_code != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not write attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not write attribute value. status: 0x%02x"), (uint16_t)err_code));
}
while (m_write_done != true) {
@@ -780,7 +781,7 @@ void ble_drv_scan_start(void) {
if ((err_code = sd_ble_gap_scan_start(&scan_params)) != 0) {
#endif
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not start scanning. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not start scanning. status: 0x%02x"), (uint16_t)err_code));
}
}
@@ -825,7 +826,7 @@ void ble_drv_connect(uint8_t * p_addr, uint8_t addr_type) {
if ((err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_DEFAULT)) != 0) {
#endif
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not connect. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not connect. status: 0x%02x"), (uint16_t)err_code));
}
}
diff --git a/ports/nrf/modules/ubluepy/ubluepy_characteristic.c b/ports/nrf/modules/ubluepy/ubluepy_characteristic.c
index 8e1d0eb1e..0935615a5 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_characteristic.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_characteristic.c
@@ -26,6 +26,7 @@
#include "py/obj.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#if MICROPY_PY_UBLUEPY_PERIPHERAL || MICROPY_PY_UBLUEPY_CENTRAL
@@ -64,7 +65,7 @@ STATIC mp_obj_t ubluepy_characteristic_make_new(const mp_obj_type_t *type, size_
// (void)sd_characterstic_add(s);
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID parameter"));
+ translate("Invalid UUID parameter")));
}
if (args[1].u_int > 0) {
diff --git a/ports/nrf/modules/ubluepy/ubluepy_service.c b/ports/nrf/modules/ubluepy/ubluepy_service.c
index 68d905743..59b81234f 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_service.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_service.c
@@ -27,6 +27,7 @@
#include "py/obj.h"
#include "py/runtime.h"
#include "py/objlist.h"
+#include "supervisor/shared/translate.h"
#if MICROPY_PY_UBLUEPY_PERIPHERAL || MICROPY_PY_UBLUEPY_CENTRAL
@@ -69,14 +70,14 @@ STATIC mp_obj_t ubluepy_service_make_new(const mp_obj_type_t *type, size_t n_arg
s->type = type;
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid Service type"));
+ translate("Invalid Service type")));
}
(void)ble_drv_service_add(s);
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID parameter"));
+ translate("Invalid UUID parameter")));
}
// clear reference to peripheral
@@ -128,7 +129,7 @@ STATIC mp_obj_t service_get_characteristic(mp_obj_t self_in, mp_obj_t uuid) {
// validate that there is an UUID object passed in as parameter
if (!(MP_OBJ_IS_TYPE(uuid, &ubluepy_uuid_type))) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID parameter"));
+ translate("Invalid UUID parameter")));
}
mp_obj_t * chars = NULL;
diff --git a/ports/nrf/modules/ubluepy/ubluepy_uuid.c b/ports/nrf/modules/ubluepy/ubluepy_uuid.c
index 380d2e404..b45494e41 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_uuid.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_uuid.c
@@ -28,6 +28,7 @@
#include "py/runtime.h"
#include "py/objstr.h"
#include "py/misc.h"
+#include "supervisor/shared/translate.h"
#if MICROPY_PY_UBLUEPY
@@ -123,7 +124,7 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args,
ble_drv_uuid_add_vs(buffer, &s->uuid_vs_idx);
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID string length"));
+ translate("Invalid UUID string length")));
}
} else if (MP_OBJ_IS_TYPE(uuid_obj, &ubluepy_uuid_type)) {
// deep copy instance
@@ -133,7 +134,7 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args,
s->value[1] = p_old->value[1];
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID parameter"));
+ translate("Invalid UUID parameter")));
}
return MP_OBJ_FROM_PTR(s);
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index 1c112e0b2..1d36198ec 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -242,7 +242,7 @@ freedos:
# build an interpreter for coverage testing and do the testing
coverage:
- $(MAKE) V=2 \
+ $(MAKE) \
COPT="-O0" CFLAGS_EXTRA='$(CFLAGS_EXTRA) -DMP_CONFIGFILE="<mpconfigport_coverage.h>" \
-fprofile-arcs -ftest-coverage \
-Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wsign-compare \
diff --git a/ports/unix/file.c b/ports/unix/file.c
index 165bbd00b..98ac1b3cc 100644
--- a/ports/unix/file.c
+++ b/ports/unix/file.c
@@ -35,6 +35,7 @@
#include "py/stream.h"
#include "py/builtin.h"
#include "py/mphal.h"
+#include "supervisor/shared/translate.h"
#include "fdfile.h"
#if MICROPY_PY_IO && !MICROPY_VFS
@@ -46,7 +47,7 @@
#ifdef MICROPY_CPYTHON_COMPAT
STATIC void check_fd_is_open(const mp_obj_fdfile_t *o) {
if (o->fd < 0) {
- mp_raise_ValueError("I/O operation on closed file");
+ mp_raise_ValueError(translate("I/O operation on closed file"));
}
}
#else
diff --git a/ports/unix/modffi.c b/ports/unix/modffi.c
index a12c249e2..fcbcebc39 100644
--- a/ports/unix/modffi.c
+++ b/ports/unix/modffi.c
@@ -36,6 +36,8 @@
#include "py/binary.h"
#include "py/mperrno.h"
+#include "supervisor/shared/translate.h"
+
/*
* modffi uses character codes to encode a value type, based on "struct"
* module type codes, with some extensions and overridings.
@@ -133,7 +135,7 @@ STATIC ffi_type *get_ffi_type(mp_obj_t o_in)
}
// TODO: Support actual libffi type objects
- mp_raise_TypeError("Unknown type");
+ mp_raise_TypeError(translate("Unknown type"));
}
STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
@@ -202,7 +204,7 @@ STATIC mp_obj_t make_func(mp_obj_t rettype_in, void *func, mp_obj_t argtypes_in)
int res = ffi_prep_cif(&o->cif, FFI_DEFAULT_ABI, nparams, char2ffi_type(*rettype), o->params);
if (res != FFI_OK) {
- mp_raise_ValueError("Error in ffi_prep_cif");
+ mp_raise_ValueError(translate("Error in ffi_prep_cif"));
}
return MP_OBJ_FROM_PTR(o);
@@ -260,12 +262,12 @@ STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t
int res = ffi_prep_cif(&o->cif, FFI_DEFAULT_ABI, nparams, char2ffi_type(*rettype), o->params);
if (res != FFI_OK) {
- mp_raise_ValueError("Error in ffi_prep_cif");
+ mp_raise_ValueError(translate("Error in ffi_prep_cif"));
}
res = ffi_prep_closure_loc(o->clo, &o->cif, call_py_func, MP_OBJ_TO_PTR(func_in), o->func);
if (res != FFI_OK) {
- mp_raise_ValueError("ffi_prep_closure_loc");
+ mp_raise_ValueError(translate("ffi_prep_closure_loc"));
}
return MP_OBJ_FROM_PTR(o);
@@ -408,7 +410,7 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
}
error:
- mp_raise_TypeError("Don't know how to pass object to native function");
+ mp_raise_TypeError(translate("Don't know how to pass object to native function"));
}
STATIC const mp_obj_type_t ffifunc_type = {
diff --git a/ports/unix/modmachine.c b/ports/unix/modmachine.c
index 48dddec0a..b2bca1206 100644
--- a/ports/unix/modmachine.c
+++ b/ports/unix/modmachine.c
@@ -35,6 +35,8 @@
#include "extmod/machine_signal.h"
#include "extmod/machine_pulse.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PLAT_DEV_MEM
#include <errno.h>
#include <fcntl.h>
@@ -48,7 +50,7 @@
uintptr_t mod_machine_mem_get_addr(mp_obj_t addr_o, uint align) {
uintptr_t addr = mp_obj_int_get_truncated(addr_o);
if ((addr & (align - 1)) != 0) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "address %08x is not aligned to %d bytes", addr, align));
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("address %08x is not aligned to %d bytes"), addr, align));
}
#if MICROPY_PLAT_DEV_MEM
{
diff --git a/ports/unix/modusocket.c b/ports/unix/modusocket.c
index ba50e6165..9b9869f5b 100644
--- a/ports/unix/modusocket.c
+++ b/ports/unix/modusocket.c
@@ -45,6 +45,8 @@
#include "py/builtin.h"
#include "py/mphal.h"
+#include "supervisor/shared/translate.h"
+
/*
The idea of this module is to implement reasonable minimum of
socket-related functions to write typical clients and servers.
@@ -469,7 +471,7 @@ STATIC mp_obj_t mod_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
if (res != 0) {
// CPython: socket.gaierror
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[addrinfo error %d]", res));
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, translate("[addrinfo error %d]"), res));
}
assert(addr_list);