Extended port information requests
This commit is contained in:
parent
0fbd27d41f
commit
243d65699f
@ -20,6 +20,8 @@ export class LPF2Hub extends Hub {
|
||||
return [t[0], t[1], t.substring(2, 4), t.substring(4)].join(".");
|
||||
}
|
||||
|
||||
public static sendPortInformationRequests: boolean = false;
|
||||
|
||||
protected _ledPort: number = 0x32;
|
||||
|
||||
private _lastTiltX: number = 0;
|
||||
@ -263,12 +265,15 @@ export class LPF2Hub extends Hub {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private _parsePortMessage (data: Buffer) {
|
||||
|
||||
let port = this._getPortForPortNumber(data[3]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (data[4] === 0x01 && process.env["PORT_DEBUG_INFO"]) {
|
||||
=======
|
||||
if (data[4] === 0x01 && LPF2Hub.sendPortInformationRequests) {
|
||||
>>>>>>> 1fa0f4a... Extended port information requests
|
||||
this._sendPortInformationRequest(data[3]);
|
||||
}
|
||||
|
||||
@ -301,11 +306,20 @@ export class LPF2Hub extends Hub {
|
||||
|
||||
private _sendPortInformationRequest (port: number) {
|
||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x21, port, 0x01]));
|
||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x21, port, 0x02])); // Mode combinations
|
||||
}
|
||||
|
||||
|
||||
private _parsePortInformationResponse (data: Buffer) {
|
||||
const port = data[3];
|
||||
if (data[4] === 2) {
|
||||
const modeCombinationMasks: number[] = [];
|
||||
for (let i = 5; i < data.length; i += 2) {
|
||||
modeCombinationMasks.push(data.readUInt16LE(i));
|
||||
}
|
||||
modeInfoDebug(`Port ${port}, mode combinations [${modeCombinationMasks.map((c) => c.toString(2)).join(", ")}]`);
|
||||
return;
|
||||
}
|
||||
const count = data[6];
|
||||
const input = data.readUInt16LE(7);
|
||||
const output = data.readUInt16LE(9);
|
||||
@ -317,6 +331,7 @@ export class LPF2Hub extends Hub {
|
||||
this._sendModeInformationRequest(port, i, 0x02); // PCT Range
|
||||
this._sendModeInformationRequest(port, i, 0x03); // SI Range
|
||||
this._sendModeInformationRequest(port, i, 0x04); // SI Symbol
|
||||
this._sendModeInformationRequest(port, i, 0x80); // Value Format
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,6 +361,12 @@ export class LPF2Hub extends Hub {
|
||||
case 0x04: // SI Symbol
|
||||
modeInfoDebug(`Port ${port}, mode ${mode}, SI symbol ${data.slice(6, data.length).toString()}`);
|
||||
break;
|
||||
case 0x80: // Value Format
|
||||
const numValues = data[6];
|
||||
const dataType = ["8bit", "16bit", "32bit", "float"][data[7]];
|
||||
const totalFigures = data[8];
|
||||
const decimals = data[9];
|
||||
modeInfoDebug(`Port ${port}, mode ${mode}, Value ${numValues} x ${dataType}, Decimal format ${totalFigures}.${decimals}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user