Skip to content

Commit 4f2ba9f

Browse files
committed
esp8266: Convert to use new MP_Exxx errno symbols.
These symbols are still defined in terms of the system Exxx symbols, and can be switched to internal numeric definitions at a later stage. Note that extmod/modlwip still uses many system Exxx symbols.
1 parent 5ab98d5 commit 4f2ba9f

6 files changed

Lines changed: 10 additions & 11 deletions

File tree

esp8266/modesp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
#include <stdio.h>
2828
#include <string.h>
2929
#include <stdbool.h>
30-
#include <errno.h>
3130

3231
#include "py/nlr.h"
3332
#include "py/obj.h"
3433
#include "py/gc.h"
3534
#include "py/runtime.h"
35+
#include "py/mperrno.h"
3636
#include "py/mphal.h"
3737
#include "netutils.h"
3838
#include "queue.h"
@@ -577,7 +577,7 @@ STATIC mp_obj_t esp_flash_read(mp_obj_t offset_in, mp_obj_t len_or_buf_in) {
577577
if (alloc_buf) {
578578
m_del(byte, buf, len);
579579
}
580-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? ETIMEDOUT : EIO)));
580+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO)));
581581
}
582582
STATIC MP_DEFINE_CONST_FUN_OBJ_2(esp_flash_read_obj, esp_flash_read);
583583

@@ -594,7 +594,7 @@ STATIC mp_obj_t esp_flash_write(mp_obj_t offset_in, const mp_obj_t buf_in) {
594594
}
595595
nlr_raise(mp_obj_new_exception_arg1(
596596
&mp_type_OSError,
597-
MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? ETIMEDOUT : EIO)));
597+
MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO)));
598598
}
599599
STATIC MP_DEFINE_CONST_FUN_OBJ_2(esp_flash_write_obj, esp_flash_write);
600600

@@ -606,7 +606,7 @@ STATIC mp_obj_t esp_flash_erase(mp_obj_t sector_in) {
606606
}
607607
nlr_raise(mp_obj_new_exception_arg1(
608608
&mp_type_OSError,
609-
MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? ETIMEDOUT : EIO)));
609+
MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO)));
610610
}
611611
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_flash_erase_obj, esp_flash_erase);
612612

esp8266/modnetwork.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <stdio.h>
2828
#include <stdint.h>
2929
#include <string.h>
30-
#include <errno.h>
3130

3231
#include "py/nlr.h"
3332
#include "py/objlist.h"

esp8266/modpybspi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <stdio.h>
2828
#include <stdint.h>
2929
#include <string.h>
30-
#include <errno.h>
3130

3231
#include "ets_sys.h"
3332
#include "etshal.h"

esp8266/modpybuart.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
#include <stdio.h>
2828
#include <stdint.h>
2929
#include <string.h>
30-
#include <errno.h>
3130

3231
#include "ets_sys.h"
3332
#include "uart.h"
3433

3534
#include "py/runtime.h"
3635
#include "py/stream.h"
36+
#include "py/mperrno.h"
3737
#include "modpyb.h"
3838

3939
// baudrate is currently fixed to this value
@@ -136,7 +136,7 @@ STATIC mp_uint_t pyb_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, i
136136

137137
// wait for first char to become available
138138
if (!uart_rx_wait(self->timeout * 1000)) {
139-
*errcode = EAGAIN;
139+
*errcode = MP_EAGAIN;
140140
return MP_STREAM_ERROR;
141141
}
142142

@@ -173,7 +173,7 @@ STATIC mp_uint_t pyb_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t
173173
}
174174

175175
STATIC mp_uint_t pyb_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
176-
*errcode = EINVAL;
176+
*errcode = MP_EINVAL;
177177
return MP_STREAM_ERROR;
178178
}
179179

esp8266/moduos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
*/
2626

2727
#include <string.h>
28-
#include <errno.h>
2928

3029
#include "py/mpconfig.h"
3130
#include "py/nlr.h"
3231
#include "py/obj.h"
3332
#include "py/objtuple.h"
3433
#include "py/objstr.h"
3534
#include "py/runtime.h"
35+
#include "py/mperrno.h"
3636
#include "extmod/misc.h"
3737
#include "genhdr/mpversion.h"
3838
#include "esp_mphal.h"
@@ -74,7 +74,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
7474
#if MICROPY_VFS_FAT
7575
mp_obj_t vfs_proxy_call(qstr method_name, mp_uint_t n_args, const mp_obj_t *args) {
7676
if (MP_STATE_PORT(fs_user_mount)[0] == NULL) {
77-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(ENODEV)));
77+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(MP_ENODEV)));
7878
}
7979

8080
mp_obj_t meth[n_args + 2];

esp8266/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define MICROPY_ENABLE_SOURCE_LINE (1)
2525
#define MICROPY_MODULE_WEAK_LINKS (1)
2626
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
27+
#define MICROPY_USE_INTERNAL_ERRNO (0)
2728
#define MICROPY_PY_BUILTINS_COMPLEX (0)
2829
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
2930
#define MICROPY_PY_BUILTINS_BYTEARRAY (1)

0 commit comments

Comments
 (0)