Skip to content

Commit 144c581

Browse files
committed
Update example
1 parent 6439b7a commit 144c581

File tree

5 files changed

+46
-54
lines changed

5 files changed

+46
-54
lines changed

examples/Wasm_Blink/Wasm_Blink.ino

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,9 @@ m3ApiRawFunction(m3_arduino_getPinLED)
123123

124124
m3ApiRawFunction(m3_arduino_print)
125125
{
126-
m3ApiGetArgMem(const char *, out)
127-
m3ApiGetArg(int32_t, out_len)
126+
m3ApiGetArgMem(const char *, buff)
128127

129128
//printf("api: print %p\n", out);
130-
131-
char buff[out_len+1];
132-
memcpy(buff, out, out_len);
133-
buff[out_len] = '\0';
134-
135129
Serial.print(buff);
136130

137131
m3ApiSuccess();
@@ -153,8 +147,8 @@ M3Result LinkArduino (IM3Runtime runtime)
153147
m3_LinkRawFunction (module, arduino, "digitalWrite", "v(ii)", &m3_arduino_digitalWrite);
154148

155149
// Convenience functions
156-
m3_LinkRawFunction (module, arduino, "print", "v(*i)", &m3_arduino_print);
157150
m3_LinkRawFunction (module, arduino, "getPinLED", "i()", &m3_arduino_getPinLED);
151+
m3_LinkRawFunction (module, arduino, "print", "v(*)", &m3_arduino_print);
158152

159153
// Dummy (for TinyGo)
160154
m3_LinkRawFunction (module, "env", "io_get_stdout", "i()", &m3_dummy);

wasm_apps/tinygo/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ func getPinLED() uint
3838
* App
3939
*/
4040

41-
var LED = getPinLED()
41+
const LED uint = 13
42+
//var LED = getPinLED()
4243

4344
func setup() {
4445
pinMode(LED, 1)

wasm_apps/tinygo/app.wasm

-44 Bytes
Binary file not shown.

wasm_apps/tinygo/app.wasm.h

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
11
unsigned char app_wasm[] = {
22
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x18, 0x05, 0x60,
3-
0x00, 0x00, 0x60, 0x02, 0x7f, 0x7f, 0x00, 0x60, 0x00, 0x01, 0x7f, 0x60,
4-
0x01, 0x7f, 0x00, 0x60, 0x03, 0x7f, 0x7f, 0x7f, 0x01, 0x7f, 0x02, 0x62,
5-
0x05, 0x03, 0x65, 0x6e, 0x76, 0x0d, 0x69, 0x6f, 0x5f, 0x67, 0x65, 0x74,
6-
0x5f, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x00, 0x02, 0x07, 0x61, 0x72,
7-
0x64, 0x75, 0x69, 0x6e, 0x6f, 0x09, 0x67, 0x65, 0x74, 0x50, 0x69, 0x6e,
8-
0x4c, 0x45, 0x44, 0x00, 0x02, 0x07, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e,
9-
0x6f, 0x07, 0x70, 0x69, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x00, 0x01, 0x07,
10-
0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x0c, 0x64, 0x69, 0x67, 0x69,
11-
0x74, 0x61, 0x6c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x00, 0x01, 0x07, 0x61,
12-
0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79,
13-
0x00, 0x03, 0x03, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
14-
0x05, 0x03, 0x01, 0x00, 0x02, 0x06, 0x1c, 0x04, 0x7f, 0x00, 0x41, 0x84,
15-
0x80, 0x04, 0x0b, 0x7f, 0x00, 0x41, 0x80, 0x80, 0x04, 0x0b, 0x7f, 0x00,
16-
0x41, 0x84, 0x80, 0x04, 0x0b, 0x7f, 0x00, 0x41, 0x80, 0x08, 0x0b, 0x07,
17-
0x7e, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x11,
18-
0x5f, 0x5f, 0x77, 0x61, 0x73, 0x6d, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x5f,
19-
0x63, 0x74, 0x6f, 0x72, 0x73, 0x00, 0x05, 0x06, 0x5f, 0x73, 0x74, 0x61,
20-
0x72, 0x74, 0x00, 0x06, 0x08, 0x63, 0x77, 0x61, 0x5f, 0x6d, 0x61, 0x69,
21-
0x6e, 0x00, 0x08, 0x0b, 0x5f, 0x5f, 0x68, 0x65, 0x61, 0x70, 0x5f, 0x62,
22-
0x61, 0x73, 0x65, 0x03, 0x00, 0x06, 0x6d, 0x65, 0x6d, 0x73, 0x65, 0x74,
23-
0x00, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x00, 0x0b, 0x0c,
24-
0x5f, 0x5f, 0x64, 0x73, 0x6f, 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65,
25-
0x03, 0x01, 0x0a, 0x5f, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x65, 0x6e,
26-
0x64, 0x03, 0x02, 0x0d, 0x5f, 0x5f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c,
27-
0x5f, 0x62, 0x61, 0x73, 0x65, 0x03, 0x03, 0x0a, 0xd9, 0x01, 0x07, 0x03,
28-
0x00, 0x01, 0x0b, 0x04, 0x00, 0x10, 0x07, 0x0b, 0x4d, 0x01, 0x02, 0x7f,
29-
0x3f, 0x00, 0x41, 0x10, 0x74, 0x41, 0x84, 0x80, 0x04, 0x6b, 0x41, 0x06,
30-
0x76, 0x21, 0x01, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x20, 0x01, 0x47,
31-
0x04, 0x40, 0x20, 0x00, 0x41, 0xfc, 0xff, 0x7b, 0x46, 0x0d, 0x02, 0x20,
32-
0x00, 0x41, 0x84, 0x80, 0x04, 0x6a, 0x41, 0x00, 0x3a, 0x00, 0x00, 0x20,
33-
0x00, 0x41, 0x01, 0x6a, 0x21, 0x00, 0x0c, 0x01, 0x0b, 0x0b, 0x10, 0x00,
34-
0x1a, 0x41, 0x80, 0x80, 0x04, 0x10, 0x01, 0x36, 0x02, 0x00, 0x0f, 0x0b,
35-
0x00, 0x0b, 0x07, 0x00, 0x10, 0x07, 0x10, 0x09, 0x00, 0x0b, 0x33, 0x00,
36-
0x41, 0x80, 0x80, 0x04, 0x28, 0x02, 0x00, 0x41, 0x01, 0x10, 0x02, 0x03,
37-
0x40, 0x41, 0x80, 0x80, 0x04, 0x28, 0x02, 0x00, 0x41, 0x01, 0x10, 0x03,
38-
0x41, 0xe4, 0x00, 0x10, 0x04, 0x41, 0x80, 0x80, 0x04, 0x28, 0x02, 0x00,
39-
0x41, 0x00, 0x10, 0x03, 0x41, 0x84, 0x07, 0x10, 0x04, 0x0c, 0x00, 0x0b,
40-
0x00, 0x0b, 0x37, 0x01, 0x02, 0x7f, 0x41, 0x00, 0x20, 0x00, 0x6b, 0x21,
41-
0x04, 0x02, 0x40, 0x03, 0x40, 0x20, 0x02, 0x20, 0x03, 0x47, 0x04, 0x40,
42-
0x20, 0x03, 0x20, 0x04, 0x46, 0x0d, 0x02, 0x20, 0x00, 0x20, 0x03, 0x6a,
43-
0x20, 0x01, 0x3a, 0x00, 0x00, 0x20, 0x03, 0x41, 0x01, 0x6a, 0x21, 0x03,
44-
0x0c, 0x01, 0x0b, 0x0b, 0x20, 0x00, 0x0f, 0x0b, 0x00, 0x0b, 0x0c, 0x00,
45-
0x41, 0xf8, 0xff, 0x03, 0x42, 0x00, 0x37, 0x03, 0x00, 0x00, 0x0b
3+
0x00, 0x00, 0x60, 0x02, 0x7f, 0x7f, 0x00, 0x60, 0x01, 0x7f, 0x00, 0x60,
4+
0x00, 0x01, 0x7f, 0x60, 0x03, 0x7f, 0x7f, 0x7f, 0x01, 0x7f, 0x02, 0x4e,
5+
0x04, 0x03, 0x65, 0x6e, 0x76, 0x0d, 0x69, 0x6f, 0x5f, 0x67, 0x65, 0x74,
6+
0x5f, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x00, 0x03, 0x07, 0x61, 0x72,
7+
0x64, 0x75, 0x69, 0x6e, 0x6f, 0x07, 0x70, 0x69, 0x6e, 0x4d, 0x6f, 0x64,
8+
0x65, 0x00, 0x01, 0x07, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x0c,
9+
0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x57, 0x72, 0x69, 0x74, 0x65,
10+
0x00, 0x01, 0x07, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x05, 0x64,
11+
0x65, 0x6c, 0x61, 0x79, 0x00, 0x02, 0x03, 0x08, 0x07, 0x00, 0x00, 0x00,
12+
0x00, 0x00, 0x04, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x1c, 0x04,
13+
0x7f, 0x00, 0x41, 0x80, 0x80, 0x04, 0x0b, 0x7f, 0x00, 0x41, 0x80, 0x80,
14+
0x04, 0x0b, 0x7f, 0x00, 0x41, 0x80, 0x80, 0x04, 0x0b, 0x7f, 0x00, 0x41,
15+
0x80, 0x08, 0x0b, 0x07, 0x7e, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72,
16+
0x79, 0x02, 0x00, 0x11, 0x5f, 0x5f, 0x77, 0x61, 0x73, 0x6d, 0x5f, 0x63,
17+
0x61, 0x6c, 0x6c, 0x5f, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x00, 0x04, 0x06,
18+
0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x00, 0x05, 0x08, 0x63, 0x77, 0x61,
19+
0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x07, 0x0b, 0x5f, 0x5f, 0x68, 0x65,
20+
0x61, 0x70, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x03, 0x00, 0x06, 0x6d, 0x65,
21+
0x6d, 0x73, 0x65, 0x74, 0x00, 0x09, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6d,
22+
0x65, 0x00, 0x0a, 0x0c, 0x5f, 0x5f, 0x64, 0x73, 0x6f, 0x5f, 0x68, 0x61,
23+
0x6e, 0x64, 0x6c, 0x65, 0x03, 0x01, 0x0a, 0x5f, 0x5f, 0x64, 0x61, 0x74,
24+
0x61, 0x5f, 0x65, 0x6e, 0x64, 0x03, 0x02, 0x0d, 0x5f, 0x5f, 0x67, 0x6c,
25+
0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x03, 0x03, 0x0a,
26+
0xc1, 0x01, 0x07, 0x03, 0x00, 0x01, 0x0b, 0x04, 0x00, 0x10, 0x06, 0x0b,
27+
0x44, 0x01, 0x02, 0x7f, 0x3f, 0x00, 0x41, 0x10, 0x74, 0x41, 0x80, 0x80,
28+
0x04, 0x6b, 0x41, 0x06, 0x76, 0x21, 0x01, 0x02, 0x40, 0x03, 0x40, 0x20,
29+
0x00, 0x20, 0x01, 0x47, 0x04, 0x40, 0x20, 0x00, 0x41, 0x80, 0x80, 0x7c,
30+
0x46, 0x0d, 0x02, 0x20, 0x00, 0x41, 0x80, 0x80, 0x04, 0x6a, 0x41, 0x00,
31+
0x3a, 0x00, 0x00, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x21, 0x00, 0x0c, 0x01,
32+
0x0b, 0x0b, 0x10, 0x00, 0x1a, 0x0f, 0x0b, 0x00, 0x0b, 0x07, 0x00, 0x10,
33+
0x06, 0x10, 0x08, 0x00, 0x0b, 0x24, 0x00, 0x41, 0x0d, 0x41, 0x01, 0x10,
34+
0x01, 0x03, 0x40, 0x41, 0x0d, 0x41, 0x01, 0x10, 0x02, 0x41, 0xe4, 0x00,
35+
0x10, 0x03, 0x41, 0x0d, 0x41, 0x00, 0x10, 0x02, 0x41, 0x84, 0x07, 0x10,
36+
0x03, 0x0c, 0x00, 0x0b, 0x00, 0x0b, 0x37, 0x01, 0x02, 0x7f, 0x41, 0x00,
37+
0x20, 0x00, 0x6b, 0x21, 0x04, 0x02, 0x40, 0x03, 0x40, 0x20, 0x02, 0x20,
38+
0x03, 0x47, 0x04, 0x40, 0x20, 0x03, 0x20, 0x04, 0x46, 0x0d, 0x02, 0x20,
39+
0x00, 0x20, 0x03, 0x6a, 0x20, 0x01, 0x3a, 0x00, 0x00, 0x20, 0x03, 0x41,
40+
0x01, 0x6a, 0x21, 0x03, 0x0c, 0x01, 0x0b, 0x0b, 0x20, 0x00, 0x0f, 0x0b,
41+
0x00, 0x0b, 0x0c, 0x00, 0x41, 0xf8, 0xff, 0x03, 0x42, 0x00, 0x37, 0x03,
42+
0x00, 0x00, 0x0b
4643
};
47-
unsigned int app_wasm_len = 527;
44+
unsigned int app_wasm_len = 483;

wasm_apps/tinygo/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export GOROOT=/opt/go
55
# Compile
66
tinygo build -target wasm \
77
-panic trap -wasm-abi generic \
8-
-heap-size 81920 \
8+
-heap-size 2048 \
99
-o app.wasm app.go
1010

1111
# Optimize (optional)

0 commit comments

Comments
 (0)