fix undefined length error

This commit is contained in:
Nebel 2020-02-06 11:18:33 +09:00
parent 33e92fec2f
commit be46b81a56
2 changed files with 2 additions and 2 deletions

View file

@ -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) {

View file

@ -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));