@emdzej/ncsx-fa-asw
v0.8.0
Published
FA token string → ASW bit set converter. Spec: ../../docs/ecu-selection.md §3.3
Downloads
922
Readme
@emdzej/ncsx-fa-asw
Converts a user-facing FA string (Auftrag — the comma/space-separated list of factory
option codes like "0205 0502 0524") into the ASW bit set that the
@emdzej/ncsx-predicate evaluator consumes to match AUFTRAGSAUSDRUCK
rows in <BR>SGET.000 and <BR>CVT.000.
NCSEXPER equivalent: coapiGetAswFromAuftrag → RecFncAsw.
Spec: ../../docs/ecu-selection.md §3.3.
Mental model
FA string AT records SWTASW ASW bit set
"$0902 $0524 $0205" ──→ ['SWA', 'CL', …] ──→ KEYID lookups ──→ Set<u16>
(FSW names) (per FSW)- Tokenise the FA string (whitespace / commas; strip
$and category-letter prefixes). - Look each token up in
chassis.atto get the FSW names it implies. - Look each FSW name up in
chassis.swtAswto get its u16 KEYID. - Optionally pull in additional Zwang (forced-inclusion) codes from
chassis.atM00.
Install
pnpm add @emdzej/ncsx-fa-asw
# or:
"@emdzej/ncsx-fa-asw": "workspace:*"Quick start
import { loadChassis } from '@emdzej/ncsx-chassis';
import { nodeChassisSource } from '@emdzej/ncsx-chassis/node';
import { faToAsw } from '@emdzej/ncsx-fa-asw';
const chassis = await loadChassis(nodeChassisSource('…/DATEN'), 'E46');
const asw = faToAsw('$0902 $0524 $0205', { chassis });
// asw is a Set<number> of u16 KEYIDs that the predicate evaluator consumes.
// Feed it to a predicate (typically via ecu-select, but you can call it directly):
import { evalAuftragsausdruck } from '@emdzej/ncsx-predicate';
evalAuftragsausdruck(predicateBytes, asw);API
| Export | Purpose |
|--------------------|------------------------------------------------------------------|
| faToAsw(fa, opts) | The pipeline: FA string → ASW bit set |
| tokenizeFa(fa) | Just the FA tokeniser (handy for UI input echo / validation) |
| aswFromIds(ids) | Build an AswSet directly from a list of KEYIDs |
| AswSet | Type alias: Set<number> |
faToAsw options
faToAsw(fa, {
chassis, // required — supplies AT + SWTASW + AT.M00
strict: false, // when true, throws on unknown FA codes / FSWs
includeZwang: true, // when true, add KEYIDs from AT.M00 Z records
onWarning: (w) => { … }, // unknown FA code, unknown FSW, no SWT table, …
});FA-string syntax accepted
- Whitespace OR commas as separators:
"0902,0524,0205"works the same as"0902 0524 0205". - Optional
$prefix per token:"$0902"(matches the convention NCSEXPER's editor uses). - Optional leading category letter:
"W0902"is the same as"0902". - Leading zeros are tolerated —
"0205"and"205"both resolve.
Warnings
onWarning receives objects like:
{ kind: 'unknown-fa-code', code: '999', message: … }— token not inchassis.at.{ kind: 'unknown-fsw', fsw: 'GHOST', message: … }— AT record references a FSW not in SWTASW.{ kind: 'no-swt', message: … }— chassis bundle has no SWTASW table loaded.
In strict: true mode each of these throws instead.
What this doesn't do (yet)
- ZCS → ASW decoding. A car's ZCS (Zentral-Codier-Schlüssel) is another way of
expressing FA; converting it requires the per-module ZCS decoder. Wait for a future
zcs-aswpackage or do it yourself viachassis.zcsut. - FSW-keyword to ASW lookup. The predicate's
S<id>opcode references SA codes, not FSW IDs. If you want to test "is FSW SWA active?", usechassis.zstto find which SA codes contribute to that FSW, then check whether those SAs are in the ASW.
Related
@emdzej/ncsx-chassis— supplies theAT+SWTASW+AT.M00tables.@emdzej/ncsx-predicate— consumes theAswSetthis produces.@emdzej/ncsx-ecu-select— most common downstream caller.- Spec:
../../docs/ecu-selection.md§3.3.
