Skip to content

Serial open error #159

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
Jun 7, 2019
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
4 changes: 4 additions & 0 deletions demo/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ class App extends React.Component {
});

daemon.error.subscribe(this.showError);
daemon.serialMonitorError.subscribe(this.showError);
daemon.uploadingError.subscribe(this.showError);
daemon.downloadingError.subscribe(this.showError);

daemon.devicesList.subscribe(({ serial, network }) => this.setState({
serialDevices: serial,
Expand Down Expand Up @@ -155,6 +158,7 @@ class App extends React.Component {

showError(err) {
this.setState({ error: err });
scrollToBottom(document.body);
}

clearError() {
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.2.6",
"version": "2.3.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
8 changes: 4 additions & 4 deletions src/chrome-app-daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default class ChromeOsDaemon extends Daemon {
}
const serialPort = this.devicesList.getValue().serial.find(p => p.Name === port);
if (!serialPort) {
return this.serialMonitorOpened.error(new Error(`Can't find port ${port}`));
return this.serialMonitorError.next(`Can't find port ${port}`);
}
this.appMessages
.pipe(takeUntil(this.serialMonitorOpened.pipe(filter(open => open))))
Expand All @@ -167,7 +167,7 @@ export default class ChromeOsDaemon extends Daemon {
this.serialMonitorOpened.next(true);
}
if (message.portOpenStatus === 'error') {
this.serialMonitorOpened.error(new Error(`Failed to open serial ${port}`));
this.serialMonitorError.next(`Failed to open serial ${port}`);
}
});
this.channel.postMessage({
Expand All @@ -189,7 +189,7 @@ export default class ChromeOsDaemon extends Daemon {
}
const serialPort = this.devicesList.getValue().serial.find(p => p.Name === port);
if (!serialPort) {
return this.serialMonitorOpened.error(new Error(`Can't find port ${port}`));
return this.serialMonitorError.next(`Can't find port ${port}`);
}
this.appMessages
.pipe(takeUntil(this.serialMonitorOpened.pipe(filter(open => !open))))
Expand All @@ -198,7 +198,7 @@ export default class ChromeOsDaemon extends Daemon {
this.serialMonitorOpened.next(false);
}
if (message.portCloseStatus === 'error') {
this.serialMonitorOpened.error(new Error(`Failed to close serial ${port}`));
this.serialMonitorError.next(`Failed to close serial ${port}`);
}
});
this.channel.postMessage({
Expand Down
1 change: 1 addition & 0 deletions src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default class Daemon {
this.channelOpen = new BehaviorSubject(null);
this.channelOpenStatus = this.channelOpen.pipe(distinctUntilChanged());
this.error = new BehaviorSubject(null).pipe(distinctUntilChanged());
this.serialMonitorError = new BehaviorSubject(null);

this.appMessages = new Subject();
this.serialMonitorOpened = new BehaviorSubject(false);
Expand Down
6 changes: 3 additions & 3 deletions src/socket-daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export default class SocketDaemon extends Daemon {
openSerialMonitor(port, baudrate = 9600) {
const serialPort = this.devicesList.getValue().serial.find(p => p.Name === port);
if (!serialPort) {
return this.serialMonitorOpened.error(new Error(`Can't find board at ${port}`));
return this.serialMonitorError.next(`Can't find board at ${port}`);
}
if (this.uploading.getValue().status === this.UPLOAD_IN_PROGRESS || serialPort.IsOpen) {
return;
Expand All @@ -349,7 +349,7 @@ export default class SocketDaemon extends Daemon {
this.serialMonitorOpened.next(true);
}
if (message.Cmd === 'OpenFail') {
this.serialMonitorOpened.error(new Error(`Failed to open serial monitor at ${port}`));
this.serialMonitorError.next(`Failed to open serial monitor at ${port}`);
}
});

Expand All @@ -373,7 +373,7 @@ export default class SocketDaemon extends Daemon {
this.serialMonitorOpened.next(false);
}
if (message.Cmd === 'CloseFail') {
this.serialMonitorOpened.error(new Error(`Failed to close serial monitor at ${port}`));
this.serialMonitorError.next(`Failed to close serial monitor at ${port}`);
}
});
this.socket.emit('command', `close ${port}`);
Expand Down