From be46b81a5640e0b88339df072a6fd600661f13fc Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Thu, 6 Feb 2020 11:18:33 +0900 Subject: [PATCH] fix undefined length error --- index.js | 2 +- index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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));