Skip to content

Commit d9c168e

Browse files
committed
BUg fix:
utime.ticks_diff() and ticks_add(): Overflow error Add missing uhashlib back Updated 'utimeq' module fix handling if time values Updated 'machine.UART' module added callbacks on data, pattern and error added flush() method Various small uptates and improvements
1 parent 8487eb8 commit d9c168e

36 files changed

+441
-72
lines changed

MicroPython_BUILD/components/micropython/esp32/machine_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ STATIC mp_obj_t machine_timer_callback(size_t n_args, const mp_obj_t *args)
638638
}
639639
self->state = TIMER_PAUSED;
640640

641-
if (MP_OBJ_IS_FUN(args[1])) {
641+
if ((MP_OBJ_IS_FUN(args[1])) || (MP_OBJ_IS_METH(args[1]))) {
642642
// Set new callback
643643
self->counter = 0x00000000ULL;
644644
self->alarm = self->period;

MicroPython_BUILD/components/micropython/esp32/machine_uart.c

Lines changed: 317 additions & 38 deletions
Large diffs are not rendered by default.

MicroPython_BUILD/components/micropython/esp32/modgsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_gsm_readSMS_obj, 1, 2, mod_gsm_re
254254
//-----------------------------------------------------------------
255255
STATIC mp_obj_t mod_gsm_SMS_cb(size_t n_args, const mp_obj_t *args)
256256
{
257-
if (MP_OBJ_IS_FUN(args[0])) {
257+
if ((MP_OBJ_IS_FUN(args[0])) || (MP_OBJ_IS_METH(args[0]))) {
258258
int interval = 60;
259259
if (n_args > 1) interval = mp_obj_get_int(args[1]);
260260
if ((interval < 5) || (interval > 86400)) return mp_const_false;

MicroPython_BUILD/components/micropython/esp32/modmqtt.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ STATIC void subscribed_cb(void *self, void *params)
104104
mp_obj_t tuple[2];
105105
tuple[0] = mp_obj_new_str(client->name, strlen(client->name), 0);
106106
if (topic) tuple[1] = mp_obj_new_str(topic, strlen(topic), 0);
107-
else tuple[1] = mp_obj_new_str("?", 1, 0);;
107+
else tuple[1] = mp_obj_new_str("?", 1, 0);
108108

109109
mp_sched_schedule(client->settings->mpy_subscribed_cb, mp_obj_new_tuple(2, tuple));
110110
}
@@ -323,32 +323,32 @@ STATIC mp_obj_t mqtt_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
323323
self->client->settings->lwt_retain = args[ARG_retain].u_int;
324324

325325
// set callbacks
326-
if (MP_OBJ_IS_FUN(args[ARG_datacb].u_obj)) {
326+
if ((MP_OBJ_IS_FUN(args[ARG_datacb].u_obj)) || (MP_OBJ_IS_METH(args[ARG_datacb].u_obj))) {
327327
self->client->settings->data_cb = (void*)data_cb;
328328
self->client->settings->mpy_data_cb = args[ARG_datacb].u_obj;
329329
}
330330

331-
if (MP_OBJ_IS_FUN(args[ARG_connected].u_obj)) {
331+
if ((MP_OBJ_IS_FUN(args[ARG_connected].u_obj)) || (MP_OBJ_IS_METH(args[ARG_connected].u_obj))) {
332332
self->client->settings->connected_cb = (void*)connected_cb;
333333
self->client->settings->mpy_connected_cb = args[ARG_connected].u_obj;
334334
}
335335

336-
if (MP_OBJ_IS_FUN(args[ARG_disconnected].u_obj)) {
336+
if ((MP_OBJ_IS_FUN(args[ARG_disconnected].u_obj)) || (MP_OBJ_IS_METH(args[ARG_disconnected].u_obj))) {
337337
self->client->settings->disconnected_cb = (void*)disconnected_cb;
338338
self->client->settings->mpy_disconnected_cb = args[ARG_disconnected].u_obj;
339339
}
340340

341-
if (MP_OBJ_IS_FUN(args[ARG_subscribed].u_obj)) {
341+
if ((MP_OBJ_IS_FUN(args[ARG_subscribed].u_obj)) || (MP_OBJ_IS_METH(args[ARG_subscribed].u_obj))) {
342342
self->client->settings->subscribe_cb = (void*)subscribed_cb;
343343
self->client->settings->mpy_subscribed_cb = args[ARG_subscribed].u_obj;
344344
}
345345

346-
if (MP_OBJ_IS_FUN(args[ARG_unsubscribed].u_obj)) {
346+
if ((MP_OBJ_IS_FUN(args[ARG_unsubscribed].u_obj)) || (MP_OBJ_IS_METH(args[ARG_unsubscribed].u_obj))) {
347347
self->client->settings->unsubscribe_cb = (void*)unsubscribed_cb;
348348
self->client->settings->mpy_unsubscribed_cb = args[ARG_unsubscribed].u_obj;
349349
}
350350

351-
if (MP_OBJ_IS_FUN(args[ARG_published].u_obj)) {
351+
if ((MP_OBJ_IS_FUN(args[ARG_published].u_obj)) || (MP_OBJ_IS_METH(args[ARG_published].u_obj))) {
352352
self->client->settings->publish_cb = (void*)published_cb;
353353
self->client->settings->mpy_published_cb = args[ARG_published].u_obj;
354354
}
@@ -402,32 +402,32 @@ STATIC mp_obj_t mqtt_op_config(mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma
402402
if (args[ARG_retain].u_int >= 0) self->client->settings->lwt_retain = args[ARG_retain].u_int;
403403
if (args[ARG_cleansess].u_int >= 0) self->client->settings->clean_session = args[ARG_cleansess].u_int;
404404

405-
if (MP_OBJ_IS_FUN(args[ARG_datacb].u_obj)) {
405+
if ((MP_OBJ_IS_FUN(args[ARG_datacb].u_obj)) || (MP_OBJ_IS_METH(args[ARG_datacb].u_obj))) {
406406
self->client->settings->data_cb = NULL;
407407
self->client->settings->mpy_data_cb = args[ARG_datacb].u_obj;
408408
self->client->settings->data_cb = (void*)data_cb;
409409
}
410-
if (MP_OBJ_IS_FUN(args[ARG_connected].u_obj)) {
410+
if ((MP_OBJ_IS_FUN(args[ARG_connected].u_obj)) || (MP_OBJ_IS_METH(args[ARG_connected].u_obj))) {
411411
self->client->settings->connected_cb = NULL;
412412
self->client->settings->mpy_connected_cb = args[ARG_connected].u_obj;
413413
self->client->settings->connected_cb = (void*)connected_cb;
414414
}
415-
if (MP_OBJ_IS_FUN(args[ARG_disconnected].u_obj)) {
415+
if ((MP_OBJ_IS_FUN(args[ARG_disconnected].u_obj)) || (MP_OBJ_IS_METH(args[ARG_disconnected].u_obj))) {
416416
self->client->settings->disconnected_cb = NULL;
417417
self->client->settings->mpy_disconnected_cb = args[ARG_disconnected].u_obj;
418418
self->client->settings->disconnected_cb = (void*)disconnected_cb;
419419
}
420-
if (MP_OBJ_IS_FUN(args[ARG_subscribed].u_obj)) {
420+
if ((MP_OBJ_IS_FUN(args[ARG_subscribed].u_obj)) || (MP_OBJ_IS_METH(args[ARG_subscribed].u_obj))) {
421421
self->client->settings->subscribe_cb = NULL;
422422
self->client->settings->mpy_subscribed_cb = args[ARG_subscribed].u_obj;
423423
self->client->settings->subscribe_cb = (void*)subscribed_cb;
424424
}
425-
if (MP_OBJ_IS_FUN(args[ARG_unsubscribed].u_obj)) {
425+
if ((MP_OBJ_IS_FUN(args[ARG_unsubscribed].u_obj)) || (MP_OBJ_IS_METH(args[ARG_unsubscribed].u_obj))) {
426426
self->client->settings->unsubscribe_cb = NULL;
427427
self->client->settings->mpy_unsubscribed_cb = args[ARG_unsubscribed].u_obj;
428428
self->client->settings->unsubscribe_cb = (void*)unsubscribed_cb;
429429
}
430-
if (MP_OBJ_IS_FUN(args[ARG_published].u_obj)) {
430+
if ((MP_OBJ_IS_FUN(args[ARG_published].u_obj)) || (MP_OBJ_IS_METH(args[ARG_published].u_obj))) {
431431
self->client->settings->publish_cb = NULL;
432432
self->client->settings->mpy_published_cb = args[ARG_published].u_obj;
433433
self->client->settings->publish_cb = (void*)published_cb;

MicroPython_BUILD/components/micropython/esp32/modnetwork.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ STATIC mp_obj_t esp_callback(size_t n_args, const mp_obj_t *args)
673673
}
674674

675675
if (wifi_mutex) xSemaphoreTake(wifi_mutex, 1000);
676-
if (MP_OBJ_IS_FUN(args[1])) {
676+
if ((MP_OBJ_IS_FUN(args[1])) || (MP_OBJ_IS_METH(args[1]))) {
677677
event_callback = args[1];
678678
}
679679
else event_callback = NULL;

MicroPython_BUILD/components/micropython/esp32/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ extern const struct _mp_obj_module_t mp_module_ota;
262262
{ MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&mp_module_machine }, \
263263
{ MP_OBJ_NEW_QSTR(MP_QSTR_network), (mp_obj_t)&mp_module_network }, \
264264
{ MP_OBJ_NEW_QSTR(MP_QSTR_ymodem), (mp_obj_t)&mp_module_ymodem }, \
265+
{ MP_OBJ_NEW_QSTR(MP_QSTR_uhashlib), (mp_obj_t)&mp_module_uhashlib }, \
265266
BUILTIN_MODULE_DISPLAY \
266267
BUILTIN_MODULE_CURL \
267268
BUILTIN_MODULE_SSH \
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// MicroPython version info
2-
#define MICROPY_GIT_TAG "ESP32_LoBo_v3.1.14"
2+
#define MICROPY_GIT_TAG "ESP32_LoBo_v3.1.15"
33
#define MICROPY_GIT_HASH "gdaa8cfa8"
4-
#define MICROPY_BUILD_DATE "2017-01-29"
4+
#define MICROPY_BUILD_DATE "2017-02-03"
55
#define MICROPY_VERSION_MAJOR (3)
66
#define MICROPY_VERSION_MINOR (1)
7-
#define MICROPY_VERSION_MICRO (14)
8-
#define MICROPY_VERSION_STRING "3.1.14"
7+
#define MICROPY_VERSION_MICRO (15)
8+
#define MICROPY_VERSION_STRING "3.1.15"

MicroPython_BUILD/components/micropython/extmod/modutimeq.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
129129
mp_raise_msg(&mp_type_IndexError, "queue overflow");
130130
}
131131
mp_uint_t l = heap->len;
132-
heap->items[l].time = MP_OBJ_SMALL_INT_VALUE(args[1]);
132+
mp_uint_t itime;
133+
if (mp_obj_is_float(args[1])) {
134+
mp_float_t time = mp_obj_float_get(args[1]);
135+
itime = (uint32_t)time;
136+
}
137+
else itime = MP_OBJ_SMALL_INT_VALUE(args[1]);
138+
heap->items[l].time = itime;
133139
heap->items[l].id = utimeq_id++;
134140
heap->items[l].callback = args[2];
135141
heap->items[l].args = args[3];

MicroPython_BUILD/components/micropython/extmod/utime_mphal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_cpu_obj, time_ticks_cpu);
9393

9494
//-------------------------------------------------------------------
9595
STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
96-
uint64_t start = mp_obj_get_int(start_in);
97-
uint64_t end = mp_obj_get_int(end_in);
96+
uint64_t start = mp_obj_get_int64(start_in);
97+
uint64_t end = mp_obj_get_int64(end_in);
9898
int64_t diff = end - start;
9999
return mp_obj_new_int_from_ll(diff);
100100
}
@@ -116,8 +116,8 @@ MP_DEFINE_CONST_FUN_OBJ_2(mp_utime_tickscpu_diff_obj, time_tickscpu_diff);
116116
//--------------------------------------------------------------------
117117
STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
118118
// we assume that first argument come from ticks_xx so is 64-bit int
119-
uint64_t tickin = mp_obj_get_int(ticks_in);
120-
uint64_t delta = mp_obj_get_int(delta_in);
119+
uint64_t tickin = mp_obj_get_int64(ticks_in);
120+
uint64_t delta = mp_obj_get_int64(delta_in);
121121
int64_t addtick = tickin + delta;
122122
return mp_obj_new_int_from_ll(addtick);
123123
}

MicroPython_BUILD/components/micropython/py/modthread.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,8 @@ STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *pos_a
158158
else {
159159
mp_raise_TypeError("expecting a string for thread name argument");
160160
}
161-
if (!MP_OBJ_IS_FUN(args[1].u_obj)) {
162-
if (!MP_OBJ_IS_METH(args[1].u_obj)) {
163-
mp_raise_TypeError("expecting a function for thread function argument");
164-
}
161+
if ((!MP_OBJ_IS_FUN(args[1].u_obj)) && (!MP_OBJ_IS_METH(args[1].u_obj))) {
162+
mp_raise_TypeError("expecting a function for thread function argument");
165163
}
166164

167165
// get positional arguments

0 commit comments

Comments
 (0)