@kb1rma/libcomm14cux-ts 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +154 -0
- package/dist/bytes.d.ts +9 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +13 -0
- package/dist/bytes.js.map +1 -0
- package/dist/constants.d.ts +174 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +122 -0
- package/dist/constants.js.map +1 -0
- package/dist/decoders/airflow.d.ts +19 -0
- package/dist/decoders/airflow.d.ts.map +1 -0
- package/dist/decoders/airflow.js +36 -0
- package/dist/decoders/airflow.js.map +1 -0
- package/dist/decoders/engineSpeed.d.ts +20 -0
- package/dist/decoders/engineSpeed.d.ts.map +1 -0
- package/dist/decoders/engineSpeed.js +33 -0
- package/dist/decoders/engineSpeed.js.map +1 -0
- package/dist/decoders/faultCodes.d.ts +19 -0
- package/dist/decoders/faultCodes.d.ts.map +1 -0
- package/dist/decoders/faultCodes.js +48 -0
- package/dist/decoders/faultCodes.js.map +1 -0
- package/dist/decoders/flags.d.ts +45 -0
- package/dist/decoders/flags.d.ts.map +1 -0
- package/dist/decoders/flags.js +54 -0
- package/dist/decoders/flags.js.map +1 -0
- package/dist/decoders/fuelMap.d.ts +89 -0
- package/dist/decoders/fuelMap.d.ts.map +1 -0
- package/dist/decoders/fuelMap.js +109 -0
- package/dist/decoders/fuelMap.js.map +1 -0
- package/dist/decoders/gear.d.ts +10 -0
- package/dist/decoders/gear.d.ts.map +1 -0
- package/dist/decoders/gear.js +23 -0
- package/dist/decoders/gear.js.map +1 -0
- package/dist/decoders/idleBypass.d.ts +8 -0
- package/dist/decoders/idleBypass.d.ts.map +1 -0
- package/dist/decoders/idleBypass.js +15 -0
- package/dist/decoders/idleBypass.js.map +1 -0
- package/dist/decoders/lambdaTrim.d.ts +15 -0
- package/dist/decoders/lambdaTrim.d.ts.map +1 -0
- package/dist/decoders/lambdaTrim.js +23 -0
- package/dist/decoders/lambdaTrim.js.map +1 -0
- package/dist/decoders/mainVoltage.d.ts +14 -0
- package/dist/decoders/mainVoltage.d.ts.map +1 -0
- package/dist/decoders/mainVoltage.js +26 -0
- package/dist/decoders/mainVoltage.js.map +1 -0
- package/dist/decoders/roadSpeed.d.ts +8 -0
- package/dist/decoders/roadSpeed.d.ts.map +1 -0
- package/dist/decoders/roadSpeed.js +14 -0
- package/dist/decoders/roadSpeed.js.map +1 -0
- package/dist/decoders/romRevision.d.ts +18 -0
- package/dist/decoders/romRevision.d.ts.map +1 -0
- package/dist/decoders/romRevision.js +26 -0
- package/dist/decoders/romRevision.js.map +1 -0
- package/dist/decoders/temperature.d.ts +12 -0
- package/dist/decoders/temperature.d.ts.map +1 -0
- package/dist/decoders/temperature.js +39 -0
- package/dist/decoders/temperature.js.map +1 -0
- package/dist/decoders/throttle.d.ts +18 -0
- package/dist/decoders/throttle.d.ts.map +1 -0
- package/dist/decoders/throttle.js +33 -0
- package/dist/decoders/throttle.js.map +1 -0
- package/dist/decoders/tuneRevision.d.ts +25 -0
- package/dist/decoders/tuneRevision.d.ts.map +1 -0
- package/dist/decoders/tuneRevision.js +22 -0
- package/dist/decoders/tuneRevision.js.map +1 -0
- package/dist/ecu.d.ts +473 -0
- package/dist/ecu.d.ts.map +1 -0
- package/dist/ecu.js +700 -0
- package/dist/ecu.js.map +1 -0
- package/dist/errors.d.ts +31 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +33 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol/protocol.d.ts +57 -0
- package/dist/protocol/protocol.d.ts.map +1 -0
- package/dist/protocol/protocol.js +137 -0
- package/dist/protocol/protocol.js.map +1 -0
- package/dist/protocol/readCount.d.ts +21 -0
- package/dist/protocol/readCount.d.ts.map +1 -0
- package/dist/protocol/readCount.js +30 -0
- package/dist/protocol/readCount.js.map +1 -0
- package/dist/queue.d.ts +15 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +21 -0
- package/dist/queue.js.map +1 -0
- package/dist/transport/simulated.d.ts +65 -0
- package/dist/transport/simulated.d.ts.map +1 -0
- package/dist/transport/simulated.js +190 -0
- package/dist/transport/simulated.js.map +1 -0
- package/dist/transport/types.d.ts +9 -0
- package/dist/transport/types.d.ts.map +1 -0
- package/dist/transport/types.js +4 -0
- package/dist/transport/types.js.map +1 -0
- package/dist/transport/webSerial.d.ts +49 -0
- package/dist/transport/webSerial.d.ts.map +1 -0
- package/dist/transport/webSerial.js +129 -0
- package/dist/transport/webSerial.js.map +1 -0
- package/dist/version.d.ts +18 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +58 -0
- package/src/bytes.ts +13 -0
- package/src/constants.ts +175 -0
- package/src/decoders/airflow.ts +41 -0
- package/src/decoders/engineSpeed.ts +36 -0
- package/src/decoders/faultCodes.ts +61 -0
- package/src/decoders/flags.ts +64 -0
- package/src/decoders/fuelMap.ts +167 -0
- package/src/decoders/gear.ts +26 -0
- package/src/decoders/idleBypass.ts +16 -0
- package/src/decoders/lambdaTrim.ts +24 -0
- package/src/decoders/mainVoltage.ts +37 -0
- package/src/decoders/roadSpeed.ts +14 -0
- package/src/decoders/romRevision.ts +30 -0
- package/src/decoders/temperature.ts +42 -0
- package/src/decoders/throttle.ts +37 -0
- package/src/decoders/tuneRevision.ts +42 -0
- package/src/ecu.ts +948 -0
- package/src/errors.ts +38 -0
- package/src/index.ts +16 -0
- package/src/protocol/protocol.ts +167 -0
- package/src/protocol/readCount.ts +45 -0
- package/src/queue.ts +24 -0
- package/src/test-support/ecu.ts +126 -0
- package/src/transport/simulated.ts +220 -0
- package/src/transport/types.ts +11 -0
- package/src/transport/webSerial.ts +163 -0
- package/src/version.ts +21 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataOffsetRev } from '../constants.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tells whether the ROM uses the Rev C data layout. The first row of a fuel
|
|
4
|
+
* map never reaches 0x30, so a larger value at the old Map 1 location means it
|
|
5
|
+
* is not map data.
|
|
6
|
+
*
|
|
7
|
+
* @param oldMap1FirstRow - The 16 bytes read from 0xC23F.
|
|
8
|
+
* @returns `true` for the Rev C layout.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isRevC(oldMap1FirstRow: Uint8Array): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Distinguishes Rev A from Rev B by the first main voltage factor byte.
|
|
13
|
+
*
|
|
14
|
+
* @param voltageFactorA - The byte read from 0xC79B.
|
|
15
|
+
* @returns Rev A if it is 0xFF, otherwise Rev B.
|
|
16
|
+
*/
|
|
17
|
+
export declare function classifyOldRevision(voltageFactorA: number): typeof DataOffsetRev.RevA | typeof DataOffsetRev.RevB;
|
|
18
|
+
//# sourceMappingURL=romRevision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"romRevision.d.ts","sourceRoot":"","sources":["../../src/decoders/romRevision.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,eAAe,EAAE,UAAU,GAAG,OAAO,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,GACrB,OAAO,aAAa,CAAC,IAAI,GAAG,OAAO,aAAa,CAAC,IAAI,CAEvD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
// Derived from libcomm14cux (https://github.com/colinbourassa/libcomm14cux)
|
|
3
|
+
// Copyright (C) Colin Bourassa. Licensed under the GNU GPL v3.
|
|
4
|
+
// Ported to TypeScript and modified for comm14cux-ts, 2026.
|
|
5
|
+
import { DataOffsetRev } from '../constants.js';
|
|
6
|
+
/**
|
|
7
|
+
* Tells whether the ROM uses the Rev C data layout. The first row of a fuel
|
|
8
|
+
* map never reaches 0x30, so a larger value at the old Map 1 location means it
|
|
9
|
+
* is not map data.
|
|
10
|
+
*
|
|
11
|
+
* @param oldMap1FirstRow - The 16 bytes read from 0xC23F.
|
|
12
|
+
* @returns `true` for the Rev C layout.
|
|
13
|
+
*/
|
|
14
|
+
export function isRevC(oldMap1FirstRow) {
|
|
15
|
+
return oldMap1FirstRow.some((value) => value > 0x30);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Distinguishes Rev A from Rev B by the first main voltage factor byte.
|
|
19
|
+
*
|
|
20
|
+
* @param voltageFactorA - The byte read from 0xC79B.
|
|
21
|
+
* @returns Rev A if it is 0xFF, otherwise Rev B.
|
|
22
|
+
*/
|
|
23
|
+
export function classifyOldRevision(voltageFactorA) {
|
|
24
|
+
return voltageFactorA === 0xff ? DataOffsetRev.RevA : DataOffsetRev.RevB;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=romRevision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"romRevision.js","sourceRoot":"","sources":["../../src/decoders/romRevision.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,4EAA4E;AAC5E,+DAA+D;AAC/D,4DAA4D;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,eAA2B;IAChD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,cAAsB;IAEtB,OAAO,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;AAC3E,CAAC","sourcesContent":["// SPDX-License-Identifier: GPL-3.0-only\n// Derived from libcomm14cux (https://github.com/colinbourassa/libcomm14cux)\n// Copyright (C) Colin Bourassa. Licensed under the GNU GPL v3.\n// Ported to TypeScript and modified for comm14cux-ts, 2026.\n\nimport { DataOffsetRev } from '../constants.js';\n\n/**\n * Tells whether the ROM uses the Rev C data layout. The first row of a fuel\n * map never reaches 0x30, so a larger value at the old Map 1 location means it\n * is not map data.\n *\n * @param oldMap1FirstRow - The 16 bytes read from 0xC23F.\n * @returns `true` for the Rev C layout.\n */\nexport function isRevC(oldMap1FirstRow: Uint8Array): boolean {\n return oldMap1FirstRow.some((value) => value > 0x30);\n}\n\n/**\n * Distinguishes Rev A from Rev B by the first main voltage factor byte.\n *\n * @param voltageFactorA - The byte read from 0xC79B.\n * @returns Rev A if it is 0xFF, otherwise Rev B.\n */\nexport function classifyOldRevision(\n voltageFactorA: number,\n): typeof DataOffsetRev.RevA | typeof DataOffsetRev.RevB {\n return voltageFactorA === 0xff ? DataOffsetRev.RevA : DataOffsetRev.RevB;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** ADC count to degrees Fahrenheit (`temperature_adc_to_degrees_f`). */
|
|
2
|
+
export declare const TEMPERATURE_ADC_TO_DEGREES_F: readonly number[];
|
|
3
|
+
/**
|
|
4
|
+
* Converts a coolant or fuel temperature sensor ADC count to degrees
|
|
5
|
+
* Fahrenheit.
|
|
6
|
+
*
|
|
7
|
+
* @param adcCount - The byte read from the sensor location, 0 to 255.
|
|
8
|
+
* @returns Temperature in degrees Fahrenheit.
|
|
9
|
+
* @throws {@link InvalidReadingError} if `adcCount` is not 0 to 255.
|
|
10
|
+
*/
|
|
11
|
+
export declare function decodeTemperatureF(adcCount: number): number;
|
|
12
|
+
//# sourceMappingURL=temperature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../src/decoders/temperature.ts"],"names":[],"mappings":"AAMA,wEAAwE;AACxE,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAgBzD,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ3D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
// Derived from libcomm14cux (https://github.com/colinbourassa/libcomm14cux)
|
|
3
|
+
// Copyright (C) Colin Bourassa. Licensed under the GNU GPL v3.
|
|
4
|
+
// Ported to TypeScript and modified for comm14cux-ts, 2026.
|
|
5
|
+
import { InvalidReadingError } from '../errors.js';
|
|
6
|
+
/** ADC count to degrees Fahrenheit (`temperature_adc_to_degrees_f`). */
|
|
7
|
+
export const TEMPERATURE_ADC_TO_DEGREES_F = [
|
|
8
|
+
266, 264, 260, 258, 255, 253, 249, 248, 244, 242, 239, 237, 233, 231, 228,
|
|
9
|
+
226, 222, 221, 219, 217, 215, 213, 212, 210, 208, 206, 204, 203, 201, 199,
|
|
10
|
+
197, 195, 194, 192, 190, 188, 186, 185, 183, 181, 179, 177, 176, 174, 172,
|
|
11
|
+
170, 168, 167, 165, 163, 161, 159, 158, 158, 156, 154, 152, 150, 149, 147,
|
|
12
|
+
145, 145, 143, 141, 140, 138, 138, 136, 136, 134, 132, 132, 131, 131, 129,
|
|
13
|
+
129, 127, 125, 125, 123, 123, 122, 122, 120, 120, 118, 118, 116, 116, 114,
|
|
14
|
+
114, 113, 113, 111, 111, 109, 109, 107, 107, 105, 105, 104, 104, 102, 102,
|
|
15
|
+
100, 100, 98, 98, 96, 96, 95, 95, 95, 93, 93, 91, 91, 89, 89, 87, 87, 86, 86,
|
|
16
|
+
84, 84, 82, 82, 82, 82, 80, 80, 78, 78, 78, 77, 77, 75, 75, 73, 73, 73, 71,
|
|
17
|
+
71, 71, 69, 69, 68, 68, 66, 66, 64, 64, 62, 62, 60, 60, 59, 59, 57, 57, 57,
|
|
18
|
+
55, 55, 53, 53, 51, 51, 50, 50, 48, 48, 46, 46, 44, 44, 44, 44, 42, 42, 42,
|
|
19
|
+
41, 41, 41, 39, 39, 37, 37, 37, 35, 35, 35, 35, 33, 33, 32, 32, 31, 31, 29,
|
|
20
|
+
29, 27, 27, 25, 25, 23, 23, 22, 22, 22, 20, 20, 18, 18, 18, 16, 16, 14, 14,
|
|
21
|
+
13, 13, 13, 11, 11, 11, 9, 9, 7, 7, 5, 5, 4, 4, 2, 2, 0, 0, -2, -2, -4, -4,
|
|
22
|
+
-4, -5, -5, -7, -7, -7, -9, -9, -9, -11, -11, -11, -13, -13, -13,
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Converts a coolant or fuel temperature sensor ADC count to degrees
|
|
26
|
+
* Fahrenheit.
|
|
27
|
+
*
|
|
28
|
+
* @param adcCount - The byte read from the sensor location, 0 to 255.
|
|
29
|
+
* @returns Temperature in degrees Fahrenheit.
|
|
30
|
+
* @throws {@link InvalidReadingError} if `adcCount` is not 0 to 255.
|
|
31
|
+
*/
|
|
32
|
+
export function decodeTemperatureF(adcCount) {
|
|
33
|
+
const degrees = TEMPERATURE_ADC_TO_DEGREES_F[adcCount];
|
|
34
|
+
if (degrees === undefined) {
|
|
35
|
+
throw new InvalidReadingError(`Invalid temperature ADC count: ${adcCount}`);
|
|
36
|
+
}
|
|
37
|
+
return degrees;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=temperature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temperature.js","sourceRoot":"","sources":["../../src/decoders/temperature.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,4EAA4E;AAC5E,+DAA+D;AAC/D,4DAA4D;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,wEAAwE;AACxE,MAAM,CAAC,MAAM,4BAA4B,GAAsB;IAC7D,GAAG,EAAE,GAAG,EAAE,GAAG,E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,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAC1E,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE;CACjE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,OAAO,GAAG,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAEvD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,mBAAmB,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["// SPDX-License-Identifier: GPL-3.0-only\n// Derived from libcomm14cux (https://github.com/colinbourassa/libcomm14cux)\n// Copyright (C) Colin Bourassa. Licensed under the GNU GPL v3.\n// Ported to TypeScript and modified for comm14cux-ts, 2026.\nimport { InvalidReadingError } from '../errors.js';\n\n/** ADC count to degrees Fahrenheit (`temperature_adc_to_degrees_f`). */\nexport const TEMPERATURE_ADC_TO_DEGREES_F: readonly number[] = [\n 266, 264, 260, 258, 255, 253, 249, 248, 244, 242, 239, 237, 233, 231, 228,\n 226, 222, 221, 219, 217, 215, 213, 212, 210, 208, 206, 204, 203, 201, 199,\n 197, 195, 194, 192, 190, 188, 186, 185, 183, 181, 179, 177, 176, 174, 172,\n 170, 168, 167, 165, 163, 161, 159, 158, 158, 156, 154, 152, 150, 149, 147,\n 145, 145, 143, 141, 140, 138, 138, 136, 136, 134, 132, 132, 131, 131, 129,\n 129, 127, 125, 125, 123, 123, 122, 122, 120, 120, 118, 118, 116, 116, 114,\n 114, 113, 113, 111, 111, 109, 109, 107, 107, 105, 105, 104, 104, 102, 102,\n 100, 100, 98, 98, 96, 96, 95, 95, 95, 93, 93, 91, 91, 89, 89, 87, 87, 86, 86,\n 84, 84, 82, 82, 82, 82, 80, 80, 78, 78, 78, 77, 77, 75, 75, 73, 73, 73, 71,\n 71, 71, 69, 69, 68, 68, 66, 66, 64, 64, 62, 62, 60, 60, 59, 59, 57, 57, 57,\n 55, 55, 53, 53, 51, 51, 50, 50, 48, 48, 46, 46, 44, 44, 44, 44, 42, 42, 42,\n 41, 41, 41, 39, 39, 37, 37, 37, 35, 35, 35, 35, 33, 33, 32, 32, 31, 31, 29,\n 29, 27, 27, 25, 25, 23, 23, 22, 22, 22, 20, 20, 18, 18, 18, 16, 16, 14, 14,\n 13, 13, 13, 11, 11, 11, 9, 9, 7, 7, 5, 5, 4, 4, 2, 2, 0, 0, -2, -2, -4, -4,\n -4, -5, -5, -7, -7, -7, -9, -9, -9, -11, -11, -11, -13, -13, -13,\n];\n\n/**\n * Converts a coolant or fuel temperature sensor ADC count to degrees\n * Fahrenheit.\n *\n * @param adcCount - The byte read from the sensor location, 0 to 255.\n * @returns Temperature in degrees Fahrenheit.\n * @throws {@link InvalidReadingError} if `adcCount` is not 0 to 255.\n */\nexport function decodeTemperatureF(adcCount: number): number {\n const degrees = TEMPERATURE_ADC_TO_DEGREES_F[adcCount];\n\n if (degrees === undefined) {\n throw new InvalidReadingError(`Invalid temperature ADC count: ${adcCount}`);\n }\n\n return degrees;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rejects a raw throttle reading above the 10-bit maximum.
|
|
3
|
+
*
|
|
4
|
+
* @param raw - The raw reading.
|
|
5
|
+
* @throws {@link InvalidReadingError} if `raw` is above 1023.
|
|
6
|
+
*/
|
|
7
|
+
export declare function assertThrottleReading(raw: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* Decodes the throttle position.
|
|
10
|
+
*
|
|
11
|
+
* @param raw - The 10-bit reading, 0 to 1023.
|
|
12
|
+
* @param minimum - 0 for an absolute reading, or the ECU's stored minimum for a
|
|
13
|
+
* corrected reading.
|
|
14
|
+
* @returns Position as a fraction from 0 (closed) to 1 (wide open).
|
|
15
|
+
* @throws {@link InvalidReadingError} if `raw` is above 1023.
|
|
16
|
+
*/
|
|
17
|
+
export declare function decodeThrottlePosition(raw: number, minimum: number): number;
|
|
18
|
+
//# sourceMappingURL=throttle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/decoders/throttle.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAIvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM3E"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
// Derived from libcomm14cux (https://github.com/colinbourassa/libcomm14cux)
|
|
3
|
+
// Copyright (C) Colin Bourassa. Licensed under the GNU GPL v3.
|
|
4
|
+
// Ported to TypeScript and modified for comm14cux-ts, 2026.
|
|
5
|
+
import { InvalidReadingError } from '../errors.js';
|
|
6
|
+
const MAX_READING = 1023;
|
|
7
|
+
/**
|
|
8
|
+
* Rejects a raw throttle reading above the 10-bit maximum.
|
|
9
|
+
*
|
|
10
|
+
* @param raw - The raw reading.
|
|
11
|
+
* @throws {@link InvalidReadingError} if `raw` is above 1023.
|
|
12
|
+
*/
|
|
13
|
+
export function assertThrottleReading(raw) {
|
|
14
|
+
if (raw > MAX_READING) {
|
|
15
|
+
throw new InvalidReadingError(`Throttle reading out of range: ${raw}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Decodes the throttle position.
|
|
20
|
+
*
|
|
21
|
+
* @param raw - The 10-bit reading, 0 to 1023.
|
|
22
|
+
* @param minimum - 0 for an absolute reading, or the ECU's stored minimum for a
|
|
23
|
+
* corrected reading.
|
|
24
|
+
* @returns Position as a fraction from 0 (closed) to 1 (wide open).
|
|
25
|
+
* @throws {@link InvalidReadingError} if `raw` is above 1023.
|
|
26
|
+
*/
|
|
27
|
+
export function decodeThrottlePosition(raw, minimum) {
|
|
28
|
+
assertThrottleReading(raw);
|
|
29
|
+
// A glitch can put the reading below the stored minimum; report zero
|
|
30
|
+
// (this also avoids dividing by zero when the minimum is 1023).
|
|
31
|
+
return raw > minimum ? (raw - minimum) / (MAX_READING - minimum) : 0;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/decoders/throttle.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,4EAA4E;AAC5E,+DAA+D;AAC/D,4DAA4D;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,IAAI,GAAG,GAAG,WAAW,EAAE,CAAC;QACtB,MAAM,IAAI,mBAAmB,CAAC,kCAAkC,GAAG,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW,EAAE,OAAe;IACjE,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAE3B,qEAAqE;IACrE,gEAAgE;IAChE,OAAO,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["// SPDX-License-Identifier: GPL-3.0-only\n// Derived from libcomm14cux (https://github.com/colinbourassa/libcomm14cux)\n// Copyright (C) Colin Bourassa. Licensed under the GNU GPL v3.\n// Ported to TypeScript and modified for comm14cux-ts, 2026.\n\nimport { InvalidReadingError } from '../errors.js';\n\nconst MAX_READING = 1023;\n\n/**\n * Rejects a raw throttle reading above the 10-bit maximum.\n *\n * @param raw - The raw reading.\n * @throws {@link InvalidReadingError} if `raw` is above 1023.\n */\nexport function assertThrottleReading(raw: number): void {\n if (raw > MAX_READING) {\n throw new InvalidReadingError(`Throttle reading out of range: ${raw}`);\n }\n}\n\n/**\n * Decodes the throttle position.\n *\n * @param raw - The 10-bit reading, 0 to 1023.\n * @param minimum - 0 for an absolute reading, or the ECU's stored minimum for a\n * corrected reading.\n * @returns Position as a fraction from 0 (closed) to 1 (wide open).\n * @throws {@link InvalidReadingError} if `raw` is above 1023.\n */\nexport function decodeThrottlePosition(raw: number, minimum: number): number {\n assertThrottleReading(raw);\n\n // A glitch can put the reading below the stored minimum; report zero\n // (this also avoids dividing by zero when the minimum is 1023).\n return raw > minimum ? (raw - minimum) / (MAX_READING - minimum) : 0;\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tune identification stored in the ROM.
|
|
3
|
+
*/
|
|
4
|
+
export interface TuneRevision {
|
|
5
|
+
/**
|
|
6
|
+
* Decimal tune number decoded from two BCD bytes.
|
|
7
|
+
*/
|
|
8
|
+
tuneNumber: number;
|
|
9
|
+
/**
|
|
10
|
+
* Checksum fixer byte.
|
|
11
|
+
*/
|
|
12
|
+
checksumFixer: number;
|
|
13
|
+
/**
|
|
14
|
+
* Ident word, which differentiates builds of the same tune number.
|
|
15
|
+
*/
|
|
16
|
+
tuneIdent: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Decodes the five tune identification bytes.
|
|
20
|
+
*
|
|
21
|
+
* @param bytes - The bytes read from 0xFFE9.
|
|
22
|
+
* @returns The tune number, checksum fixer and ident word.
|
|
23
|
+
*/
|
|
24
|
+
export declare function decodeTuneRevision(bytes: Uint8Array): TuneRevision;
|
|
25
|
+
//# sourceMappingURL=tuneRevision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuneRevision.d.ts","sourceRoot":"","sources":["../../src/decoders/tuneRevision.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,CAQlE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
// Derived from libcomm14cux (https://github.com/colinbourassa/libcomm14cux)
|
|
3
|
+
// Copyright (C) Colin Bourassa. Licensed under the GNU GPL v3.
|
|
4
|
+
// Ported to TypeScript and modified for comm14cux-ts, 2026.
|
|
5
|
+
function bcd(byte) {
|
|
6
|
+
return (byte >> 4) * 10 + (byte & 0x0f);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Decodes the five tune identification bytes.
|
|
10
|
+
*
|
|
11
|
+
* @param bytes - The bytes read from 0xFFE9.
|
|
12
|
+
* @returns The tune number, checksum fixer and ident word.
|
|
13
|
+
*/
|
|
14
|
+
export function decodeTuneRevision(bytes) {
|
|
15
|
+
const [b0 = 0, b1 = 0, fixer = 0, identHigh = 0, identLow = 0] = bytes;
|
|
16
|
+
return {
|
|
17
|
+
tuneNumber: bcd(b0) * 100 + bcd(b1),
|
|
18
|
+
checksumFixer: fixer,
|
|
19
|
+
tuneIdent: (identHigh << 8) | identLow,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=tuneRevision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuneRevision.js","sourceRoot":"","sources":["../../src/decoders/tuneRevision.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,4EAA4E;AAC5E,+DAA+D;AAC/D,4DAA4D;AAoB5D,SAAS,GAAG,CAAC,IAAY;IACvB,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAClD,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;IAEvE,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC;QACnC,aAAa,EAAE,KAAK;QACpB,SAAS,EAAE,CAAC,SAAS,IAAI,CAAC,CAAC,GAAG,QAAQ;KACvC,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: GPL-3.0-only\n// Derived from libcomm14cux (https://github.com/colinbourassa/libcomm14cux)\n// Copyright (C) Colin Bourassa. Licensed under the GNU GPL v3.\n// Ported to TypeScript and modified for comm14cux-ts, 2026.\n\n/**\n * Tune identification stored in the ROM.\n */\nexport interface TuneRevision {\n /**\n * Decimal tune number decoded from two BCD bytes.\n */\n tuneNumber: number;\n /**\n * Checksum fixer byte.\n */\n checksumFixer: number;\n /**\n * Ident word, which differentiates builds of the same tune number.\n */\n tuneIdent: number;\n}\n\nfunction bcd(byte: number): number {\n return (byte >> 4) * 10 + (byte & 0x0f);\n}\n\n/**\n * Decodes the five tune identification bytes.\n *\n * @param bytes - The bytes read from 0xFFE9.\n * @returns The tune number, checksum fixer and ident word.\n */\nexport function decodeTuneRevision(bytes: Uint8Array): TuneRevision {\n const [b0 = 0, b1 = 0, fixer = 0, identHigh = 0, identLow = 0] = bytes;\n\n return {\n tuneNumber: bcd(b0) * 100 + bcd(b1),\n checksumFixer: fixer,\n tuneIdent: (identHigh << 8) | identLow,\n };\n}\n"]}
|