/
timed_microsd.js
29 lines (24 loc) · 966 Bytes
/
timed_microsd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
/*********************************************
This MicroSD card example writes a text file
to the sd card, then reads the file to the
console.
*********************************************/
var _start = Date.now();
var tessel = require('tessel'),
sdcardlib = require('../'); // Replace '../' with 'sdcard' in your own code.
sdcardlib.use(tessel.port['A'], {getFilesystems:true}, function(e, fss) {
if (e) throw e;
var fs = fss[0],
start = Date.now();
console.log("_time_", start - _start);
console.log('Writing...');
fs.writeFile('someFile.txt', 'Hey Tessel SDCard!', function(err) {
console.log('Write complete. Reading...');
fs.readFile('someFile.txt', function(err, data) {
console.log('Read:\n', data.toString());
console.log(":TIME:", Date.now()-start);
});
});
});