Skip to content

Commit

Permalink
Merge pull request #5 from abkonsta/master
Browse files Browse the repository at this point in the history
Add monitor function
  • Loading branch information
paulcuth committed Oct 26, 2015
2 parents 12201bc + a86ab38 commit b07f782
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
11 changes: 8 additions & 3 deletions README.md
Expand Up @@ -78,8 +78,13 @@ $ esp run "print 'Mechanisms, not policy.'"
Mechanisms, not policy.
```

#### monitor
Displays the data received from the serial port.
```
$ esp monitor
Displaying output from port /dev/cu.wchusbserial1410.
Press ^C to stop.
```

## License
MIT



13 changes: 10 additions & 3 deletions bin/cli.js
Expand Up @@ -137,11 +137,18 @@ var config = {
.then(console.log)
.then(comms.close.bind(comms));
});
}

};
},

monitor: function() {
console.log("Displaying output from port " + port + ".");
console.log("Press ^C to stop.\n");

new SerialComms(port).on('ready', function (comms) {
comms.monitor();
});
}

};


function execute (config, args) {
Expand Down
5 changes: 5 additions & 0 deletions src/SerialComms.js
Expand Up @@ -82,5 +82,10 @@ SerialComms.prototype.close = function () {
};


SerialComms.prototype.monitor = function() {
this._port.on('data', function(data) {
process.stdout.write(data);
});
}

module.exports = SerialComms;

0 comments on commit b07f782

Please sign in to comment.