From 95c5572819d51d48519c48b1d7b2995101f20dfd Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Wed, 16 Oct 2019 00:13:31 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=91=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=83=B3=E3=82=B9=E3=81=AE=E6=94=B9=E5=96=84:=20GPIOPortMapSiz?= =?UTF-8?q?eMax=E3=82=92=E8=A8=AD=E3=81=91=E3=82=8B=20(1023)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 3 ++- index.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ca62207..f8e36c5 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const path = require("path"); */ const PollingInterval = 100; const SysfsGPIOPath = "/sys/class/gpio"; +const GPIOPortMapSizeMax = 1023; const Uint16Max = 65535; function parseUint16(string) { const n = Number.parseInt(string, 10); @@ -150,7 +151,7 @@ class OperationError extends Error { } exports.OperationError = OperationError; async function requestGPIOAccess() { - const ports = new GPIOPortMap([...Array(Uint16Max + 1).keys()].map(portNumber => [ + const ports = new GPIOPortMap([...Array(GPIOPortMapSizeMax + 1).keys()].map(portNumber => [ portNumber, new GPIOPort(portNumber) ])); diff --git a/index.ts b/index.ts index 24bd161..b601579 100644 --- a/index.ts +++ b/index.ts @@ -9,6 +9,8 @@ const PollingInterval = 100; const SysfsGPIOPath = "/sys/class/gpio"; +const GPIOPortMapSizeMax = 1023; + const Uint16Max = 65535; function parseUint16(string: string) { @@ -227,7 +229,7 @@ export class OperationError extends Error {} export async function requestGPIOAccess(): Promise { const ports = new GPIOPortMap( - [...Array(Uint16Max + 1).keys()].map(portNumber => [ + [...Array(GPIOPortMapSizeMax + 1).keys()].map(portNumber => [ portNumber, new GPIOPort(portNumber) ])