Skip to content

Commit

Permalink
feature: support reading actisense ebl files (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 authored Feb 9, 2021
1 parent 2ff2b0a commit 21792a1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
47 changes: 47 additions & 0 deletions bin/actisense-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env node

const { EventEmitter } = require('events');

var device

const argv = require('minimist')(process.argv.slice(2), {
alias: { h: 'help' }
})

if ( argv['help'] ) {
console.error(`Usage: ${process.argv[0]} file
Options:
-h, --help output usage information`)
process.exit(1)
}

if ( argv['_'].length === 0 ) {
console.error('Please specify a file')
process.exit(1)
}

const app = new EventEmitter();

const serial = new (require('../lib/serial'))({ app:app, plainText:true, disableSetTransmitPGNs: true, fromFile: true })
const { Transform } = require('stream');

const toStringTr = new Transform({
objectMode: true,

transform(chunk, encoding, callback) {
this.push(chunk + "\n");
callback();
}
});

serial.pipe(toStringTr).pipe(process.stdout)

filestream = require('fs').createReadStream(argv['_'][0])
filestream.on('error', err => {
console.error(err.message)
})
filestream.on('end', () => {
process.exit(0)
})
filestream.pipe(serial)
4 changes: 3 additions & 1 deletion lib/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,9 @@ function composeDisablePGN(pgn) {
}

SerialStream.prototype.end = function () {
this.serial.close()
if ( this.serial ) {
this.serial.close()
}
}

SerialStream.prototype._transform = function (chunk, encoding, done) {
Expand Down

0 comments on commit 21792a1

Please sign in to comment.