Created
April 5, 2019 06:59
-
-
Save daniellandau/01d494a835741198a64232297b0fbd03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs") | |
const buf = fs.readFileSync("/dev/stdin") | |
if (buf.length !== 20) { | |
console.log(`${+new Date()};error;error;error`) | |
process.exit() | |
} | |
const offset = 8 | |
const dataByteSize = 12 | |
const dataSize = dataByteSize / 4 | |
const arbuf = new ArrayBuffer(dataByteSize) | |
const intView = new Int32Array(arbuf) | |
const floatView = new Float32Array(arbuf) | |
for (let i = 0; i < dataSize; ++i) { | |
intView[i] = | |
buf[offset + i * 4 + 0] << 24 | | |
buf[offset + i * 4 + 1] << 16 | | |
buf[offset + i * 4 + 2] << 8 | | |
buf[offset + i * 4 + 3] << 0 | |
} | |
let result = "" | |
result += +new Date() | |
for (let i = 0; i < dataSize; ++i) { | |
result += `;${floatView[i]}` | |
} | |
console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment