Skip to content

Commit

Permalink
Output serial with port (#447)
Browse files Browse the repository at this point in the history
* support messages from serial monitor with port [EDITOR-621]

* 2.4.0
  • Loading branch information
Stefania authored Feb 10, 2021
1 parent 7f96f4e commit 45d43b5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions demo/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions src/socket-daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 45d43b5

Please sign in to comment.