Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync up with main repo #9

Merged
merged 40 commits into from
May 20, 2019
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d44a3a9
Merge pull request #1 from intel/master
Weining2019 May 8, 2019
c010d20
Merge pull request #2 from intel/master
Weining2019 May 9, 2019
1f398d3
convert tab to 4 spaces in header files
Weining2019 May 9, 2019
89a13e8
Merge pull request #3 from intel/master
Weining2019 May 9, 2019
5a0089e
test
Weining2019 May 16, 2019
9e3edf7
test
Weining2019 May 16, 2019
57dabc2
test
Weining2019 May 16, 2019
3315c8c
Revert "test"
Weining2019 May 16, 2019
1baddc3
Revert "test"
Weining2019 May 16, 2019
e655f51
Revert "test"
Weining2019 May 16, 2019
b4774a3
aaa
Weining2019 May 16, 2019
c9e7708
Revert "aaa"
Weining2019 May 16, 2019
0d31325
a
Weining2019 May 16, 2019
82786e5
Revert "a"
Weining2019 May 16, 2019
af37fef
aaas
Weining2019 May 16, 2019
94d9a1d
a1
Weining2019 May 16, 2019
0428ff5
a2
Weining2019 May 16, 2019
f45466a
a3
Weining2019 May 16, 2019
d386d44
a4
Weining2019 May 16, 2019
f9929dd
a5
Weining2019 May 16, 2019
e993b07
a6
Weining2019 May 16, 2019
da9064f
Revert "a6"
Weining2019 May 16, 2019
8b9e0b7
Revert "a5"
Weining2019 May 16, 2019
4a6c536
Revert "a4"
Weining2019 May 16, 2019
793661d
Revert "a3"
Weining2019 May 16, 2019
8901c5b
Revert "a2"
Weining2019 May 16, 2019
444dc48
Revert "a1"
Weining2019 May 16, 2019
d033503
Revert "aaas"
Weining2019 May 16, 2019
3238c4f
add simple
Weining2019 May 16, 2019
2da1d4d
Revert "add simple"
Weining2019 May 16, 2019
8cc885f
Merge pull request #4 from intel/master
Weining2019 May 17, 2019
e450e60
Merge pull request #5 from intel/master
Weining2019 May 17, 2019
8deb148
Merge pull request #6 from intel/master
Weining2019 May 17, 2019
eead4f6
Merge pull request #7 from intel/master
Weining2019 May 17, 2019
9da47ed
Update README.md
xwang98 May 18, 2019
b2f9063
Merge pull request #8 from intel/master
Weining2019 May 20, 2019
f64b753
Update README
Weining2019 May 20, 2019
5ab2a7b
Update README.md
wenyongh May 20, 2019
ff49e67
Merge pull request #30 from Weining2019/master
wenyongh May 20, 2019
a66f18e
update README of littlevgl sample (#31)
litian-int May 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
aaas
  • Loading branch information
Weining2019 committed May 16, 2019
commit af37fefb348cbc8e690428f8b4d4f73ebd646cb3
311 changes: 311 additions & 0 deletions core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
#User Guide

##Introduction

This project aims to demonstrate wasm app management and programming model of WAMR.

##Build all binaries
Execute the build.sh script then all binaries including wasm application files would be generated in 'out' directory.
`./build.sh`

###Out directory structure
<pre>
out/
├── host_tool
├── simple
└── wasm-apps
├── event_publisher.wasm
├── event_subscriber.wasm
├── request_handler.wasm
├── request_sender.wasm
├── sensor.wasm
└── timer.wasm
</pre>

- host_tool:
A small testing tool to interact with WAMR. See the usage of this tool by executing "./host_tool -h".
`./host_tool -h`

- simple:
The simple application with WAMR runtime built in. See the usage of this application by executing "./simple -h".
`./simple -h`
>Note: The connection between simple and host_tool is TCP by default and this guide uses default connection. You can also use the UART mode. To achieve this you have to uncomment the below line in CMakeLists.txt and rebuild. You have to set up a UART hardware connection between 2 machines one of which runs the host_tool and the other runs the simple application. See the help of host_tool and the simple application to know how to specify UART device parameters.
`#add_definitions (-DCONNECTION_UART)`

- wasm-apps:
Sample wasm applications that demonstrate all APIs of the WAMR programming model. The source codes are in the wasm-apps directory under the root of this project.
+ event_publisher.wasm
This application shows the sub/sub programming model. The pub application publishes the event "alert/overheat" by calling api_publish_event() API. The subscriber could be host_tool or other wasm application.
+ event_subscriber.wasm
This application shows the sub/pub programming model. The sub application subscribes the "alert/overheat" event by calling api_subscribe_event() API so that it is able to receive the event once generated and published by the pub application. To make the process clear to interpret, the sub application dumps the event when receiving it.
+ request_handler.wasm
This application shows the request/response programming model. The request handler application registers 2 resources(/url1 and /url2) by calling api_register_resource_handler() API. The request sender could be host_tool or other wasm application.
+ request_sender.wasm
This application shows the request/response programming model. The sender application sends 2 requests, one is "/app/request_handler/url1" and the other is "url1". The former is an accurate request which explicitly specifies the name of request handler application in the middle of the URL and the later is a general request.
+ sensor.wasm
This application shows the sensor programming model. It opens a test sensor and configures the sensor event generating interval to 1 second. To make the process clear to interpret, the application dumps the sensor event when receiving it.
+ timer.wasm
This application shows the timer programming model. It creates a periodic timer that prints the current expiry number in every second.

##Run
- Enter the out directory
`cd ./out/`

- Startup the 'simple' process works in TCP server mode
`./simple -s`

You would see "App Manager started." is printed.
`App Manager started.`

- Query all installed applications
`./host_tool -q`

- Install the request handler wasm application
`./host_tool -i request_handler -f ./wasm-apps/request_handler.wasm`

- Send request to specific wasm application
`./host_tool -r /app/request_handler/url1 -A GET`

- Send a general request (not specify target application name)
`./host_tool -r /url1 -A GET`

- Install the event publisher wasm application
`./host_tool -i pub -f ./wasm-apps/event_publisher.wasm`

- Subscribe event by host_tool
`./host_tool -s /alert/overheat -a 3000`

- Install the event subscriber wasm application
`./host_tool -i sub -f ./wasm-apps/event_subscriber.wasm`

- Uninstall the wasm app
`./host_tool -u request_handler`
`./host_tool -u pub`
`./host_tool -u sub`

>Note: You have to manually kill the simple process by Ctrl+C after use.

###Output example

####Output of simple
```
$ ./simple -s
App Manager started.
connection established!
sent 137 bytes to host
Query Applets success!
Attribute container dump:
Tag: Applets Info
Attribute list:
key: num, type: int, value: 0x0

connection lost, and waiting for client to reconnect...
connection established!
Install WASM app success!
sent 16 bytes to host
WASM app 'request_handler' started
connection lost, and waiting for client to reconnect...
connection established!
Send request to applet: request_handler
Send request to app request_handler success.
App request_handler got request, url url1, action 1
[resp] ### user resource 1 handler called
sent 150 bytes to host
Wasm app process request success.
connection lost, and waiting for client to reconnect...
connection established!
Send request to app request_handler success.
App request_handler got request, url /url1, action 1
[resp] ### user resource 1 handler called
sent 150 bytes to host
Wasm app process request success.
connection lost, and waiting for client to reconnect...
connection established!
sent 137 bytes to host
Query Applets success!
Attribute container dump:
Tag: Applets Info
Attribute list:
key: num, type: int, value: 0x1
key: applet1, type: string, value: request_handler
key: heap1, type: int, value: 0xc000

connection lost, and waiting for client to reconnect...
connection established!
Install WASM app success!
sent 16 bytes to host
WASM app 'pub' started
connection lost, and waiting for client to reconnect...
connection established!
Install WASM app success!
sent 16 bytes to host
WASM app 'sub' started
am_register_event adding url:(alert/overheat)
client: 3 registered event (alert/overheat)
connection lost, and waiting for client to reconnect...
Send request to app sub success.
App sub got request, url alert/overheat, action 6
### user over heat event handler called
Attribute container dump:
Tag:
Attribute list:
key: warning, type: string, value: temperature is over high

Wasm app process request success.
Send request to app sub success.
App sub got request, url alert/overheat, action 6
### user over heat event handler called
Attribute container dump:
Tag:
Attribute list:
key: warning, type: string, value: temperature is over high

Wasm app process request success.
connection established!
am_register_event adding url:(alert/overheat)
client: -3 registered event (alert/overheat)
sent 16 bytes to host
sent 142 bytes to host
Send request to app sub success.
App sub got request, url alert/overheat, action 6
### user over heat event handler called
Attribute container dump:
Tag:
Attribute list:
key: warning, type: string, value: temperature is over high

Wasm app process request success.
Send request to app sub success.
App sub got request, url alert/overheat, action 6
### user over heat event handler called
Attribute container dump:
Tag:
Attribute list:
key: warning, type: string, value: temperature is over high

Wasm app process request success.
connection established!
sent 266 bytes to host
Query Applets success!
Attribute container dump:
Tag: Applets Info
Attribute list:
key: num, type: int, value: 0x3
key: applet1, type: string, value: sub
key: heap1, type: int, value: 0xc000
key: applet2, type: string, value: pub
key: heap2, type: int, value: 0xc000
key: applet3, type: string, value: request_handler
key: heap3, type: int, value: 0xc000

connection lost, and waiting for client to reconnect...
Send request to app sub success.
App sub got request, url alert/overheat, action 6
### user over heat event handler called
Attribute container dump:
Tag:
Attribute list:
key: warning, type: string, value: temperature is over high

Wasm app process request success.
Send request to app sub success.
App sub got request, url alert/overheat, action 6
### user over heat event handler called
Attribute container dump:
Tag:
Attribute list:
key: warning, type: string, value: temperature is over high

Wasm app process request success.
connection established!
App instance main thread exit.
client: 3 deregistered event (alert/overheat)
Uninstall WASM app successful!
sent 16 bytes to host
connection lost, and waiting for client to reconnect...
connection established!
App instance main thread exit.
Uninstall WASM app successful!
sent 16 bytes to host
connection lost, and waiting for client to reconnect...
connection established!
App instance main thread exit.
Uninstall WASM app successful!
sent 16 bytes to host
connection lost, and waiting for client to reconnect...
connection established!
sent 137 bytes to host
Query Applets success!
Attribute container dump:
Tag: Applets Info
Attribute list:
key: num, type: int, value: 0x0

connection lost, and waiting for client to reconnect...
^C

```

####Output of host_tool
```
$ ./host_tool -q

response status 69
{
"num": 1,
"applet1": "request_handler",
"heap1": 49152
}
$ ./host_tool -i pub -f ./wasm-apps/event_publisher.wasm

response status 65
$ ./host_tool -i sub -f ./wasm-apps/event_subscriber.wasm

response status 65
$ ./host_tool -s /alert/overheat -a 3000

response status 69

received an event alert/overheat
{
"warning": "temperature is over high"
}
received an event alert/overheat
{
"warning": "temperature is over high"
}
received an event alert/overheat
{
"warning": "temperature is over high"
}
received an event alert/overheat
{
"warning": "temperature is over high"
$ ./host_tool -q

response status 69
{
"num": 3,
"applet1": "sub",
"heap1": 49152,
"applet2": "pub",
"heap2": 49152,
"applet3": "request_handler",
"heap3": 49152
$ ./host_tool -u sub

response status 66
$ ./host_tool -u pub

response status 66
$ ./host_tool -u request_handler

response status 66
$ ./host_tool -q

response status 69
{
"num": 0
}

```