{"_id":"@emdzej/ncsx-cabd","_rev":"6-9048d3ed73c38e0368b56bff7b4dc87b","name":"@emdzej/ncsx-cabd","dist-tags":{"latest":"0.9.0"},"versions":{"0.4.0":{"name":"@emdzej/ncsx-cabd","version":"0.4.0","_id":"@emdzej/ncsx-cabd@0.4.0","maintainers":[{"name":"emdzej","email":"michal@jaskolski.pro"}],"homepage":"https://github.com/emdzej/ncsx#readme","bugs":{"url":"https://github.com/emdzej/ncsx/issues"},"dist":{"shasum":"73f6ff073d2bf8df5d584c3b1fa2b47d05ee2ad6","tarball":"https://registry.npmjs.org/@emdzej/ncsx-cabd/-/ncsx-cabd-0.4.0.tgz","fileCount":27,"integrity":"sha512-H4+y698HJFcN9VwSiRhaodsxKSO/KyRfqp41aajU7snase701AUZU9lNUtk63wEX2+pmpgozvsE7THzN89Jd4Q==","signatures":[{"sig":"MEYCIQDpsgZxUzD8igDZOrSErg/5ExRpozUj2rVzB9IbUBvOIQIhALSKSO/SCO23wkZgQlIAWvZ4d52v0wtKqnuTzD92fPXe","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38446},"main":"dist/index.js","type":"module","_from":"file:emdzej-ncsx-cabd-0.4.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run --passWithNoTests","build":"tsc -p tsconfig.json","clean":"rm -rf dist .turbo *.tsbuildinfo","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"emdzej","email":"michal@jaskolski.pro"},"_resolved":"/private/var/folders/7h/x_w_580x4s9dq3sq11tpvzkwy3nbj8/T/d385eb82f5fbd40fa950f319754c4d91/emdzej-ncsx-cabd-0.4.0.tgz","_integrity":"sha512-H4+y698HJFcN9VwSiRhaodsxKSO/KyRfqp41aajU7snase701AUZU9lNUtk63wEX2+pmpgozvsE7THzN89Jd4Q==","repository":{"url":"git+https://github.com/emdzej/ncsx.git","type":"git","directory":"packages/cabd"},"_npmVersion":"11.14.1","description":"CABD coding-rule decoder and encoder (netto bytes ↔ FSW/PSW values). Spec: ../../docs/coding-flow.md, ../../docs/daten-format.md §1.7-1.8","directories":{},"_nodeVersion":"22.22.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","@types/node":"^22.13.1"},"_npmOperationalInternal":{"tmp":"tmp/ncsx-cabd_0.4.0_1779705611225_0.657510530901062","host":"s3://npm-registry-packages-npm-production"}},"0.5.1":{"name":"@emdzej/ncsx-cabd","version":"0.5.1","_id":"@emdzej/ncsx-cabd@0.5.1","maintainers":[{"name":"emdzej","email":"michal@jaskolski.pro"}],"homepage":"https://github.com/emdzej/ncsx#readme","bugs":{"url":"https://github.com/emdzej/ncsx/issues"},"dist":{"shasum":"5a17451516b833e53c33109033456e1b9aa20267","tarball":"https://registry.npmjs.org/@emdzej/ncsx-cabd/-/ncsx-cabd-0.5.1.tgz","fileCount":27,"integrity":"sha512-gEPv2dgTS6NePuTuGmUVVfsUxW6LncHWz240tmFjuu+ghXLaPRAGO7Oabw7lnsSUrgD0rsndqKYTNdc2625Mgw==","signatures":[{"sig":"MEUCIDJL6E5zmGPzSs+EmgiFfNioRLYVOw1vInS0D5DcLcmnAiEA0AEa+gnozmOtIAwq4kC1mCY9kdvEmXQoTcQimLI/BEY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38446},"main":"dist/index.js","type":"module","_from":"file:emdzej-ncsx-cabd-0.5.1.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run --passWithNoTests","build":"tsc -p tsconfig.json","clean":"rm -rf dist .turbo *.tsbuildinfo","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"emdzej","email":"michal@jaskolski.pro"},"_resolved":"/private/var/folders/7h/x_w_580x4s9dq3sq11tpvzkwy3nbj8/T/a54f2480f77c1533975557a4f781ee5b/emdzej-ncsx-cabd-0.5.1.tgz","_integrity":"sha512-gEPv2dgTS6NePuTuGmUVVfsUxW6LncHWz240tmFjuu+ghXLaPRAGO7Oabw7lnsSUrgD0rsndqKYTNdc2625Mgw==","repository":{"url":"git+https://github.com/emdzej/ncsx.git","type":"git","directory":"packages/cabd"},"_npmVersion":"11.14.1","description":"CABD coding-rule decoder and encoder (netto bytes ↔ FSW/PSW values). Spec: ../../docs/coding-flow.md, ../../docs/daten-format.md §1.7-1.8","directories":{},"_nodeVersion":"22.22.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","@types/node":"^22.13.1"},"_npmOperationalInternal":{"tmp":"tmp/ncsx-cabd_0.5.1_1779876424642_0.6551623645876783","host":"s3://npm-registry-packages-npm-production"}},"0.6.0":{"name":"@emdzej/ncsx-cabd","version":"0.6.0","_id":"@emdzej/ncsx-cabd@0.6.0","maintainers":[{"name":"emdzej","email":"michal@jaskolski.pro"}],"homepage":"https://github.com/emdzej/ncsx#readme","bugs":{"url":"https://github.com/emdzej/ncsx/issues"},"dist":{"shasum":"4e13d77a5bdd23404326b3dfc1f2574d7d3afbd2","tarball":"https://registry.npmjs.org/@emdzej/ncsx-cabd/-/ncsx-cabd-0.6.0.tgz","fileCount":27,"integrity":"sha512-fcGRuCFnjI2U3Yq/6jheGTG3TrhUpk+wfAJahXz6vEqDjEPplSed3zS6cJ3Ur5YTaaBKsoGs7W789+Ry+3TCRg==","signatures":[{"sig":"MEUCIQDGaBd5pNd8xXKT7SpT/tVSR8dJqXOjfls+RacClJte/wIgYuzGpxwgJ/VywNwrs4dBsWViJHlZoddQ8551vMzEFvM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38446},"main":"dist/index.js","type":"module","_from":"file:emdzej-ncsx-cabd-0.6.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run --passWithNoTests","build":"tsc -p tsconfig.json","clean":"rm -rf dist .turbo *.tsbuildinfo","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"emdzej","email":"michal@jaskolski.pro"},"_resolved":"/private/var/folders/7h/x_w_580x4s9dq3sq11tpvzkwy3nbj8/T/82daece3a53c4242f3f8fe5f5de32123/emdzej-ncsx-cabd-0.6.0.tgz","_integrity":"sha512-fcGRuCFnjI2U3Yq/6jheGTG3TrhUpk+wfAJahXz6vEqDjEPplSed3zS6cJ3Ur5YTaaBKsoGs7W789+Ry+3TCRg==","repository":{"url":"git+https://github.com/emdzej/ncsx.git","type":"git","directory":"packages/cabd"},"_npmVersion":"11.14.1","description":"CABD coding-rule decoder and encoder (netto bytes ↔ FSW/PSW values). Spec: ../../docs/coding-flow.md, ../../docs/daten-format.md §1.7-1.8","directories":{},"_nodeVersion":"22.22.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","@types/node":"^22.13.1"},"_npmOperationalInternal":{"tmp":"tmp/ncsx-cabd_0.6.0_1779981228333_0.04873419508527577","host":"s3://npm-registry-packages-npm-production"}},"0.7.0":{"name":"@emdzej/ncsx-cabd","version":"0.7.0","_id":"@emdzej/ncsx-cabd@0.7.0","maintainers":[{"name":"emdzej","email":"michal@jaskolski.pro"}],"homepage":"https://github.com/emdzej/ncsx#readme","bugs":{"url":"https://github.com/emdzej/ncsx/issues"},"dist":{"shasum":"f1b4fe78d8e311783232bbd69f08a27b57533f04","tarball":"https://registry.npmjs.org/@emdzej/ncsx-cabd/-/ncsx-cabd-0.7.0.tgz","fileCount":27,"integrity":"sha512-RweXnW1URTnJzpI4oAAjZXeuEumkNpdG0YD2oRD4Zfzdvd7rW32V0cCU7gdCGjM1Xr+QJFDsERrzxYYEw18w9g==","signatures":[{"sig":"MEYCIQCcYdHlXkun1r4kf9zC+vv13L7X5yEVLYMwdPw/B1mLeAIhAKWUUpHfB70IxeeN9Wi+TdSyGP3I3ALqE3/nDFaj1wfM","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38446},"main":"dist/index.js","type":"module","_from":"file:emdzej-ncsx-cabd-0.7.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run --passWithNoTests","build":"tsc -p tsconfig.json","clean":"rm -rf dist .turbo *.tsbuildinfo","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"emdzej","email":"michal@jaskolski.pro"},"_resolved":"/private/var/folders/7h/x_w_580x4s9dq3sq11tpvzkwy3nbj8/T/6c7d4b0af2f308a4687953cb41c7dc83/emdzej-ncsx-cabd-0.7.0.tgz","_integrity":"sha512-RweXnW1URTnJzpI4oAAjZXeuEumkNpdG0YD2oRD4Zfzdvd7rW32V0cCU7gdCGjM1Xr+QJFDsERrzxYYEw18w9g==","repository":{"url":"git+https://github.com/emdzej/ncsx.git","type":"git","directory":"packages/cabd"},"_npmVersion":"11.14.1","description":"CABD coding-rule decoder and encoder (netto bytes ↔ FSW/PSW values). Spec: ../../docs/coding-flow.md, ../../docs/daten-format.md §1.7-1.8","directories":{},"_nodeVersion":"22.22.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","@types/node":"^22.13.1"},"_npmOperationalInternal":{"tmp":"tmp/ncsx-cabd_0.7.0_1780062994506_0.05557752645451397","host":"s3://npm-registry-packages-npm-production"}},"0.8.0":{"name":"@emdzej/ncsx-cabd","version":"0.8.0","_id":"@emdzej/ncsx-cabd@0.8.0","maintainers":[{"name":"emdzej","email":"michal@jaskolski.pro"}],"homepage":"https://github.com/emdzej/ncsx#readme","bugs":{"url":"https://github.com/emdzej/ncsx/issues"},"dist":{"shasum":"c28ff809e73eb8c578fbe8c038cfb555f1dc8bf6","tarball":"https://registry.npmjs.org/@emdzej/ncsx-cabd/-/ncsx-cabd-0.8.0.tgz","fileCount":27,"integrity":"sha512-SFIPZs7xuDmvSEZSLoovP1hnAQZpSf4F4CNjLFxFU7lSgioWT4N4IRu0W49Hmmc61QnkNFlppimc7FYdMq/UTw==","signatures":[{"sig":"MEUCIQC8giCz2RU2wNLGSzluCU/zYjFmepIz5/nHaTL3+87mjgIgAVrEr6LP8pN3zE74qUcG5jJgy9VvKxBobY6lr6wZtpg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38446},"main":"dist/index.js","type":"module","_from":"file:emdzej-ncsx-cabd-0.8.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run --passWithNoTests","build":"tsc -p tsconfig.json","clean":"rm -rf dist .turbo *.tsbuildinfo","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"emdzej","email":"michal@jaskolski.pro"},"_resolved":"/private/var/folders/7h/x_w_580x4s9dq3sq11tpvzkwy3nbj8/T/3c5b9e19d8c21aed5810ebf7f5d7d9fe/emdzej-ncsx-cabd-0.8.0.tgz","_integrity":"sha512-SFIPZs7xuDmvSEZSLoovP1hnAQZpSf4F4CNjLFxFU7lSgioWT4N4IRu0W49Hmmc61QnkNFlppimc7FYdMq/UTw==","repository":{"url":"git+https://github.com/emdzej/ncsx.git","type":"git","directory":"packages/cabd"},"_npmVersion":"11.16.0","description":"CABD coding-rule decoder and encoder (netto bytes ↔ FSW/PSW values). Spec: ../../docs/coding-flow.md, ../../docs/daten-format.md §1.7-1.8","directories":{},"_nodeVersion":"22.22.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","@types/node":"^22.13.1"},"_npmOperationalInternal":{"tmp":"tmp/ncsx-cabd_0.8.0_1780758392918_0.8915441464648668","host":"s3://npm-registry-packages-npm-production"}},"0.9.0":{"name":"@emdzej/ncsx-cabd","version":"0.9.0","description":"CABD coding-rule decoder and encoder (netto bytes ↔ FSW/PSW values). Spec: ../../docs/coding-flow.md, ../../docs/daten-format.md §1.7-1.8","main":"dist/index.js","types":"dist/index.d.ts","type":"module","devDependencies":{"@types/node":"^22.13.1","vitest":"^2.1.8"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/emdzej/ncsx.git","directory":"packages/cabd"},"scripts":{"build":"tsc -p tsconfig.json","test":"vitest run --passWithNoTests","test:watch":"vitest","lint":"eslint .","typecheck":"tsc --noEmit","clean":"rm -rf dist .turbo *.tsbuildinfo"},"_id":"@emdzej/ncsx-cabd@0.9.0","bugs":{"url":"https://github.com/emdzej/ncsx/issues"},"homepage":"https://github.com/emdzej/ncsx#readme","_integrity":"sha512-p2fBVDLyIPrBGaZLzSPwJNRwzEiyr8zh2zagIepz8yj9UwaOiC/GjVEyK02DAkUKdZPvhuuFzzj7BMTR0PTNlw==","_resolved":"/private/var/folders/7h/x_w_580x4s9dq3sq11tpvzkwy3nbj8/T/c2436acf8dcff6aa433c6201832cc048/emdzej-ncsx-cabd-0.9.0.tgz","_from":"file:emdzej-ncsx-cabd-0.9.0.tgz","_nodeVersion":"22.22.1","_npmVersion":"11.16.0","dist":{"integrity":"sha512-p2fBVDLyIPrBGaZLzSPwJNRwzEiyr8zh2zagIepz8yj9UwaOiC/GjVEyK02DAkUKdZPvhuuFzzj7BMTR0PTNlw==","shasum":"19053cc1e848d5faa53b65234f3060d637a3262b","tarball":"https://registry.npmjs.org/@emdzej/ncsx-cabd/-/ncsx-cabd-0.9.0.tgz","fileCount":27,"unpackedSize":38446,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDMXIyQy/fPqo5czYNxabuLnAQBjfJRKD8lOLGdgwEydAIgFD1i09RU6F764FdoAp1ZW2Q++3Btl7BCaXSbDXds0Zc="}]},"_npmUser":{"name":"emdzej","email":"michal@jaskolski.pro"},"directories":{},"maintainers":[{"name":"emdzej","email":"michal@jaskolski.pro"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ncsx-cabd_0.9.0_1783336545083_0.0015156675736005543"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-25T10:40:11.046Z","modified":"2026-07-06T11:15:45.335Z","0.4.0":"2026-05-25T10:40:11.414Z","0.5.1":"2026-05-27T10:07:04.878Z","0.6.0":"2026-05-28T15:13:48.490Z","0.7.0":"2026-05-29T13:56:34.629Z","0.8.0":"2026-06-06T15:06:33.097Z","0.9.0":"2026-07-06T11:15:45.212Z"},"bugs":{"url":"https://github.com/emdzej/ncsx/issues"},"homepage":"https://github.com/emdzej/ncsx#readme","repository":{"type":"git","url":"git+https://github.com/emdzej/ncsx.git","directory":"packages/cabd"},"description":"CABD coding-rule decoder and encoder (netto bytes ↔ FSW/PSW values). Spec: ../../docs/coding-flow.md, ../../docs/daten-format.md §1.7-1.8","maintainers":[{"name":"emdzej","email":"michal@jaskolski.pro"}],"readme":"# @emdzej/ncsx-cabd\n\nCABD coding-rule **decoder and encoder** — converts between the raw byte-level\n`netto` buffer that the ECU exchanges over EDIABAS and the logical FSW/PSW value layer\nNCSEXPER's coding UI works with.\n\nThis is the bidirectional core of BMW coding: read direction lets you decode what the ECU\ncurrently has; write direction lets you encode an edit ready to flash back.\n\nSpec: [`../../docs/coding-flow.md`](../../docs/coding-flow.md) (end-to-end pipeline) and\n[`../../docs/daten-format.md` §1.7-1.8](../../docs/daten-format.md#17-the-a-length-prefixed-bytes-field)\n(OPERATION operators + EINHEIT units).\n\n## The CABD rule\n\nEvery FSW lives somewhere in the SG's coding memory. A CABD rule (one row in\n`PARZUWEISUNG_FSW` / `PARZUWEISUNG_DIR`) says where and how:\n\n```ts\ninterface CabdRule {\n  wortadr: number;       // byte offset into the netto buffer (despite the name)\n  byteadr: number;       // number of consecutive bytes this FSW covers\n  maske: number[];       // mask bytes, one per byte covered (length === byteadr)\n  einheit?: Einheit;     // 'h' | 'A' | 'a' | 'b' | 'd' — how source bytes fold into a number\n  operations?: Operation[]; // post-processing operations: ! & * + - / > ^ |\n}\n```\n\n## Install\n\n```bash\npnpm add @emdzej/ncsx-cabd\n# or:\n\"@emdzej/ncsx-cabd\": \"workspace:*\"\n```\n\n## Quick start\n\n```ts\nimport { decodeField, encodeField } from '@emdzej/ncsx-cabd';\n\nconst rule = {\n  wortadr: 0x04,         // FSW lives at netto[4]\n  byteadr: 1,            // one byte wide\n  maske: [0xff],         // owns all 8 bits\n  einheit: 'h' as const, // raw hex bytes\n  operations: [],\n};\n\nconst netto = Uint8Array.from([0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00]);\n\n// Read direction: bytes → value\nconsole.log(decodeField(rule, netto)); // 0x01\n\n// Write direction: value → bytes (mutates `netto` in place)\nencodeField(rule, 0x42, netto);\nconsole.log(netto[4]?.toString(16));   // \"42\"\n```\n\n## API\n\n| Export                      | Direction | Purpose                                       |\n|-----------------------------|-----------|-----------------------------------------------|\n| `decodeField(rule, netto)`  | read      | Bytes at `wortadr` → logical value            |\n| `encodeField(rule, v, netto)` | write   | Value → masked bytes spliced into `netto`     |\n| `applyOperationsRead(value, ops)` | read | Run the OPERATION list left-to-right        |\n| `applyOperationsWrite(value, ops)` | write | Run the inverted OPERATION list           |\n| `decodeEinheit(bytes, e)`   | read      | Fold source bytes per EINHEIT char            |\n| `encodeEinheit(value, e, len)` | write  | Inverse of `decodeEinheit`                    |\n\n## OPERATION operators\n\n| Op    | Read direction | Write direction (inverse) |\n|-------|----------------|---------------------------|\n| `!`   | `~value` (bitwise NOT) | same                |\n| `&`   | `value & N`    | undefined (lossy)         |\n| `*`   | `value * N`    | `value / N`               |\n| `+`   | `value + N`    | `value - N`               |\n| `-`   | `value - N`    | `value + N`               |\n| `/`   | `value / N`    | `value * N`               |\n| `>`   | `value >> N`   | `value << N`              |\n| `^`   | `value ^ N`    | same                      |\n| `|`   | `value | N`    | undefined (lossy)         |\n\n`&` and `|` operations are lossy in the write direction; `encodeField` will throw if your\nrule requires inverting one.\n\n## EINHEIT (unit) chars\n\n| Char | Source format              | Decoded value                                  |\n|------|----------------------------|------------------------------------------------|\n| `h`  | hex bytes (LE)             | raw u8/u16/u32 LE                              |\n| `A`  | ASCII hex digit            | `'0'-'9'` → 0..9; `'A'-'Z'` → 10..35           |\n| `a`  | raw ASCII byte             | `c & 0xff`                                     |\n| `b`  | ASCII bit-string           | sum of `(c-'0') << pos` per char               |\n| `d`  | ASCII decimal digits       | `parseInt(s, 10)`                              |\n\n## Decode/encode pipeline\n\n```\nread:  netto bytes ──┬─→ AND with MASKE ─→ right-shift by trailing-zero count of mask\n                     │                       (auto-shift, can disable)\n                     │                       ↓\n                     └─→ fold via EINHEIT ─→ run OPERATION list ─→ logical value\n\nwrite: logical value ─→ invert OPERATION list ─→ unfold via EINHEIT ─→ left-shift to mask bit pos\n                                                                          ↓\n                                            splice into netto with MASKE-controlled OR\n```\n\n## Related\n\n- [`@emdzej/ncsx-daten`](../daten/) — gives you the raw `PARZUWEISUNG_FSW` rows that\n  build a `CabdRule`.\n- [`@emdzej/ncsx-coder`](../coder/) — uses this package per-edit to encode into a netto\n  buffer.\n- [`@emdzej/ncsx-trace`](../trace/) — Nettodata write path uses the same MASKE accumulation.\n- Specs: [`../../docs/coding-flow.md`](../../docs/coding-flow.md) and\n  [`../../docs/daten-format.md` §1.7-1.8](../../docs/daten-format.md#17-the-a-length-prefixed-bytes-field).\n","readmeFilename":"README.md"}