Skip to content

Commit 45d43b5

Browse files
author
Stefania
authored
Output serial with port (#447)
* support messages from serial monitor with port [EDITOR-621] * 2.4.0
1 parent 7f96f4e commit 45d43b5

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,22 @@ daemon.devicesList.subscribe(({serial, network}) => {
3838
// Open serial monitor
3939
daemon.openSerialMonitor('port-name');
4040

41-
// Read from serial monitor
41+
// Read from serial monitor (ouputs string)
4242
daemon.serialMonitorMessages.subscribe(message => {
4343
console.log(message);
4444
});
4545

46+
// Read from serial monitor, output object with source port name
47+
/*
48+
{
49+
"P": "dev/ttyACM0",
50+
"D":"output text here\r\n"
51+
}
52+
*/
53+
daemon.serialMonitorMessagesWithPort.subscribe(messageObj => {
54+
console.log(messageObj);
55+
});
56+
4657
// Write to serial monitor
4758
daemon.writeSerial('port-name', 'message');
4859

@@ -72,7 +83,7 @@ daemon.downloading.subscribe(download => {
7283

7384
## Version 2
7485

75-
Version 2 of the arduino-create-agent aims to provide a cleaner api based on promises.
86+
Version 2 of the arduino-create-agent aims to provide a cleaner api based on promises.
7687
It will remain confined to a v2 property on the daemon object until it will be stable.
7788
At the moment it only supports tool management.
7889

demo/app.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ class App extends React.Component {
134134
scrollToBottom(serialTextarea);
135135
});
136136

137+
daemon.serialMonitorMessagesWithPort.subscribe(messageObj => {
138+
console.log(messageObj);
139+
});
140+
137141
daemon.uploading.subscribe(upload => {
138142
this.setState({ uploadStatus: upload.status, uploadError: upload.err });
139143
// console.log(upload);

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "arduino-create-agent-js-client",
3-
"version": "2.3.6",
3+
"version": "2.4.0",
44
"description": "JS module providing discovery of the Arduino Create Plugin and communication with it",
55
"main": "lib/index.js",
66
"module": "es/index.js",

src/daemon.js

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default class Daemon {
5050
this.appMessages = new Subject();
5151
this.serialMonitorOpened = new BehaviorSubject(false);
5252
this.serialMonitorMessages = new Subject();
53+
this.serialMonitorMessagesWithPort = new Subject();
5354
this.uploading = new BehaviorSubject({ status: this.UPLOAD_NOPE });
5455
this.uploadingDone = this.uploading.pipe(filter(upload => upload.status === this.UPLOAD_DONE))
5556
.pipe(first())

src/socket-daemon.js

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export default class SocketDaemon extends Daemon {
240240
// Serial monitor message
241241
if (message.D) {
242242
this.serialMonitorMessages.next(message.D);
243+
this.serialMonitorMessagesWithPort.next(message);
243244
}
244245

245246
if (message.ProgrammerStatus) {

0 commit comments

Comments
 (0)