mirror of
https://github.com/chirimen-oh/node-web-i2c.git
synced 2025-01-18 16:08:06 +00:00
fix undefined length error
This commit is contained in:
parent
33e92fec2f
commit
be46b81a56
2 changed files with 2 additions and 2 deletions
2
index.js
2
index.js
|
@ -88,7 +88,7 @@ class I2CPort {
|
|||
/** Different from Web I2C API specification. */
|
||||
writeBytes: async (bytes) => {
|
||||
try {
|
||||
const { bytesWritten, buffer } = await bus.i2cWrite(slaveAddress, length, Buffer.from(bytes));
|
||||
const { bytesWritten, buffer } = await bus.i2cWrite(slaveAddress, bytes.length, Buffer.from(bytes));
|
||||
return new Uint8Array(buffer.slice(0, bytesWritten));
|
||||
}
|
||||
catch (error) {
|
||||
|
|
2
index.ts
2
index.ts
|
@ -110,7 +110,7 @@ export class I2CPort {
|
|||
try {
|
||||
const { bytesWritten, buffer } = await bus.i2cWrite(
|
||||
slaveAddress,
|
||||
length,
|
||||
bytes.length,
|
||||
Buffer.from(bytes)
|
||||
);
|
||||
return new Uint8Array(buffer.slice(0, bytesWritten));
|
||||
|
|
Loading…
Add table
Reference in a new issue