From 07edc32a8afc1fd6d6d257d9db0afd29188538b7 Mon Sep 17 00:00:00 2001 From: bene Date: Sun, 9 Jan 2022 13:47:15 +0100 Subject: [PATCH 1/2] parse multiple feedback message correctly Using a virtual port you get feedback for the virtual port and its componentes in one message. Change suggested by @aileo https://github.com/nathankellenicki/node-poweredup/issues/118#issuecomment-754911527 --- src/hubs/lpf2hub.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hubs/lpf2hub.ts b/src/hubs/lpf2hub.ts index e7b7d0c..0c45a2c 100644 --- a/src/hubs/lpf2hub.ts +++ b/src/hubs/lpf2hub.ts @@ -348,14 +348,13 @@ export class LPF2Hub extends BaseHub { private _parsePortAction (message: Buffer) { + for (let offset = 3; offset < message.length; offset += 2) { + const device = this._getDeviceByPortId(message[offset]); - const portId = message[3]; - const device = this._getDeviceByPortId(portId); - - if (device) { - device.finish(message[4]); + if (device) { + device.finish(message[offset+1]); + } } - } From 02215ccf40114ad3c4f13730780b0a49a1650b4c Mon Sep 17 00:00:00 2001 From: bene Date: Sun, 9 Jan 2022 13:55:18 +0100 Subject: [PATCH 2/2] handle busy/full feedback message commands with startup and completion information changed from 0x11 (= execute immediately + request feedback) to 0x01 (= buffer if neccessary + request reedback) can return feedback 0x10 = busy/full. This feedback should not resolve the buffered commands. --- src/devices/device.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/devices/device.ts b/src/devices/device.ts index 734aa95..7c23205 100644 --- a/src/devices/device.ts +++ b/src/devices/device.ts @@ -168,6 +168,7 @@ export class Device extends EventEmitter { } public finish (message: number) { + if((message & 0x10) === 0x10) return; // "busy/full" this._busy = (message & 0x01) === 0x01; while(this._finishedCallbacks.length > Number(this._busy)) { const callback = this._finishedCallbacks.shift();