pxt-common-packages 9.3.5 → 9.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/azureiot/_locales/azureiot-jsdoc-strings.json +2 -0
- package/libs/azureiot/azureiot.ts +45 -2
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/base/core.cpp +1 -1
- package/libs/base/gc.cpp +8 -2
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/core---esp32/pxt.h +2 -0
- package/libs/core---esp32/usb.cpp +43 -18
- package/libs/core---esp32/worker.cpp +8 -0
- package/libs/core---vm/scheduler.cpp +8 -1
- package/libs/core---vm/vm.cpp +15 -8
- package/libs/game/built/debug/binary.js +6470 -6470
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/_locales/mqtt-jsdoc-strings.json +1 -1
- package/libs/mqtt/built/debug/binary.js +84 -84
- package/libs/mqtt/mqtt.ts +103 -27
- package/libs/palette/built/debug/binary.js +6469 -6469
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/storyboard/built/debug/binary.js +6469 -6469
- package/package.json +1 -1
package/libs/base/core.cpp
CHANGED
|
@@ -473,7 +473,7 @@ String concat(String s, String other) {
|
|
|
473
473
|
if (IS_CONS(other) || IS_CONS(s->cons.right))
|
|
474
474
|
goto mkCons;
|
|
475
475
|
auto lenAR = s->cons.right->getUTF8Size();
|
|
476
|
-
lenB = other->getUTF8Size();
|
|
476
|
+
lenB = other->getUTF8Size(); // de-consify other
|
|
477
477
|
if (lenAR + lenB > SHORT_CONCAT_STRING)
|
|
478
478
|
goto mkCons;
|
|
479
479
|
// if (s->cons.right + other) is short enough, use associativity
|
package/libs/base/gc.cpp
CHANGED
|
@@ -544,7 +544,11 @@ static void sweep(int flags) {
|
|
|
544
544
|
|
|
545
545
|
if (midPtr) {
|
|
546
546
|
uint32_t currFree = 0;
|
|
547
|
+
#ifdef PXT_ESP32
|
|
548
|
+
auto limit = freeSize * 1 / 4;
|
|
549
|
+
#else
|
|
547
550
|
auto limit = freeSize * 1 / 2;
|
|
551
|
+
#endif
|
|
548
552
|
for (auto p = firstFree; p; p = p->nextFree) {
|
|
549
553
|
auto len = VAR_BLOCK_WORDS(p->vtable);
|
|
550
554
|
currFree += len;
|
|
@@ -792,9 +796,11 @@ void *gcAllocate(int numbytes) {
|
|
|
792
796
|
if (i == 0)
|
|
793
797
|
gc(0);
|
|
794
798
|
// GC didn't help, try new block
|
|
795
|
-
else if (i == 1)
|
|
799
|
+
else if (i == 1) {
|
|
800
|
+
DMESG("gcAlloc(%d) (%d/%d free; %d max block) -> new block", numbytes,
|
|
801
|
+
gcStats.lastFreeBytes, gcStats.totalBytes, gcStats.lastMaxBlockBytes);
|
|
796
802
|
allocateBlock();
|
|
797
|
-
else
|
|
803
|
+
} else
|
|
798
804
|
// the block allocated was apparently too small
|
|
799
805
|
soft_panic(PANIC_GC_OOM);
|
|
800
806
|
}
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P133933(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___134174 = (undefined);
|
|
70
|
+
globals._pollEventQueue___134187 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P133933.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"colorbuffer.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P133933.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P133933_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P133933, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P133761_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P133933
|
|
92
92
|
})
|
package/libs/core---esp32/pxt.h
CHANGED
|
@@ -41,7 +41,9 @@ typedef Buffer Sound;
|
|
|
41
41
|
typedef struct worker *worker_t;
|
|
42
42
|
worker_t worker_alloc(const char *id, uint32_t stack_size);
|
|
43
43
|
int worker_run(worker_t w, TaskFunction_t fn, void *arg);
|
|
44
|
+
int worker_run_wait(worker_t w, TaskFunction_t fn, void *arg);
|
|
44
45
|
void worker_set_idle(worker_t w, TaskFunction_t fn, void *arg);
|
|
46
|
+
extern worker_t fg_worker;
|
|
45
47
|
|
|
46
48
|
void memInfo();
|
|
47
49
|
|
|
@@ -240,41 +240,66 @@ int HF2::handlePkt(int sz) {
|
|
|
240
240
|
return sendResponse(0);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
struct BufferEntry {
|
|
244
|
+
unsigned size;
|
|
245
|
+
uint8_t flag;
|
|
246
|
+
uint8_t data[0];
|
|
247
|
+
};
|
|
246
248
|
|
|
247
|
-
|
|
249
|
+
static void send_buffer_core(void *ent_) {
|
|
250
|
+
auto ent = (BufferEntry *)ent_;
|
|
248
251
|
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
uint32_t buf[64 / 4]; // aligned
|
|
253
|
+
auto size = ent->size;
|
|
254
|
+
auto data = ent->data;
|
|
251
255
|
|
|
252
|
-
while (connected && size > 0) {
|
|
256
|
+
while (hf2.connected && size > 0) {
|
|
253
257
|
memset(buf + 1, 0, 60);
|
|
254
258
|
int s = 63;
|
|
255
259
|
if (size <= 63) {
|
|
256
260
|
s = size;
|
|
257
|
-
buf[0] = flag;
|
|
261
|
+
buf[0] = ent->flag;
|
|
258
262
|
} else {
|
|
259
|
-
buf[0] = flag == HF2_FLAG_CMDPKT_LAST ? HF2_FLAG_CMDPKT_BODY : flag;
|
|
263
|
+
buf[0] = ent->flag == HF2_FLAG_CMDPKT_LAST ? HF2_FLAG_CMDPKT_BODY : ent->flag;
|
|
260
264
|
}
|
|
261
265
|
buf[0] |= s;
|
|
262
266
|
uint8_t *dst = (uint8_t *)buf;
|
|
263
267
|
dst++;
|
|
264
|
-
if (prepend + 1) {
|
|
265
|
-
memcpy(dst, &prepend, 4);
|
|
266
|
-
prepend = -1;
|
|
267
|
-
dst += 4;
|
|
268
|
-
s -= 4;
|
|
269
|
-
size -= 4;
|
|
270
|
-
}
|
|
271
268
|
memcpy(dst, data, s);
|
|
272
|
-
data =
|
|
269
|
+
data = data + s;
|
|
273
270
|
size -= s;
|
|
274
271
|
|
|
275
|
-
tinyusb_cdcacm_write_queue(TINYUSB_CDC_ACM_0, (uint8_t *)buf, sizeof(buf))
|
|
272
|
+
if (tinyusb_cdcacm_write_queue(TINYUSB_CDC_ACM_0, (uint8_t *)buf, sizeof(buf)) <
|
|
273
|
+
sizeof(buf))
|
|
274
|
+
DMESG("CDC write fail");
|
|
276
275
|
// tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_0, 0); - prints warnings
|
|
277
276
|
}
|
|
277
|
+
|
|
278
|
+
xfree(ent);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
void HF2::sendBuffer(uint8_t flag, const void *data, unsigned size, uint32_t prepend) {
|
|
282
|
+
if (!connected)
|
|
283
|
+
return;
|
|
284
|
+
|
|
285
|
+
if (prepend + 1)
|
|
286
|
+
size += 4;
|
|
287
|
+
|
|
288
|
+
auto ent = (BufferEntry *)xmalloc(sizeof(BufferEntry) + size);
|
|
289
|
+
ent->size = size;
|
|
290
|
+
ent->flag = flag;
|
|
291
|
+
auto dst = ent->data;
|
|
292
|
+
|
|
293
|
+
if (prepend + 1) {
|
|
294
|
+
memcpy(dst, &prepend, 4);
|
|
295
|
+
dst += 4;
|
|
296
|
+
size -= 4;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
memcpy(dst, data, size);
|
|
300
|
+
|
|
301
|
+
if (worker_run_wait(fg_worker, send_buffer_core, ent))
|
|
302
|
+
DMESG("HF2 queue full");
|
|
278
303
|
}
|
|
279
304
|
|
|
280
305
|
int HF2::sendEvent(uint32_t evId, const void *data, int size) {
|
|
@@ -48,4 +48,12 @@ int worker_run(worker_t w, TaskFunction_t fn, void *arg) {
|
|
|
48
48
|
return -1;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
int worker_run_wait(worker_t w, TaskFunction_t fn, void *arg) {
|
|
52
|
+
qitem_t evt = {fn, arg};
|
|
53
|
+
if (xQueueSend(w->queue, &evt, 100) == pdPASS)
|
|
54
|
+
return 0;
|
|
55
|
+
return -1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
51
59
|
}
|
|
@@ -24,11 +24,18 @@
|
|
|
24
24
|
#define THROW throw()
|
|
25
25
|
#define THREAD_DBG(...)
|
|
26
26
|
|
|
27
|
+
static uint8_t in_xmalloc_panic;
|
|
28
|
+
|
|
27
29
|
void *xmalloc(size_t sz) {
|
|
28
30
|
auto r = malloc(sz);
|
|
29
31
|
if (r == NULL) {
|
|
30
32
|
DMESG("failed to allocate %d bytes", sz);
|
|
31
|
-
|
|
33
|
+
if (in_xmalloc_panic) {
|
|
34
|
+
target_panic(PANIC_GC_OOM);
|
|
35
|
+
} else {
|
|
36
|
+
in_xmalloc_panic = 1;
|
|
37
|
+
soft_panic(PANIC_GC_OOM); // this can happen on esp32 etc; shouldn't on linux/ios etc
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
return r;
|
|
34
41
|
}
|
package/libs/core---vm/vm.cpp
CHANGED
|
@@ -155,12 +155,16 @@ void vm_stack_trace() {
|
|
|
155
155
|
auto end = vmImg->stackTop;
|
|
156
156
|
auto ptr = ctx->sp;
|
|
157
157
|
DMESG(" PC:%x", (ctx->pc - ctx->imgbase) << 1);
|
|
158
|
-
|
|
158
|
+
int max = 30;
|
|
159
|
+
while (ptr < end && max) {
|
|
159
160
|
auto v = (uintptr_t)*ptr++;
|
|
160
161
|
if (VM_IS_ENCODED_PC(v)) {
|
|
161
162
|
DMESG(" PC:%x", VM_DECODE_PC(v) << 1);
|
|
163
|
+
max--;
|
|
162
164
|
}
|
|
163
165
|
}
|
|
166
|
+
if (max == 0)
|
|
167
|
+
DMESG(" ...");
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
//%
|
|
@@ -214,18 +218,21 @@ void op_callind(FiberContext *ctx, unsigned arg) {
|
|
|
214
218
|
void op_ret(FiberContext *ctx, unsigned arg) {
|
|
215
219
|
SPLIT_ARG(retNumArgs, numTmps);
|
|
216
220
|
|
|
217
|
-
// check if we're leaving a function that still has open try blocks
|
|
218
|
-
// (this results from invalid code generation)
|
|
219
|
-
if (ctx->tryFrame && ctx->tryFrame->registers[0] == (uintptr_t)ctx->currAction) {
|
|
220
|
-
DMESG("try frame %p left on return", ctx->tryFrame);
|
|
221
|
-
target_panic(PANIC_VM_ERROR);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
221
|
POP(numTmps);
|
|
225
222
|
auto retaddr = (intptr_t)POPVAL();
|
|
226
223
|
ctx->currAction = (RefAction *)POPVAL();
|
|
227
224
|
POP(retNumArgs);
|
|
228
225
|
|
|
226
|
+
// check if we're leaving a function that still has open try blocks
|
|
227
|
+
// (this results from invalid code generation)
|
|
228
|
+
if (ctx->tryFrame &&
|
|
229
|
+
ctx->tryFrame->registers[2] < (uint8_t *)ctx->sp - (uint8_t *)vmImg->stackBase) {
|
|
230
|
+
DMESG("try frame %p left on return %d/%d", ctx->tryFrame, ctx->tryFrame->registers[2],
|
|
231
|
+
(uint8_t *)ctx->sp - (uint8_t *)vmImg->stackBase);
|
|
232
|
+
vm_stack_trace();
|
|
233
|
+
target_panic(PANIC_VM_ERROR);
|
|
234
|
+
}
|
|
235
|
+
|
|
229
236
|
if (retaddr == (intptr_t)TAG_STACK_BOTTOM) {
|
|
230
237
|
ctx->pc = NULL;
|
|
231
238
|
} else {
|