Skip to content

Output serial with port #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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