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="2783" name="writeTextFile" prototype="Page" created="1371825643047" lastModified="1371825643063">
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>writeTextFile</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.110 Safari/537.36</http_browser>
11 <time type="date">21.06.2013 09:40:43 CDT</time>
12 <hopsession>127.0.0.192.94.94.z5cudt01kfu3</hopsession>
13 <body><script src="/static/bonescript-demo.js"></script>
\r
14 <h2>BonesSript</h2>
\r
16 <div id='side-menu' class="t3_sidebar">
\r
17 <ul class="left-menu">
\r
18 <strong>Navigation</strong>
\r
19 <li><a href="/Support/BoneScript/menu/">Menu contents</a></li>
\r
22 <div class="t3_content_1">
\r
23 <div id='connect-status'></div>
\r
24 <div id="content_child">
\r
25 <!--- START CONTENT -->
\r
27 <h1>writeTextFile(filename, data, [callback])</h1>
\r
28 <p>Write the contents of a text (ASCII) file.</p>
\r
29 <h2>Arguments</h2>
\r
31 <li><em>filename</em>: complete path of the file to be written</li>
\r
32 <li><em>data</em>: ASCII string to be written</li>
\r
33 <li><em>callback</em>: called upon completion</li>
\r
35 <h2>Return value</h2>
\r
36 <h2>callback(x)</h2>
\r
38 <li><em>x.err</em>: error status message</li>
\r
41 <button class="dynlink" onclick="demoRun('code')">run</button>
\r
42 <button class="dynlink" onclick="demoRestore('code')">restore</button>
\r
44 <pre id="code" class="use-editor" style="height: 200px;">
\r
45 var b = require('bonescript');
\r
46 var file = '/sys/class/leds/beaglebone:green:usr3/trigger';
\r
47 b.writeTextFile(file, 'heartbeat', readStatus);
\r
48 function readStatus(x) {
\r
49 console.log(JSON.stringify(x));
\r
50 b.readTextFile(file, printStatus);
\r
52 function printStatus(x) {
\r
53 console.log(JSON.stringify(x));
\r
55 <div readonly id='console-output' style='height: 80px;'></div>
\r
56 <h2>Build and execute instructions</h2>
\r
58 <li>Be careful not to overwrite important files!</li>
\r
59 <li>Run the above to see the USR3 LED start to blink in a heartbeat pattern.</li>
\r
60 <li>Adjust the LED selection and trigger.</li>
\r
62 <h2>See also</h2>
\r
64 <h3>Topics</h3>
\r
68 <h3>Related functions</h3>
\r
70 <li><a href="/Support/BoneScript/#require">require</a></li>
\r
71 <li><a href="/Support/BoneScript/readTextFile/">readTextFile</a></li>
\r
73 <h3>Examples</h3>
\r
75 <li><a href="/Support/BoneScript/demo_bmp085/">BMP085 I2C pressure/temperature sensor
\r
76 demo</a></li>
\r
77 <li><a href="/Support/BoneScript/demo_bmp085_graphing/">BMP085 I2C pressure/temperature
\r
78 sensor graphing demo</a></li>
\r
81 <!--- START FOOTER -->
\r
84 <div style="clear:both;"></div></body>
85 <pseudoparent idref="2471" prototyperef="Page"/>
86 <http_referer>http://beagleboard.org/Support/BoneScript/writeTextFile/edit</http_referer>
87 <http_host>beagleboard.org</http_host>
89 <user>blog.hangerhead.com</user>