mirror of
https://github.com/chirimen-oh/node-web-gpio.git
synced 2025-01-18 16:08:00 +00:00
fix path
This commit is contained in:
parent
3c05ccf9ce
commit
d79f14234a
2 changed files with 8 additions and 6 deletions
6
index.js
6
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);
|
||||
|
|
8
index.ts
8
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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue