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

Added JS C module Support MRAA Examples #49

Merged
merged 21 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: ruby
rvm:
- 2.1
- 2.4.4
sudo: required
services:
- docker
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ clean:

test:
ifdef HTMLPROOFER
$(HTMLPROOFER) "./bone101" --disable-external --alt-ignore "/.*/" --only-4xx --url-ignore "/#.*/" --url-swap "/bone101:" --file-ignore "/Support/bone101/UI/","/Support/bonecard/create/"
$(HTMLPROOFER) "./bone101" --disable-external --alt-ignore "/.*/" --only-4xx --url-ignore "/#.*/" --url-swap "/bone101:" --file-ignore "/Support/bone101/UI/","/Support/bone101/PBUI/","/Support/bonecard/create/"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to reverse this and simply remove the reference to the missing file.

else
@echo htmlproofer not found
endif
Expand Down
12 changes: 6 additions & 6 deletions Support/BoneScript/analogRead/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ <h2>Return value</h2>
<ul>
<li>Number from 0 to 1 where 0 is 0V and 1 is the maximum input voltage (1.8V)</li>
</ul>
<h2>callback(x)</h2>
<h2>callback(err,value)</h2>
<ul>
<li><em>x.value</em>: return value</li>
<li><em>x.err</em>: error status message</li>
<li><em>value</em>: return value</li>
<li><em>err</em>: error status message</li>
</ul>
<h2>Example
<button class="dynlink" onclick="demoRun('code')">run</button>
Expand All @@ -60,9 +60,9 @@ <h2>Example
<pre id="code" class="use-editor" style="height: 120px;">
var b = require('bonescript');
b.analogRead('P9_36', printStatus);
function printStatus(x) {
console.log('x.value = ' + x.value);
console.log('x.err = ' + x.err);
function printStatus(err,value) {
console.log('value = ' + value);
console.log('err = ' + err);
}</pre>
<div readonly id='console-output' style='height: 80px;'></div>
<h2>Build and execute instructions</h2>
Expand Down
2 changes: 1 addition & 1 deletion Support/BoneScript/cape_bacon/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title: cape_bacon
scripts: [ '/Support/script/bonescript-demo.js', '/static/jquery-ui.min.js' ]
---
{{ include side_menu.html title="BoneScript" }}
{% include side_menu.html title="BoneScript" %}

<div class="t3_content_1">
<div id='connect-status'></div>
Expand Down
12 changes: 6 additions & 6 deletions Support/BoneScript/digitalRead/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ <h2>Return value</h2>
<li><a href="{{site.baseurl}}/Support/BoneScript/#HIGH">HIGH</a> if pin is HIGH</li>
<li><a href="{{site.baseurl}}/Support/BoneScript/#LOW">LOW</a> if pin is LOW</li>
</ul>
<h2>callback(x)</h2>
<h2>callback(err,value)</h2>
<ul>
<li><em>x.value</em>: return value</li>
<li><em>x.err</em>: error status message</li>
<li><em>value</em>: return value</li>
<li><em>err</em>: error status message</li>
</ul>
<h2>Example
<button class="dynlink" onclick="demoRun('code')">run</button>
Expand All @@ -55,9 +55,9 @@ <h2>Example
var b = require('bonescript');
b.pinMode('P8_19', b.INPUT);
b.digitalRead('P8_19', printStatus);
function printStatus(x) {
console.log('x.value = ' + x.value);
console.log('x.err = ' + x.err);
function printStatus(err,value) {
console.log('value = ' + value);
console.log('err = ' + err);
}</pre>
<div readonly id='console-output' style='height: 80px;'></div>
<h2>Build and execute instructions</h2>
Expand Down
32 changes: 21 additions & 11 deletions Support/BoneScript/getPinMode/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,19 @@ <h2>Return value</h2>
<li><em>name</em>: pin name</li>
<li><em>err</em>: error status message</li>
</ul>
<h2>callback(x)</h2>
<h2>callback(err,resp)</h2>
<ul>
<li><em>x</em>: return value</li>
<li><em>resp</em>: response object containing:</li>
<ul>
<li><em>mux</em>: index of mux mode</li>
<li><em>options</em>: array of mode names</li>
<li><em>slew</em>: 'fast' or 'slow'</li>
<li><em>rx</em>: 'enabled' or 'disabled'</li>
<li><em>pullup</em>: 'diabled', 'pullup' or 'pulldown'</li>
<li><em>pin</em>: key string for pin</li>
<li><em>name</em>: pin name</li>
</ul>
<li><em>err</em>: error status message</li>
</ul>
<h2>Example
<button class="dynlink" onclick="demoRun('code')">run</button>
Expand All @@ -59,16 +69,16 @@ <h2>Example
<pre id="code" class="use-editor" style="height: 230px;">
var b = require('bonescript');
b.getPinMode("P8_13", printPinMux);
function printPinMux(x) {
console.log('mux = ' + x.mux);
console.log('pullup = ' + x.pullup);
console.log('slew = ' + x.slew);
if(x.options)
function printPinMux(err,resp) {
console.log('mux = ' + resp.mux);
console.log('pullup = ' + resp.pullup);
console.log('slew = ' + resp.slew);
if(resp.options)
console.log('options = ' +
x.options.join(','));
console.log('pin = ' + x.pin);
console.log('name = ' + x.name);
console.log('err = ' + x.err);
resp.options.join(','));
console.log('pin = ' + resp.pin);
console.log('name = ' + resp.name);
console.log('err = ' + err);
}</pre>
<div readonly id='console-output' style='width: 496px;'></div>
<h2>Build and execute instructions</h2>
Expand Down
15 changes: 8 additions & 7 deletions Support/BoneScript/getPlatform/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ <h2>Return value</h2>
<li><em>version</em>: revision of the board</li>
<li><em>bonescript</em>: verison of bonescript</li>
</ul>
<h2>callback(x)</h2>
<h2>callback(err,resp)</h2>
<ul>
<li><em>x</em>: same as the return value.</li>
<li><em>resp</em>: same as the return value.</li>
<li><em>err</em>: error status message.</li>
</ul>
<h2>Example
<button class="dynlink" onclick="demoRun('code')">run</button>
Expand All @@ -61,11 +62,11 @@ <h2>Example
<pre id="code" class="use-editor" style="height: 150px;">
var b = require('bonescript');
b.getPlatform(printData);
function printData(x) {
console.log('name = ' + x.name);
console.log('version = ' + x.version);
console.log('serialNumber = ' + x.serialNumber);
console.log('bonescript = ' + x.bonescript);
function printData(err,resp) {
console.log('name = ' + resp.name);
console.log('version = ' + resp.version);
console.log('serialNumber = ' + resp.serialNumber);
console.log('bonescript = ' + resp.bonescript);
}</pre>
<div readonly id='console-output' style='height: 200px;'></div>
<h2>Build and execute instructions</h2>
Expand Down
82 changes: 82 additions & 0 deletions Support/BoneScript/loadCModule/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
layout: index
title: loadCModule
scripts: [ '/Support/script/bonescript-demo.js' ]
style: |
#code {
position: relative;
width: 500px;
padding-left: 0;
border-radius: 4px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
margin-bottom: 0px;
margin-left: 30px;
margin-right: 0px;
align: left;
}
#console-output {
margin-top: 0px;
margin-left: 30px;
width: 496px;
border: 1px solid #cccccc;
resize: vertical;
}
---
{% include side_menu.html title="BoneScript" %}
<div class="t3_content_1">
<div id='connect-status'></div>
<div id="content_child">

<p>You might be able to see a newer version of this on <a href="http://beagleboard.org/support/bonescript/loadCModule">beagleboard.org/support/bonescript/writeCModule</a></p>
<h1>loadCModule(filepath,fnNames&arguments, isMRAA)</h1>
<p>Loads functions from the C program provided at the path with Function names and arguments in the fnName&arguments input.</p>
<h2>Arguments</h2>
<ul>
<li><em>filename</em>: complete path of the C file</li>
<li><em>fnNames&arguments </em>: (object)contains functions name and input/output arguments in the format: <br>
{function_name : [ 'outArgType' , [ 'inArg1Type',inArg2Type',...]]}<br>
function_name: (string) corresponds to the name of the function to be loaded.<br>
outArgType: (string) corresponds to the output argument type of the function loaded.<br>
inArgTypeZ: (string) corresponds to the input arguments type of the function loaded.<br>
</li>
<li><em>isMRAA</em>: (boolean)whether to link link mraa headers during compilation(default : false).</li>
</ul>
<h2>return</h2>
<ul>
<li><em>x</em>: (object)the function loaded corresponding to the input provided</li>
</ul>
<h2>Example
<button class="dynlink" onclick="demoRun('code')">run</button>
<button class="dynlink" onclick="demoRestore('code')">restore</button>
</h2>
<pre id="code" class="use-editor" style="height: 200px;">
var b = require('bonescript');
var args = {
'main': ['int', ['int']]
};
var x = b.loadCModule('/usr/share/bone101/examples/extras/helloworld', args,false);
x.main(1, function (err, res) {}); //default sync usage
//x.main.async(1, function (err, res) {}); //async usage
</pre>
<div readonly id='console-output' style='height: 80px;'></div>
<h2>Build and execute instructions</h2>
<ul>
<li>Run the above to load a helloworld.c program at the path generated using <a href="{{site.baseurl}}/Support/BoneScript/writeCModule">writeCModule</a> </li>
<li>Modify the Path and Args to load other modules.</li>
</ul>
<h2>See also</h2>
<!--
<h3>Topics</h3>
<ul>
</ul>
-->
<h3>Related functions</h3>
<ul>
<li><a href="{{site.baseurl}}/Support/BoneScript/#require">require</a></li>
<li><a href="{{site.baseurl}}/Support/BoneScript/writeCModule">writeCModule</a></li>
</ul>


</div>
</div>
24 changes: 12 additions & 12 deletions Support/BoneScript/pinMode/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ <h2>Return value</h2>
<li><a href="{{site.baseurl}}/Support/BoneScript/#true">true</a> if successful</li>
<li><a href="{{site.baseurl}}/Support/BoneScript/#false">false</a> on failure</li>
</ul>
<h2>callback(x)</h2>
<h2>callback(err,value)</h2>
<ul>
<li><em>x.value</em>: return value</li>
<li><em>x.err</em>: error status message</li>
<li><em>value</em>: return value</li>
<li><em>err</em>: error status message</li>
</ul>
<h2>Example
<button class="dynlink" onclick="demoRun('code')">run</button>
Expand All @@ -60,16 +60,16 @@ <h2>Example
b.pinMode("P8_13", b.OUTPUT, 7, 'pullup',
'fast', printStatus);
b.getPinMode("P8_13", printPinMux);
function printStatus(x) {
console.log('value = ' + x.value);
console.log('err = ' + x.err);
function printStatus(err,value) {
console.log('value = ' + value);
console.log('err = ' + err);
}
function printPinMux(x) {
console.log('mux = ' + x.mux);
console.log('pullup = ' + x.pullup);
console.log('slew = ' + x.slew);
console.log('options = ' + x.options.join(','));
console.log('err = ' + x.err);
function printPinMux(err,resp) {
console.log('mux = ' + resp.mux);
console.log('pullup = ' + resp.pullup);
console.log('slew = ' + resp.slew);
console.log('options = ' + resp.options.join(','));
console.log('err = ' + err);
}</pre>
<div readonly id='console-output' style='height: 200px;'></div>
<h2>Build and execute instructions</h2>
Expand Down
12 changes: 6 additions & 6 deletions Support/BoneScript/readTextFile/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ <h2>Return value</h2>
<ul>
<li>File contents in a single string</li>
</ul>
<h2>callback(x)</h2>
<h2>callback(err,data)</h2>
<ul>
<li><em>x.data</em>: file contents</li>
<li><em>x.err</em>: error status message</li>
<li><em>data</em>: file contents</li>
<li><em>err</em>: error status message</li>
</ul>
<h2>Example
<button class="dynlink" onclick="demoRun('code')">run</button>
Expand All @@ -52,9 +52,9 @@ <h2>Example
<pre id="code" class="use-editor" style="height: 120px;">
var b = require('bonescript');
b.readTextFile('/etc/dogtag', printStatus);
function printStatus(x) {
console.log('x.data = ' + x.data);
console.log('x.err = ' + x.err);
function printStatus(err,data) {
console.log('data = ' + data);
console.log('err = ' + err);
}</pre>
<div readonly id='console-output' style='height: 80px;'></div>
<h2>Build and execute instructions</h2>
Expand Down
80 changes: 80 additions & 0 deletions Support/BoneScript/writeCModule/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
layout: index
title: writeCModule
scripts: [ '/Support/script/bonescript-demo.js' ]
style: |
#code {
position: relative;
width: 500px;
padding-left: 0;
border-radius: 4px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
margin-bottom: 0px;
margin-left: 30px;
margin-right: 0px;
align: left;
}
#console-output {
margin-top: 0px;
margin-left: 30px;
width: 496px;
border: 1px solid #cccccc;
resize: vertical;
}
---
{% include side_menu.html title="BoneScript" %}
<div class="t3_content_1">
<div id='connect-status'></div>
<div id="content_child">

<p>You might be able to see a newer version of this on <a href="http://beagleboard.org/support/bonescript/writeCModule">beagleboard.org/support/bonescript/writeCModule</a></p>
<h1>writeCModule(filename, code, [callback])</h1>
<p>write a C program with Source code provided in the code input at the filename path.</p>
<h2>Arguments</h2>
<ul>
<li><em>filename</em>: complete path of the file to be written</li>
<li><em>code</em>: code string to be written</li>
<li><em>callback</em>: called upon completion</li>
</ul>
<h2>callback(x)</h2>
<ul>
<li><em>x.err</em>: error status message</li>
</ul>
<h2>Example
<button class="dynlink" onclick="demoRun('code')">run</button>
<button class="dynlink" onclick="demoRestore('code')">restore</button>
</h2>
<pre id="code" class="use-editor" style="height: 200px;">
var b = require('bonescript');
var code = `
#include <stdio.h>
int main(int argc)
{
printf("Hello, World!");
return 0;
}`; //code enclosed between ``
b.writeCModule('/usr/share/bone101/examples/extras/helloworld', code);
</pre>
<div readonly id='console-output' style='height: 80px;'></div>
<h2>Build and execute instructions</h2>
<ul>
<li>Be careful not to overwrite important files!</li>
<li>Run the above to generate a helloworld.c file at the path and use <a href="{{site.baseurl}}/Support/BoneScript/loadCModule">loadCModule</a> to compile and run.</li>
<li>Modify the C code.</li>
</ul>
<h2>See also</h2>
<!--
<h3>Topics</h3>
<ul>
</ul>
-->
<h3>Related functions</h3>
<ul>
<li><a href="{{site.baseurl}}/Support/BoneScript/#require">require</a></li>
<li><a href="{{site.baseurl}}/Support/BoneScript/loadCModule">loadCModule</a></li>
</ul>


</div>
</div>
Loading