Skip to content

Commit 54b7f98

Browse files
authored
Throwing an error when device is not found (#552)
* Updated logic to extract the file extension * Upgraded a 'busy' message to an 'error' message when the device is not found
1 parent d160155 commit 54b7f98

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@
44
# arduino-create-agent-js-client
55
JS module providing discovery of the [Arduino Create Agent](https://github.com/arduino/arduino-create-agent) and communication with it
66

7+
78
## Changelog
8-
[2.9.0] - 2022-06-06
9+
[2.9.1-alpha.2] - 2022-08-17
10+
11+
### Changed
12+
- The error `No device found` coming from the `arduino-create-agent` is now treated as an error.
13+
14+
## Changelog
15+
[2.9.1-alpha.1] - 2022-07-28
16+
17+
### Added
18+
- Added support for ESP boards (experimental)
919

20+
## Changelog
21+
[2.9.0] - 2022-06-06
1022
### Added
1123
- Added support for "Arduino RP2040 Connect" board
1224
### Changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "arduino-create-agent-js-client",
3-
"version": "2.9.0",
3+
"version": "2.9.1-alpha.2",
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default class Daemon {
130130
})
131131
.then(result => result.json())
132132
.then(uploadCommandInfo => {
133-
const projectNameIndex = uploadCommandInfo.commandline.indexOf('{build.project_name}');
133+
const projectNameIndex = uploadCommandInfo.commandline.lastIndexOf('{build.project_name}');
134134
let ext = uploadCommandInfo.commandline.substring(projectNameIndex + 21, projectNameIndex + 24);
135135
const data = compilationResult[ext] || compilationResult.bin;
136136
if (!ext || !data) {

src/socket-daemon.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,12 @@ export default class SocketDaemon extends Daemon {
392392
this.uploading.next({ status: this.UPLOAD_IN_PROGRESS, msg: `Programming with: ${message.Cmd}` });
393393
break;
394394
case 'Busy':
395-
this.uploading.next({ status: this.UPLOAD_IN_PROGRESS, msg: message.Msg });
395+
if (message.Msg && message.Msg.indexOf('No device found') === 0) {
396+
this.uploading.next({ status: this.UPLOAD_ERROR, err: message.Msg });
397+
}
398+
else {
399+
this.uploading.next({ status: this.UPLOAD_IN_PROGRESS, msg: message.Msg });
400+
}
396401
break;
397402
case 'Error':
398403
this.uploading.next({ status: this.UPLOAD_ERROR, err: message.Msg });

0 commit comments

Comments
 (0)