Unify some error strings

This commit is contained in:
Scott Shawcroft 2023-07-20 11:16:31 -07:00
parent 305303996d
commit 5f082561b3
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
20 changed files with 65 additions and 94 deletions

View File

@ -126,8 +126,10 @@ msgstr ""
#: ports/espressif/common-hal/espulp/ULP.c
#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
#: ports/mimxrt10xx/common-hal/usb_host/Port.c
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
#: ports/raspberrypi/common-hal/usb_host/Port.c
#: shared-bindings/digitalio/DigitalInOut.c
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
@ -182,6 +184,7 @@ msgid "%q must be 1 when %q is True"
msgstr ""
#: py/argcheck.c shared-bindings/gifio/GifWriter.c
#: shared-module/gifio/OnDiskGif.c
msgid "%q must be <= %d"
msgstr ""
@ -779,10 +782,6 @@ msgstr ""
msgid "Cannot subclass slice"
msgstr ""
#: shared-module/bitbangio/SPI.c
msgid "Cannot transfer without MOSI and MISO pins"
msgstr ""
#: shared-bindings/pwmio/PWMOut.c
msgid "Cannot vary frequency on a timer that is already in use"
msgstr ""
@ -1090,13 +1089,10 @@ msgstr ""
msgid "Half duplex SPI is not implemented"
msgstr ""
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c
#: ports/stm/common-hal/sdioio/SDCard.c
msgid "Hardware busy, try alternative pins"
msgstr ""
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/busio/UART.c
#: ports/stm/common-hal/canio/CAN.c ports/stm/common-hal/sdioio/SDCard.c
msgid "Hardware in use, try alternative pins"
msgstr ""
@ -1355,14 +1351,6 @@ msgstr ""
msgid "Mismatched swap flag"
msgstr ""
#: ports/mimxrt10xx/common-hal/busio/SPI.c
msgid "Missing MISO or MOSI Pin"
msgstr ""
#: ports/stm/common-hal/busio/SPI.c
msgid "Missing MISO or MOSI pin"
msgstr ""
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
#, c-format
msgid "Missing first_in_pin. Instruction %d reads pin(s)"
@ -1436,6 +1424,14 @@ msgid "Nimble out of memory"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/espressif/common-hal/busio/SPI.c
#: ports/espressif/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/SPI.c
#: ports/stm/common-hal/busio/UART.c shared-bindings/displayio/FourWire.c
#: shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/paralleldisplay/ParallelBus.c shared-module/bitbangio/SPI.c
msgid "No %q pin"
msgstr ""
@ -1469,36 +1465,6 @@ msgstr ""
msgid "No IP"
msgstr ""
#: ports/espressif/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
msgid "No MISO Pin"
msgstr ""
#: ports/stm/common-hal/busio/SPI.c shared-module/bitbangio/SPI.c
msgid "No MISO pin"
msgstr ""
#: ports/espressif/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
msgid "No MOSI Pin"
msgstr ""
#: ports/stm/common-hal/busio/SPI.c shared-module/bitbangio/SPI.c
msgid "No MOSI pin"
msgstr ""
#: ports/espressif/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "No RX pin"
msgstr ""
#: ports/espressif/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "No TX pin"
msgstr ""
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
msgid "No available clocks"
msgstr ""
@ -2405,6 +2371,7 @@ msgstr ""
#: ports/espressif/boards/m5stack_core_basic/mpconfigboard.h
#: ports/espressif/boards/m5stack_core_fire/mpconfigboard.h
#: ports/espressif/boards/m5stack_stick_c/mpconfigboard.h
#: ports/espressif/boards/m5stack_stick_c_plus/mpconfigboard.h
msgid "You pressed button A at start up."
msgstr ""
@ -3628,11 +3595,6 @@ msgstr ""
msgid "no module named '%q'"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/paralleldisplay/ParallelBus.c
msgid "no reset pin available"
msgstr ""
#: shared-module/sdcardio/SDCard.c
msgid "no response from SD card"
msgstr ""

View File

@ -352,7 +352,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
if (self->tx_pin == NULL) {
mp_raise_ValueError(translate("No TX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
}
COMPLETE_MEMORY_READS;
@ -400,7 +400,7 @@ STATIC void enable_interrupt(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) {
if (self->rx_pin == NULL) {
mp_raise_ValueError(translate("No RX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
}
if (len == 0) {

View File

@ -186,7 +186,7 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) {
bool common_hal_busio_spi_write(busio_spi_obj_t *self,
const uint8_t *data, size_t len) {
if (self->MOSI == NULL) {
mp_raise_ValueError(translate("No MOSI Pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
return common_hal_busio_spi_transfer(self, data, NULL, len);
}
@ -194,7 +194,7 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
bool common_hal_busio_spi_read(busio_spi_obj_t *self,
uint8_t *data, size_t len, uint8_t write_value) {
if (self->MISO == NULL) {
mp_raise_ValueError(translate("No MISO Pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
}
if (self->MOSI == NULL) {
return common_hal_busio_spi_transfer(self, NULL, data, len);
@ -210,10 +210,10 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self,
return true;
}
if (self->MOSI == NULL && data_out != NULL) {
mp_raise_ValueError(translate("No MOSI Pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
if (self->MISO == NULL && data_in != NULL) {
mp_raise_ValueError(translate("No MISO Pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
}
spi_transaction_t transactions[MAX_SPI_TRANSACTIONS];

View File

@ -304,7 +304,7 @@ 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) {
if (self->rx_pin == NULL) {
mp_raise_ValueError(translate("No RX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
}
if (len == 0) {
// Nothing to read.
@ -357,7 +357,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
if (self->tx_pin == NULL) {
mp_raise_ValueError(translate("No TX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
}
size_t left_to_write = len;

View File

@ -182,7 +182,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
self->spi = mcu_spi_banks[self->clock->bank_idx - 1];
} else {
if (spi_taken) {
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
} else {
raise_ValueError_invalid_pins();
}
@ -331,7 +331,7 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
return true;
}
if (self->mosi == NULL) {
mp_raise_ValueError(translate("No MOSI Pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
lpspi_transfer_t xfer = { 0 };
@ -349,7 +349,7 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self,
return true;
}
if (self->miso == NULL) {
mp_raise_ValueError(translate("No MISO Pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
}
LPSPI_SetDummyData(self->spi, write_value);
@ -367,8 +367,11 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_ou
if (len == 0) {
return true;
}
if (self->miso == NULL || self->mosi == NULL) {
mp_raise_ValueError(translate("Missing MISO or MOSI Pin"));
if (self->MOSI == NULL && data_out != NULL) {
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
if (self->MISO == NULL && data_in != NULL) {
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
}
LPSPI_SetDummyData(self->spi, 0xFF);

View File

@ -401,7 +401,7 @@ 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) {
if (self->rx == NULL) {
mp_raise_ValueError(translate("No RX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
}
if (len == 0) {
@ -458,7 +458,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
if (self->tx == NULL) {
mp_raise_ValueError(translate("No TX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
}
if (self->rs485_dir && len) {
GPIO_PinWrite(self->rs485_dir->gpio, self->rs485_dir->number, !self->rs485_invert);

View File

@ -297,7 +297,7 @@ 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) {
if (nrf_uarte_rx_pin_get(self->uarte->p_reg) == NRF_UARTE_PSEL_DISCONNECTED) {
mp_raise_ValueError(translate("No RX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
}
uint64_t start_ticks = supervisor_ticks_ms64();
@ -347,7 +347,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
if (nrf_uarte_tx_pin_get(self->uarte->p_reg) == NRF_UARTE_PSEL_DISCONNECTED) {
mp_raise_ValueError(translate("No TX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
}
if (len == 0) {

View File

@ -211,7 +211,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
if (self->tx_pin == NO_PIN) {
mp_raise_ValueError(translate("No TX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
}
if (self->rs485_dir_pin != NO_PIN) {
@ -239,7 +239,7 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data,
// Read characters.
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
if (self->rx_pin == NO_PIN) {
mp_raise_ValueError(translate("No RX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
}
if (len == 0) {

View File

@ -72,7 +72,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
common_hal_mcu_pin_claim(sda);
in_used = true;
} else {
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
}
} else {
raise_ValueError_invalid_pins();

View File

@ -95,7 +95,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
mp_raise_ValueError(translate("SPI init error"));
}
} else {
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
}
} else {
raise_ValueError_invalid_pins();

View File

@ -131,7 +131,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
context = self;
} else {
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
}
} else {

View File

@ -117,7 +117,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
I2Cx = mcu_i2c_banks[self->sda->periph_index - 1];
} else {
if (i2c_taken) {
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
} else {
raise_ValueError_invalid_pins();
}

View File

@ -160,7 +160,7 @@ STATIC int check_pins(busio_spi_obj_t *self,
}
if (spi_taken) {
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
} else {
raise_ValueError_invalid_pin();
}
@ -347,7 +347,7 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) {
bool common_hal_busio_spi_write(busio_spi_obj_t *self,
const uint8_t *data, size_t len) {
if (self->mosi == NULL) {
mp_raise_ValueError(translate("No MOSI pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
HAL_StatusTypeDef result = HAL_SPI_Transmit(&self->handle, (uint8_t *)data, (uint16_t)len, HAL_MAX_DELAY);
return result == HAL_OK;
@ -356,9 +356,9 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
bool common_hal_busio_spi_read(busio_spi_obj_t *self,
uint8_t *data, size_t len, uint8_t write_value) {
if (self->miso == NULL && !self->half_duplex) {
mp_raise_ValueError(translate("No MISO pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
} else if (self->half_duplex && self->mosi == NULL) {
mp_raise_ValueError(translate("No MOSI pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
HAL_StatusTypeDef result = HAL_OK;
if ((!self->half_duplex && self->mosi == NULL) || (self->half_duplex && self->mosi != NULL && self->miso == NULL)) {
@ -372,8 +372,11 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self,
bool common_hal_busio_spi_transfer(busio_spi_obj_t *self,
const uint8_t *data_out, uint8_t *data_in, size_t len) {
if (self->miso == NULL || self->mosi == NULL) {
mp_raise_ValueError(translate("Missing MISO or MOSI pin"));
if (self->mosi == NULL && data_out != NULL) {
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
if (self->miso == NULL && data_in != NULL) {
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
}
HAL_StatusTypeDef result = HAL_SPI_TransmitReceive(&self->handle,
(uint8_t *)data_out, data_in, (uint16_t)len,HAL_MAX_DELAY);

View File

@ -293,7 +293,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
if (self->rx == NULL) {
mp_raise_ValueError(translate("No RX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
}
uint64_t start_ticks = supervisor_ticks_ms64();
@ -327,7 +327,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
if (self->tx == NULL) {
mp_raise_ValueError(translate("No TX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
}
// Disable UART IRQ to avoid resource hazards in Rx IRQ handler

View File

@ -69,7 +69,7 @@ void common_hal_canio_can_construct(canio_can_obj_t *self, const mcu_pin_obj_t *
}
if (reserved_can[periph_index]) {
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
}
const uint32_t can_frequency = 42000000;

View File

@ -113,7 +113,7 @@ STATIC int check_pins(sdioio_sdcard_obj_t *self,
}
if (sdio_taken) {
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
} else {
raise_ValueError_invalid_pin();
}

View File

@ -114,7 +114,7 @@ STATIC mp_obj_t displayio_fourwire_obj_reset(mp_obj_t self_in) {
displayio_fourwire_obj_t *self = self_in;
if (!common_hal_displayio_fourwire_reset(self)) {
mp_raise_RuntimeError(translate("no reset pin available"));
mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset);
}
return mp_const_none;
}

View File

@ -91,7 +91,7 @@ STATIC mp_obj_t displayio_i2cdisplay_obj_reset(mp_obj_t self_in) {
displayio_i2cdisplay_obj_t *self = self_in;
if (!common_hal_displayio_i2cdisplay_reset(self)) {
mp_raise_RuntimeError(translate("no reset pin available"));
mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset);
}
return mp_const_none;
}

View File

@ -122,7 +122,7 @@ STATIC mp_obj_t paralleldisplay_parallelbus_obj_reset(mp_obj_t self_in) {
paralleldisplay_parallelbus_obj_t *self = self_in;
if (!common_hal_paralleldisplay_parallelbus_reset(self)) {
mp_raise_RuntimeError(translate("no reset pin available"));
mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset);
}
return mp_const_none;
}

View File

@ -123,7 +123,7 @@ void shared_module_bitbangio_spi_unlock(bitbangio_spi_obj_t *self) {
// Writes out the given data.
bool shared_module_bitbangio_spi_write(bitbangio_spi_obj_t *self, const uint8_t *data, size_t len) {
if (len > 0 && !self->has_mosi) {
mp_raise_ValueError(translate("No MOSI pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
uint32_t delay_half = self->delay_half;
@ -178,7 +178,7 @@ bool shared_module_bitbangio_spi_write(bitbangio_spi_obj_t *self, const uint8_t
// Reads in len bytes while outputting zeroes.
bool shared_module_bitbangio_spi_read(bitbangio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_data) {
if (len > 0 && !self->has_miso) {
mp_raise_ValueError(translate("No MISO pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
}
uint32_t delay_half = self->delay_half;
@ -245,8 +245,11 @@ bool shared_module_bitbangio_spi_read(bitbangio_spi_obj_t *self, uint8_t *data,
// transfer
bool shared_module_bitbangio_spi_transfer(bitbangio_spi_obj_t *self, const uint8_t *dout, uint8_t *din, size_t len) {
if (len > 0 && (!self->has_mosi || !self->has_miso)) {
mp_raise_ValueError(translate("Cannot transfer without MOSI and MISO pins"));
if (!self->has_mosi && dout != NULL) {
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
}
if (!self->has_miso && din != NULL) {
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
}
uint32_t delay_half = self->delay_half;