diff --git a/README.md b/README.md index e1036718..2cceba97 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,22 @@ daemon.devicesList.subscribe(({serial, network}) => { // Open serial monitor daemon.openSerialMonitor('port-name'); -// Read from serial monitor +// Read from serial monitor (ouputs string) daemon.serialMonitorMessages.subscribe(message => { console.log(message); }); +// Read from serial monitor, output object with source port name +/* + { + "P": "dev/ttyACM0", + "D":"output text here\r\n" + } +*/ +daemon.serialMonitorMessagesWithPort.subscribe(messageObj => { + console.log(messageObj); +}); + // Write to serial monitor daemon.writeSerial('port-name', 'message'); @@ -72,7 +83,7 @@ daemon.downloading.subscribe(download => { ## Version 2 -Version 2 of the arduino-create-agent aims to provide a cleaner api based on promises. +Version 2 of the arduino-create-agent aims to provide a cleaner api based on promises. It will remain confined to a v2 property on the daemon object until it will be stable. At the moment it only supports tool management. diff --git a/demo/app.jsx b/demo/app.jsx index 7a906b7b..92c6ba7d 100644 --- a/demo/app.jsx +++ b/demo/app.jsx @@ -134,6 +134,10 @@ class App extends React.Component { scrollToBottom(serialTextarea); }); + daemon.serialMonitorMessagesWithPort.subscribe(messageObj => { + console.log(messageObj); + }); + daemon.uploading.subscribe(upload => { this.setState({ uploadStatus: upload.status, uploadError: upload.err }); // console.log(upload); diff --git a/package-lock.json b/package-lock.json index bd9c9cc4..90f8aa0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "arduino-create-agent-js-client", - "version": "2.3.6", + "version": "2.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1f7a68d6..b697fead 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arduino-create-agent-js-client", - "version": "2.3.6", + "version": "2.4.0", "description": "JS module providing discovery of the Arduino Create Plugin and communication with it", "main": "lib/index.js", "module": "es/index.js", diff --git a/src/daemon.js b/src/daemon.js index 64e404bf..9fcde5d9 100644 --- a/src/daemon.js +++ b/src/daemon.js @@ -50,6 +50,7 @@ export default class Daemon { this.appMessages = new Subject(); this.serialMonitorOpened = new BehaviorSubject(false); this.serialMonitorMessages = new Subject(); + this.serialMonitorMessagesWithPort = new Subject(); this.uploading = new BehaviorSubject({ status: this.UPLOAD_NOPE }); this.uploadingDone = this.uploading.pipe(filter(upload => upload.status === this.UPLOAD_DONE)) .pipe(first()) diff --git a/src/socket-daemon.js b/src/socket-daemon.js index 4c9beecc..ccd063c0 100644 --- a/src/socket-daemon.js +++ b/src/socket-daemon.js @@ -240,6 +240,7 @@ export default class SocketDaemon extends Daemon { // Serial monitor message if (message.D) { this.serialMonitorMessages.next(message.D); + this.serialMonitorMessagesWithPort.next(message); } if (message.ProgrammerStatus) {