Log updates
[beagleboard.org.git] / db / 2737.xml
blob26a0eddbea6ddbbd2c3f8cf1195ec1d637a6077d
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <?xml-stylesheet type="text/xsl" href="helma.xsl"?>
3 <xmlroot xmlns:hop="http://www.helma.org/docs/guide/features/database">
4   <hopobject id="2737" name="wired_basic_test" prototype="Page" created="1370881904612" lastModified="1372265022864">
5   <hop:parent idref="2471" prototyperef="Page"/>
6     <is_xhtml type="boolean">true</is_xhtml>
7     <http_remotehost>127.0.0.1</http_remotehost>
8     <http_language>en-US,en;q=0.8</http_language>
9     <uri>wired_basic_test</uri>
10     <http_browser>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36</http_browser>
11     <time type="date">26.06.2013 11:43:42 CDT</time>
12     <hopsession>127.0.0.192.94.94.16y4dhn3hk151</hopsession>
13     <body>&lt;script src=&quot;/static/bonescript-demo.js&quot;&gt;&lt;/script&gt;\r
14 &lt;div id=&apos;side-menu&apos; class=&quot;t3_sidebar&quot;&gt;\r
15     &lt;ul class=&quot;left-menu&quot;&gt;&lt;strong&gt;Navigation&lt;/strong&gt;\r
16         &lt;li&gt;&lt;a href=&quot;/static/side-menu.html&quot;&gt;Menu contents&lt;/a&gt;&lt;/li&gt;\r
17     &lt;/ul&gt;\r
18 &lt;/div&gt;\r
19 &lt;div class=&quot;t3_content_1&quot;&gt;&lt;div id=&apos;connect-status&apos;&gt;&lt;/div&gt;&lt;div id=&quot;content_child&quot;&gt;\r
20 &lt;h1&gt;Demo: Wired basic test&lt;/h1&gt;\r
21 &lt;p&gt;This is a  test to verify the basic functionality of BoneScript. It requires\r
22     that you perform a small bit of external wiring to make sure output is valid\r
23     at the expansion header pins. If this test does not pass, it is recommended\r
24     that you update BoneScript. If after updating BoneScript this test still\r
25     does not pass, please report the issue on the &lt;a href=&quot;/discuss&quot;&gt;mailing\r
26         list\r
27     &lt;/a&gt;.\r
28 &lt;/p&gt;\r
29 &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRun(&apos;code&apos;)&quot;&gt;run&lt;/button&gt;\r
30 &lt;div readonly id=&apos;console-output&apos; style=&quot;height: 200px;&quot;&gt;&lt;/div&gt;\r
31 &lt;h2&gt;Build and execute instructions&lt;/h2&gt;\r
32 &lt;img src=&quot;/static/uploads/wired_basic_test_bb.png&quot; align=&quot;right&quot; width=&quot;300px&quot; /&gt;\r
33 &lt;ul&gt;\r
34     &lt;li&gt;Connect P9_23 to P9_24 through a 1kohm resistor.&lt;/li&gt;\r
35     &lt;li&gt;Connect P9_21 to P9_35 through a 1kohm resistor.&lt;/li&gt;\r
36     &lt;li&gt;Connect a 10uF (35V) capacitor to P9_35 with the other end tied to ground.&lt;/li&gt;\r
37     &lt;li&gt;Run the code and observe &apos;***PASS***&apos; at the end of the log.&lt;/li&gt;\r
38     &lt;li&gt;If you do not see &apos;***PASS***&apos;, look for exceptions in the run code.&lt;/li&gt;\r
39 &lt;/ul&gt;\r
40 &lt;div style=&quot;clear:both;&quot;&gt;&lt;/div&gt;\r
41 &lt;h2&gt;Code&lt;/h2&gt;\r
42 &lt;pre style=&quot;height: 1800px;&quot; id=&quot;code&quot; class=&quot;use-editor&quot;&gt;\r
43 var b = require(&apos;bonescript&apos;);\r
45 b.getPlatform(onGetPlatform);\r
47 function onGetPlatform(x) {\r
48     if(!x.name || !x.serialNumber || !x.version)\r
49         err(&apos;getPlatform returned &apos; + JSON.stringify(x));\r
50     console.log(&apos;Name = &apos; + x.name);\r
51     console.log(&apos;S/N = &apos; + x.serialNumber);\r
52     console.log(&apos;Version = &apos; + x.version);\r
53     console.log(&apos;BoneScript version = &apos; + x.bonescript);\r
54     if(x.bonescript != &apos;0.2.2&apos;)\r
55         err(&apos;BoneScript 0.2.2 required&apos;);\r
56     b.setDate(Date().toString(), onSetDate);\r
57 }\r
59 function onSetDate(x) {\r
60     if(x.stdout !== null) {\r
61         err(&apos;setDate returned &apos; + JSON.stringify(x));\r
62     }\r
63     b.echo(&apos;test&apos;, onEcho);\r
64 }\r
66 function onEcho(x) {\r
67     if(x.data != &apos;test&apos;) err(&apos;doEcho returned &apos; + JSON.stringify(x));\r
68     b.getPinMode(&apos;P9_20&apos;, onGetPinMode);\r
69 }\r
71 function onGetPinMode(x) {\r
72     if(x.mux != 3) err(&apos;getPinMode returned &apos; + JSON.stringify(x));\r
73     b.pinMode(&apos;P9_24&apos;, b.INPUT, 7, &apos;disabled&apos;, &apos;fast&apos;, onPinModeInput);\r
74 }\r
76 function onPinModeInput(x) {\r
77     if(x.value !== true) err(&apos;pinMode(input) returned &apos; + JSON.stringify(x));\r
78     b.pinMode(&apos;P9_23&apos;, b.OUTPUT, 7, &apos;disabled&apos;, &apos;fast&apos;, onPinModeOutput);\r
79 }\r
81 function onPinModeOutput(x) {\r
82     if(x.value !== true) err(&apos;pinMode(output) returned &apos; + JSON.stringify(x));\r
83     b.digitalWrite(&apos;P9_23&apos;, b.LOW, onDigitalWriteLow);\r
84 }\r
86 function onDigitalWriteLow(x) {\r
87     if(x.data !== null) err(&apos;digitalWrite(low) returned &apos; + JSON.stringify(x));\r
88     b.digitalRead(&apos;P9_24&apos;, onDigitalReadLow);\r
89 }\r
91 function onDigitalReadLow(x) {\r
92     if(x.value != b.LOW) err(&apos;digitalRead(low) returned &apos; + JSON.stringify(x));\r
93     b.digitalWrite(&apos;P9_23&apos;, b.HIGH, onDigitalWriteHigh);\r
94 }\r
96 function onDigitalWriteHigh(x) {\r
97     if(x.data !== null) err(&apos;digitalWrite(high) returned &apos; + JSON.stringify(x));\r
98     b.digitalRead(&apos;P9_24&apos;, onDigitalReadHigh);\r
99 }\r
101 function onDigitalReadHigh(x) {\r
102     if(x.value != b.HIGH) err(&apos;digitalRead(high) returned &apos; + JSON.stringify(x));\r
103     b.analogWrite(&apos;P9_21&apos;, 0.27, 2000.0, onAnalogWrite);\r
106 function onAnalogWrite(x) {\r
107     if(x.value !== true) err(&apos;analogWrite returned &apos; + JSON.stringify(x));\r
108     setTimeout(doAnalogRead, 1000);\r
111 function doAnalogRead() {\r
112     b.analogRead(&apos;P9_35&apos;, onAnalogRead);\r
115 function onAnalogRead(x) {\r
116     if(x.value &gt; 0.55 || x.value &lt; 0.45)\r
117         err(&apos;analogRead returned &apos; + JSON.stringify(x));\r
118     b.writeTextFile(&apos;/tmp/basic_test&apos;, &apos;So far so good&apos;, onWriteTextFile);\r
121 function onWriteTextFile(x) {\r
122     if(x.err !== null) err(&apos;writeTextFile returned &apos; + JSON.stringify(x));\r
123     b.readTextFile(&apos;/tmp/basic_test&apos;, onReadTextFile);\r
126 function onReadTextFile(x) {\r
127     if(x.err !== null) err(&apos;readTextFile returned &apos; + JSON.stringify(x));\r
128     if(x.data != &apos;So far so good&apos;)\r
129         err(&apos;onReadTextFile returned &apos; + JSON.stringify(x));\r
130     complete();\r
133 function complete() {\r
134     console.log(&apos;***PASS***&apos;);\r
135     process.exit(0);\r
138 function err(x) {\r
139     console.log(&apos;***FAIL*** &apos; + x);\r
140     throw(x);\r
143 function printJSON(x) {\r
144     console.log(&apos;x = &apos; + JSON.stringify(x));\r
145 }&lt;/pre&gt;\r
146 &lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</body>
147     <pseudoparent idref="2471" prototyperef="Page"/>
148     <http_referer>http://beagleboard.org/support/BoneScript/wired_basic_test/edit</http_referer>
149     <http_host>beagleboard.org</http_host>
150     <user>jkridner@gmail.com</user>
151     <lang>en-us</lang>
152   </hopobject>
153 </xmlroot>