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

Add support for RemoteBridge update scripts #388

Merged
merged 18 commits into from Mar 7, 2018
Merged

Add support for RemoteBridge update scripts #388

merged 18 commits into from Mar 7, 2018

Conversation

timburke
Copy link
Member

@timburke timburke commented Mar 7, 2018

Overview

This is a big PR but it lays the groundwork for working with RemoteBridge update scripts in CoreTools. In particular it adds support for parsing and creating them (without needing a specific iotile-support-* package containing old functionality to do so.

There is now an UpdateScript class in iotile-core that can parse and create binary .trub update scripts from a series of action records. Some of these records are implemented in iotile-core itself and there is a plugin mechanism for other packages to implement their own records.

iotile-sensorgraph takes advantage of this plugin system to implement all of the required actions needed to program a complete .sgf file into an IOTile device.

New User Facing Functionality

  1. There is a new iotile-updateinfo script installed with coretools that can take in any binary .trub script file and print out all of the records that it contains in a human reading way. For example:
(env) > iotile-updateinfo .\test.trub

Update Script
-------------
Path: .\test.trub
Record Count: 68
Total length: 1951 bytes

Actions
-------
01: Stop sensorgraph engine
02: Clear all sensorgrapgh readings
03: Clear current sensorgraph
04: Add sensorgraph node '(system input 3 always) => counter 1025 using copy_latest_a'
05: Add sensorgraph node '(system input 5 always) => counter 1026 using copy_latest_a'
06: Add sensorgraph node '(input 1 always) => unbuffered 1024 using copy_latest_a'
07: Add sensorgraph node '(system input 1538 when value == 0) => unbuffered 1025 using copy_latest_a'
08: Add sensorgraph node '(system input 1538 when value == 1) => unbuffered 1028 using copy_latest_a'
09: Add sensorgraph node '(system input 1025 always) => unbuffered 1035 using copy_latest_a'
10: Add sensorgraph node '(system input 1026 always) => unbuffered 1036 using copy_latest_a'
11: Add sensorgraph node '(unbuffered 1024 always) => output 32 using copy_latest_a'
12: Add sensorgraph node '(unbuffered 1025 always) => constant 1 using copy_latest_a'
13: Add sensorgraph node '(unbuffered 1025 when count == 1 && constant 1024 always) => unbuffered 1026 using call_rpc'
14: Add sensorgraph node '(unbuffered 1025 when count == 1 && constant 1025 always) => unbuffered 1027 using call_rpc'
15: Add sensorgraph node '(unbuffered 1028 always) => constant 1 using copy_latest_a'
16: Add sensorgraph node '(unbuffered 1028 when count == 1 && constant 1026 always) => unbuffered 1029 using call_rpc'
17: Add sensorgraph node '(unbuffered 1028 when count == 1 && constant 1027 always) => unbuffered 1030 using call_rpc'
18: Add sensorgraph node '(constant 1035 always && unbuffered 1035 when value == 8) => constant 1034 using copy_latest_a'
19: Add sensorgraph node '(constant 1036 always && unbuffered 1036 when value == 8) => constant 1034 using copy_latest_a'
20: Add sensorgraph node '(system input 1024 always && constant 1 when value == 1) => unbuffered 1031 using copy_latest_a'
21: Add sensorgraph node '(counter 1026 always && constant 1 when value == 1) => counter 1028 using copy_latest_a'
22: Add sensorgraph node '(counter 1025 always && constant 1034 when value == 1) => counter 1031 using copy_latest_a'
23: Add sensorgraph node '(unbuffered 1031 when count == 1 && constant 1028 always) => unbuffered 1033 using call_rpc'
24: Add sensorgraph node '(counter 1028 when count >= 1 && constant 1030 always) => unbuffered 1034 using call_rpc'
25: Add sensorgraph node '(counter 1028 when count >= 1 && constant 1031 always) => output 34 using call_rpc'
26: Add sensorgraph node '(counter 1028 when count >= 1 && constant 1032 always) => output 33 using call_rpc'
27: Add sensorgraph node '(counter 1031 when count >= 1 && constant 1038 always) => unbuffered 18 using call_rpc'
28: Add sensorgraph node '(counter 1031 when count >= 1 && constant 1039 always) => unbuffered 1037 using call_rpc'
29: Add sensorgraph node '(counter 1031 when count >= 1 && constant 1040 always) => unbuffered 15 using call_rpc'
30: Add sensorgraph node '(counter 1031 when count >= 1) => counter 1033 using copy_latest_a'
31: Add sensorgraph node '(counter 1028 when count >= 1 && constant 1033 always) => output 35 using call_rpc'
32: Add sensorgraph node '(counter 1033 when count == 1 && constant 1041 always) => unbuffered 22 using call_rpc'
33: Add sensorgraph node '(counter 1033 when count == 1 && constant 1042 always) => unbuffered 25 using call_rpc'
34: Add sensorgraph streamer 'manual streamer on all outputs'
35: Add sensorgraph streamer 'manual streamer on all system outputs with streamer 0'
36: Add sensorgraph streamer 'manual streamer on all system buffered with streamer 0'
37: Add sensorgraph streamer 'realtime streamer on unbuffered 18'
38: Add sensorgraph streamer 'realtime streamer on unbuffered 15'
39: Add sensorgraph streamer 'realtime streamer on unbuffered 22'
40: Add sensorgraph streamer 'realtime streamer on unbuffered 25'
41: Initialize stream 'constant 1028' to 819254 (0x000C8036)
42: Initialize stream 'constant 1039' to 950272 (0x000E8000)
43: Initialize stream 'constant 1038' to 819203 (0x000C8003)
44: Initialize stream 'constant 1033' to 950273 (0x000E8001)
45: Initialize stream 'constant 1035' to 1 (0x00000001)
46: Initialize stream 'constant 1034' to 0 (0x00000000)
47: Initialize stream 'constant 1024' to 819253 (0x000C8035)
48: Initialize stream 'constant 1025' to 532494 (0x0008200E)
49: Initialize stream 'constant 1026' to 819254 (0x000C8036)
50: Initialize stream 'constant 1027' to 532494 (0x0008200E)
51: Initialize stream 'constant 1031' to 950275 (0x000E8003)
52: Initialize stream 'constant 1032' to 950274 (0x000E8002)
53: Initialize stream 'constant 1' to 0 (0x00000000)
54: Initialize stream 'constant 1040' to 950275 (0x000E8003)
55: Initialize stream 'constant 1030' to 950272 (0x000E8000)
56: Initialize stream 'constant 1042' to 950273 (0x000E8001)
57: Initialize stream 'constant 1036' to 0 (0x00000000)
58: Initialize stream 'constant 1041' to 950274 (0x000E8002)
59: Persist sensorgraph to flash
60: Set config variable 0x2000 on controller to 'hex:01000000'
61: Set config variable 0x2001 on controller to 'hex:00000000'
62: Set config variable 0x2002 on controller to 'hex:58020000'
63: Set config variable 0x8000 on slot 2 to 'hex:1400'
64: Set config variable 0x8009 on slot 2 to 'hex:03000000'
65: Set config variable 0x8005 on slot 2 to 'hex:02'
66: Set config variable 0x8006 on slot 2 to 'hex:01'
67: Set config variable 0x8008 on slot 2 to 'hex:00'
68: Set device app to (tag:2049 version:1.0)
  1. You can now specify an additional output format from iotile-sensorgraph which is -f script. This triggers the creation of a .trub script containing all of the records necessary to program the sensorgraph into a device. For example, the above file was generated by a command line:
(env) > iotile-sgcompile ./pod1m.sgf -f script -o test.trub
  1. The .trub parser is smart enough to understand that some high level actions like 'Load sensorgraph Node' compile down in a script into just a normal SendRPC action. The parser is able to perform somewhat deep inspection on the records in a script in order to turn them back into high level actions. This is true even for actions that turn into multiple records like SetConfigVariable which turns into a sequence of begin_config, push_config, end_config actions which are themselves just SendRPC actions.

@timburke timburke added iotile-core Related to iotile-core package iotile-sensorgraph Related to iotile-sensorgraph package type:enhancement Marks a proposed enhancement request labels Mar 7, 2018
@timburke
Copy link
Member Author

timburke commented Mar 7, 2018

Remaining work:

  • Add support for controller reflash action
  • Add support for reset device action

This makes the output of format_script repeatable across machines
and comparable with just a straight binary comparison rather than
checking whether the scripts are functionally identical.
@timburke timburke merged commit b33d50d into master Mar 7, 2018
@timburke timburke deleted the feat-scripts branch March 7, 2018 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iotile-core Related to iotile-core package iotile-sensorgraph Related to iotile-sensorgraph package type:enhancement Marks a proposed enhancement request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant