Skip to content

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mastashake08 committed Oct 24, 2023
1 parent 7f4149e commit aa1a4d4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
35 changes: 22 additions & 13 deletions classes/SerialManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class SerialManager extends WebIOT {
if ('serial' in navigator) { /* Scan and write NFC tags */
super(debug)
} else {
alert('NFC is not supported in your browser')
alert('Serial is not supported in your browser')
}
}

Expand Down Expand Up @@ -41,25 +41,34 @@ export class SerialManager extends WebIOT {
}

async readData () {
const reader = this.selectedPort.readable.getReader();

while(this.selectedPort.readable){
try {
const reader = this.selectedPort.readable.getReader();
while (true) {
const { value, done } = await reader.read();
if (done) {
// Allow the serial port to be closed later.
console.log('done')
reader.releaseLock();
break;
}
console.log(value.buffer)
console.log(done)
// value is a Uint8Array.
return value
}
} catch (e) {

// Listen to data coming from the serial device.
while (true) {
const { value, done } = await reader.read();
if (done) {
// Allow the serial port to be closed later.
console.log('done')
reader.releaseLock();
break;
}
// value is a Uint8Array.
return value

}

}

async writeData(data) {
const writer = this.selectedPort.writable.getWriter();

await writer.write(data);
// Allow the serial port to be closed later.

Expand Down
4 changes: 2 additions & 2 deletions 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": "@mastashake08/web-iot",
"version": "1.4.0",
"version": "1.4.1",
"description": "Connect to your IoT devices via usb, serial, NFC or Serial. Allows for callback integration and streaming *coming soon*",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit aa1a4d4

Please sign in to comment.