Skip to content

Commit d327baa

Browse files
committed
Use await on closing connection and readme update
1 parent 5aaa640 commit d327baa

8 files changed

+9
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is an partial port of [pyboard.py](https://docs.micropython.org/en/latest/r
44

55
## Basic usage
66

7-
```
7+
```js
88
const Board = require('micropython.js')
99
// Instantiate board class
1010
const board = new Board()
@@ -26,7 +26,7 @@ const rootFiles = await board.fs_ils()
2626
console.log('files at /', rootFiles)
2727

2828
// Close serial
29-
board.close()
29+
await board.close()
3030
```
3131

3232
## Examples

examples/02_execute_file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async function main() {
77
const output = await board.execfile('./test.py')
88
console.log('output')
99
console.log(output)
10-
board.close()
10+
await board.close()
1111
}
1212

1313
main()

examples/03_put_file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async function main() {
66
console.log('sending file to board')
77
await board.fs_put('./big_file.py', 'test.py', console.log)
88
console.log('done')
9-
board.close()
9+
await board.close()
1010
}
1111

1212
main()

examples/04_remove_file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async function main() {
66
console.log('removing file from board')
77
await board.fs_rm('test.py')
88
console.log('done')
9-
board.close()
9+
await board.close()
1010
}
1111

1212
main()

examples/05_list_files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ async function main() {
99
const libFiles = await board.fs_ils('lib')
1010
console.log('files at /lib')
1111
console.log(libFiles)
12-
board.close()
12+
await board.close()
1313
}
1414

1515
main()

examples/06_get_file_contents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async function main() {
66
const output = await board.fs_cat('test.py')
77
console.log('file contents:')
88
console.log(output)
9-
board.close()
9+
await board.close()
1010
}
1111

1212
main()

examples/07_save_file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function main() {
2424
console.log('saving content to file')
2525
await board.fs_save(content, 'test.py')
2626
console.log('done')
27-
board.close()
27+
await board.close()
2828
}
2929

3030
main()

examples/08_file_exists.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async function main() {
1818
console.log('xxxxxxxxxxx does not exist')
1919
}
2020

21-
board.close()
21+
await board.close()
2222
}
2323

2424
main()

0 commit comments

Comments
 (0)