Fix nrf and unix

crypto-aes
Scott Shawcroft 5 years ago
parent 2cd166b573
commit 76e0373576
No known key found for this signature in database
GPG Key ID: FD0EDC4B6C53CA59

@ -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));

@ -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) {

@ -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;

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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
}
}
}

@ -242,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 ", " \

@ -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) {

@ -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;

@ -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);

@ -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

@ -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 = {

@ -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
{

@ -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);

Loading…
Cancel
Save