Skip to content

Commit 9c3e15b

Browse files
author
smellai
committed
Merge branch 'refactoring-rxjs' of github.com:bcmi-labs/create-plugin-communication into refactoring-rxjs
2 parents 7c9cd67 + 8a5f583 commit 9c3e15b

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/boardConfiguration.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import { BehaviorSubject } from 'rxjs';
3131
import { takeUntil, filter, first } from 'rxjs/operators';
3232
import { provisioningSketch } from './sketches/provisioning.ino';
33+
import { read } from 'fs';
3334

3435
const BAUDRATE = 9600;
3536

@@ -155,7 +156,11 @@ export default class BoardConfiguration {
155156
this.configuring.next({ status: this.CONFIGURE_IN_PROGRESS, msg: 'Starting board configuration' });
156157
if (!this.daemon.channelOpen.getValue()) {
157158
const errorMessage = `Couldn't configure board at port ${board.port} because we there is no open channel to the Arduino Create Plugin.`;
158-
this.configuring.next({ status: this.CONFIGURE_ERROR, err: errorMessage });
159+
this.configuring.next({
160+
status: this.CONFIGURE_ERROR,
161+
msg: errorMessage,
162+
err: 'cannot find plugin'
163+
});
159164
return;
160165
}
161166
this.serialMonitorContent = '';
@@ -186,7 +191,11 @@ export default class BoardConfiguration {
186191
// check the uploading status:
187192
if (this.daemon.uploading.getValue().status === this.daemon.UPLOAD_IN_PROGRESS) {
188193
// if there is an upload in course, notify observers;
189-
this.configuring.next({ status: this.CONFIGURE_ERROR, err: `Couldn't configure board at port ${board.port}. There is already an upload in progress.` });
194+
this.configuring.next({
195+
status: this.CONFIGURE_ERROR,
196+
msg: `Couldn't configure board at port ${board.port}. There is already an upload in progress.`,
197+
err: `upload in progress`
198+
});
190199
return;
191200
}
192201

@@ -199,9 +208,16 @@ export default class BoardConfiguration {
199208
.then(() => this.configuring.next({ status: this.CONFIGURE_DONE }))
200209
.catch(reason => this.configuring.next({
201210
status: this.CONFIGURE_ERROR,
202-
err: `Couldn't configure board at port ${board.port}. Configuration failed with error: ${reason}`
211+
msg: `Couldn't configure board at port ${board.port}. Configuration failed with error: ${reason}`,
212+
err: reason.toString()
203213
}))
204214
.finally(() => this.daemon.closeSerialMonitor(board.port, BAUDRATE));
215+
}, error => {
216+
this.configuring.next({
217+
status: this.CONFIGURE_ERROR,
218+
msg: `Couldn't configure board at port ${board.port}. Configuration failed with error: ${error}`,
219+
err: error.toString()
220+
});
205221
});
206222
this.daemon.openSerialMonitor(board.port, BAUDRATE);
207223
});

src/socket-daemon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export default class SocketDaemon extends Daemon {
284284

285285
const serialPort = this.devicesList.getValue().serial.find(p => p.Name === port);
286286
if (!serialPort) {
287-
return this.serialMonitorOpened.error(new Error(`Can't find port ${port}`));
287+
return this.serialMonitorOpened.error(new Error(`Can't find board at ${port}`));
288288
}
289289
this.appMessages
290290
.pipe(takeUntil(this.serialMonitorOpened.pipe(filter(open => open))))
@@ -293,7 +293,7 @@ export default class SocketDaemon extends Daemon {
293293
this.serialMonitorOpened.next(true);
294294
}
295295
if (message.Cmd === 'OpenFail') {
296-
this.serialMonitorOpened.error(new Error(`Failed to open serial ${port}`));
296+
this.serialMonitorOpened.error(new Error(`Failed to open serial monitor at ${port}`));
297297
}
298298
});
299299

0 commit comments

Comments
 (0)