diff --git a/index.js b/index.js index a5a6f63..f1025dc 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ class GPIOPort extends events_1.EventEmitter { try { clearInterval(this._timeout); await fs_1.promises.writeFile(`/sys/class/gpio/export`, parseUint16(this.portNumber.toString()).toString()); - await fs_1.promises.writeFile(`/sys/class/gpio/${parseUint16(this.portNumber.toString())}/direction`, direction); + await fs_1.promises.writeFile(`/sys/class/gpio/gpio${parseUint16(this.portNumber.toString())}/direction`, direction); if (direction === "in") { this._timeout = setInterval(this.read.bind(this), this._pollingInterval); } @@ -104,7 +104,7 @@ class GPIOPort extends events_1.EventEmitter { } async read() { try { - const buffer = await fs_1.promises.readFile(`/sys/class/gpio/${parseUint16(this.portNumber.toString())}/value`); + const buffer = await fs_1.promises.readFile(`/sys/class/gpio/gpio${parseUint16(this.portNumber.toString())}/value`); const value = parseUint16(buffer.toString()); if (this._value !== value) { this._value = value; @@ -118,7 +118,7 @@ class GPIOPort extends events_1.EventEmitter { } async write(value) { try { - await fs_1.promises.writeFile(`/sys/class/gpio/${parseUint16(this.portNumber.toString())}/value`, parseUint16(value.toString()).toString()); + await fs_1.promises.writeFile(`/sys/class/gpio/gpio${parseUint16(this.portNumber.toString())}/value`, parseUint16(value.toString()).toString()); } catch (error) { throw new OperationError(error); diff --git a/index.ts b/index.ts index 313766e..8d0e10d 100644 --- a/index.ts +++ b/index.ts @@ -134,7 +134,9 @@ export class GPIOPort extends EventEmitter { parseUint16(this.portNumber.toString()).toString() ); await fs.writeFile( - `/sys/class/gpio/${parseUint16(this.portNumber.toString())}/direction`, + `/sys/class/gpio/gpio${parseUint16( + this.portNumber.toString() + )}/direction`, direction ); if (direction === "in") { @@ -169,7 +171,7 @@ export class GPIOPort extends EventEmitter { async read() { try { const buffer = await fs.readFile( - `/sys/class/gpio/${parseUint16(this.portNumber.toString())}/value` + `/sys/class/gpio/gpio${parseUint16(this.portNumber.toString())}/value` ); const value = parseUint16(buffer.toString()) as GPIOValue; @@ -188,7 +190,7 @@ export class GPIOPort extends EventEmitter { async write(value: GPIOValue) { try { await fs.writeFile( - `/sys/class/gpio/${parseUint16(this.portNumber.toString())}/value`, + `/sys/class/gpio/gpio${parseUint16(this.portNumber.toString())}/value`, parseUint16(value.toString()).toString() ); } catch (error) {