diff --git a/index.js b/index.js index bbbf2cf..f96dd56 100644 --- a/index.js +++ b/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) { diff --git a/index.ts b/index.ts index e9dd73f..7af2cf4 100644 --- a/index.ts +++ b/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));