Web edits
[beagleboard.org.git] / db / 2737.xml
blobce40524a693808eba1c0ddd73784ab2735c2ba52
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="1373380628516">
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">09.07.2013 09:37:08 CDT</time>
12     <hopsession>127.0.0.192.91.66.1u0nc432fl6ke</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;p&gt;This current version tests the installation of BoneScript 0.2.2 provided in\r
30     the 2013-06-20 Angstrom image. Installation instructions are at \r
31     &lt;a href=&quot;/getting-started&quot;&gt;\r
32         the Getting Started page\r
33     &lt;/a&gt;.\r
34 &lt;/p&gt;\r
35 &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRun(&apos;code&apos;)&quot;&gt;run&lt;/button&gt;\r
36 &lt;div readonly id=&apos;console-output&apos; style=&quot;height: 200px;&quot;&gt;&lt;/div&gt;\r
37 &lt;h2&gt;Build and execute instructions&lt;/h2&gt;\r
38 &lt;img src=&quot;/static/uploads/wired_basic_test_bb.png&quot; align=&quot;right&quot; width=&quot;300px&quot; /&gt;\r
39 &lt;ul&gt;\r
40     &lt;li&gt;Connect P9_23 to P9_24 through a 1kohm resistor.&lt;/li&gt;\r
41     &lt;li&gt;Connect P9_21 to P9_35 through a 1kohm resistor.&lt;/li&gt;\r
42     &lt;li&gt;Connect a 10uF (35V) capacitor to P9_35 with the other end tied to ground.&lt;/li&gt;\r
43     &lt;li&gt;Run the code and observe &apos;***PASS***&apos; at the end of the log.&lt;/li&gt;\r
44     &lt;li&gt;If you do not see &apos;***PASS***&apos;, look for exceptions in the run code.&lt;/li&gt;\r
45 &lt;/ul&gt;\r
46 &lt;div style=&quot;clear:both;&quot;&gt;&lt;/div&gt;\r
47 &lt;h2&gt;Code&lt;/h2&gt;\r
48 &lt;pre style=&quot;height: 1800px;&quot; id=&quot;code&quot; class=&quot;use-editor&quot;&gt;\r
49 var b = require(&apos;bonescript&apos;);\r
51 b.getPlatform(onGetPlatform);\r
53 function onGetPlatform(x) {\r
54     if(!x.name || !x.serialNumber || !x.version)\r
55         err(&apos;getPlatform returned &apos; + JSON.stringify(x));\r
56     console.log(&apos;Name = &apos; + x.name);\r
57     console.log(&apos;S/N = &apos; + x.serialNumber);\r
58     console.log(&apos;Version = &apos; + x.version);\r
59     console.log(&apos;BoneScript version = &apos; + x.bonescript);\r
60     if(x.bonescript != &apos;0.2.2&apos;)\r
61         err(&apos;BoneScript 0.2.2 required&apos;);\r
62     b.setDate(Date().toString(), onSetDate);\r
63 }\r
65 function onSetDate(x) {\r
66     if(x.stdout !== null) {\r
67         err(&apos;setDate returned &apos; + JSON.stringify(x));\r
68     }\r
69     b.echo(&apos;test&apos;, onEcho);\r
70 }\r
72 function onEcho(x) {\r
73     if(x.data != &apos;test&apos;) err(&apos;doEcho returned &apos; + JSON.stringify(x));\r
74     b.getPinMode(&apos;P9_20&apos;, onGetPinMode);\r
75 }\r
77 function onGetPinMode(x) {\r
78     if(x.mux != 3) err(&apos;getPinMode returned &apos; + JSON.stringify(x));\r
79     b.pinMode(&apos;P9_24&apos;, b.INPUT, 7, &apos;disabled&apos;, &apos;fast&apos;, onPinModeInput);\r
80 }\r
82 function onPinModeInput(x) {\r
83     if(x.value !== true) err(&apos;pinMode(input) returned &apos; + JSON.stringify(x));\r
84     b.pinMode(&apos;P9_23&apos;, b.OUTPUT, 7, &apos;disabled&apos;, &apos;fast&apos;, onPinModeOutput);\r
85 }\r
87 function onPinModeOutput(x) {\r
88     if(x.value !== true) err(&apos;pinMode(output) returned &apos; + JSON.stringify(x));\r
89     b.digitalWrite(&apos;P9_23&apos;, b.LOW, onDigitalWriteLow);\r
90 }\r
92 function onDigitalWriteLow(x) {\r
93     if(x.data !== null) err(&apos;digitalWrite(low) returned &apos; + JSON.stringify(x));\r
94     b.digitalRead(&apos;P9_24&apos;, onDigitalReadLow);\r
95 }\r
97 function onDigitalReadLow(x) {\r
98     if(x.value != b.LOW) err(&apos;digitalRead(low) returned &apos; + JSON.stringify(x));\r
99     b.digitalWrite(&apos;P9_23&apos;, b.HIGH, onDigitalWriteHigh);\r
102 function onDigitalWriteHigh(x) {\r
103     if(x.data !== null) err(&apos;digitalWrite(high) returned &apos; + JSON.stringify(x));\r
104     b.digitalRead(&apos;P9_24&apos;, onDigitalReadHigh);\r
107 function onDigitalReadHigh(x) {\r
108     if(x.value != b.HIGH) err(&apos;digitalRead(high) returned &apos; + JSON.stringify(x));\r
109     b.analogWrite(&apos;P9_21&apos;, 0.27, 2000.0, onAnalogWrite);\r
112 function onAnalogWrite(x) {\r
113     if(x.value !== true) err(&apos;analogWrite returned &apos; + JSON.stringify(x));\r
114     setTimeout(doAnalogRead, 1000);\r
117 function doAnalogRead() {\r
118     b.analogRead(&apos;P9_35&apos;, onAnalogRead);\r
121 function onAnalogRead(x) {\r
122     if(x.value &gt; 0.55 || x.value &lt; 0.45)\r
123         err(&apos;analogRead returned &apos; + JSON.stringify(x));\r
124     b.writeTextFile(&apos;/tmp/basic_test&apos;, &apos;So far so good&apos;, onWriteTextFile);\r
127 function onWriteTextFile(x) {\r
128     if(x.err !== null) err(&apos;writeTextFile returned &apos; + JSON.stringify(x));\r
129     b.readTextFile(&apos;/tmp/basic_test&apos;, onReadTextFile);\r
132 function onReadTextFile(x) {\r
133     if(x.err !== null) err(&apos;readTextFile returned &apos; + JSON.stringify(x));\r
134     if(x.data != &apos;So far so good&apos;)\r
135         err(&apos;onReadTextFile returned &apos; + JSON.stringify(x));\r
136     complete();\r
139 function complete() {\r
140     console.log(&apos;***PASS***&apos;);\r
141     process.exit(0);\r
144 function err(x) {\r
145     console.log(&apos;***FAIL*** &apos; + x);\r
146     throw(x);\r
149 function printJSON(x) {\r
150     console.log(&apos;x = &apos; + JSON.stringify(x));\r
151 }&lt;/pre&gt;\r
152 &lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</body>
153     <pseudoparent idref="2471" prototyperef="Page"/>
154     <http_referer>http://beagleboard.org/support/BoneScript/wired_basic_test/edit</http_referer>
155     <http_host>beagleboard.org</http_host>
156     <user>blog.hangerhead.com</user>
157     <lang>en-us</lang>
158   </hopobject>
159 </xmlroot>