mirror of
https://github.com/chirimen-oh/node-web-i2c.git
synced 2025-01-31 06:08:00 +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. */
|
/** Different from Web I2C API specification. */
|
||||||
writeBytes: async (bytes) => {
|
writeBytes: async (bytes) => {
|
||||||
try {
|
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));
|
return new Uint8Array(buffer.slice(0, bytesWritten));
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
2
index.ts
2
index.ts
|
@ -110,7 +110,7 @@ export class I2CPort {
|
||||||
try {
|
try {
|
||||||
const { bytesWritten, buffer } = await bus.i2cWrite(
|
const { bytesWritten, buffer } = await bus.i2cWrite(
|
||||||
slaveAddress,
|
slaveAddress,
|
||||||
length,
|
bytes.length,
|
||||||
Buffer.from(bytes)
|
Buffer.from(bytes)
|
||||||
);
|
);
|
||||||
return new Uint8Array(buffer.slice(0, bytesWritten));
|
return new Uint8Array(buffer.slice(0, bytesWritten));
|
||||||
|
|
Loading…
Add table
Reference in a new issue