npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@emdzej/ncsx-ecu-select

v0.8.0

Published

Walks <BR>SGET.000 to produce the in-scope SG list for a given chassis + ASW. Equivalent of NCSEXPER's coapiScanAllSgFromBr.

Downloads

810

Readme

@emdzej/ncsx-ecu-select

Given a chassis bundle and the car's ASW bit set, returns the list of SGs (ECUs) that are in scope — the ones whose AUFTRAGSAUSDRUCK predicate matches.

This is step 2 of the coding flow: before you can code or read any SG, you need to know which SGs the car actually has. NCS Expert calls this "Process ECU" and walks the same SGAUSWAHL_* blocks in the same order; this package is the deterministic equivalent.

NCSEXPER equivalent: coapiScanAllSgFromBr (with coapiScanAllSgFromZcs being the same function fed by a different ASW source).

Spec: ../../docs/ecu-selection.md §3.4.

What it does

Walks the three SGAUSWAHL_* blocks of <BR>SGET.000 in most-specific-first order:

  1. SGAUSWAHL_VMSGBD — variant + module-variant + SGBD-specific rows.
  2. SGAUSWAHL_SGBD — module-variant + SGBD-specific rows.
  3. SGAUSWAHL_VM — variant-only fallback.

For each row, evaluates the AUFTRAGSAUSDRUCK byte-coded predicate against the supplied AswSet (via @emdzej/ncsx-predicate). Matching rows are returned as a SelectedSg[] with the resolved (sgName, cabd, sgbd, …) tuple.

By default, deduplicates by sgName so the most-specific row wins for each SG.

Install

pnpm add @emdzej/ncsx-ecu-select
# or:
"@emdzej/ncsx-ecu-select": "workspace:*"

Quick start

import { loadChassis } from '@emdzej/ncsx-chassis';
import { nodeChassisSource } from '@emdzej/ncsx-chassis/node';
import { faToAsw } from '@emdzej/ncsx-fa-asw';
import { selectEcus } from '@emdzej/ncsx-ecu-select';

const chassis = await loadChassis(nodeChassisSource('…/DATEN'), 'E46');
const asw = faToAsw('0205 0502 0524', { chassis });
const selected = selectEcus(chassis, asw);

for (const sg of selected) {
  console.log(`${sg.source}  ${sg.sgName}  CBD=${sg.cbd}  CABD=${sg.cabd}  SGBD=${sg.sgbd}`);
}

API

| Export | Purpose | |----------------------------|--------------------------------------------------------| | selectEcus(chassis, asw, opts?) | Walk SGAUSWAHL_* and return matched SGs | | SelectedSg | One row in the result | | SelectionSource | 'VMSGBD' \| 'SGBD' \| 'VM' — which block matched |

SelectedSg

interface SelectedSg {
  sgName: string;       // logical SG short name (matches SGFAM)
  cbd: string;          // CBD coding bundle name
  cabd?: string;        // CABD coding module name (omitted for VM rows)
  sgbd?: string;        // EDIABAS SGBD file (omitted for VM rows)
  umrsg: string;        // conversion-SG hint
  vmg?: string;         // module-variant (omitted for SGBD rows)
  index: number | null;
  source: SelectionSource;  // which SGAUSWAHL_* block this came from
}

selectEcus options

selectEcus(chassis, asw, {
  dedupeBySgName: true,         // most-specific row wins per SG (default true)
  maxPredicateLength: 100,      // skip predicates longer than this (safety)
  onWarning: (msg) => { … },    // surface skip reasons (rare; mostly malformed predicates)
});

When to reach for it

  • Building a "Pick a module" UI — feed selected into a list.
  • Driving a multi-SG batch operation (planCoding does this internally).
  • Debugging "why isn't NCS Expert seeing my module?" — compare selectEcus output against what NCS Expert lists for your VIN.

Tie-breaker semantics

When dedupeBySgName: true (the default):

  • The walk order is most-specific → least-specific (VMSGBD → SGBD → VM).
  • The first (sgName) to match wins; subsequent rows for the same SG are skipped.
  • This matches NCSEXPER's behaviour: a VMSGBD-specific override beats a VM fallback.

Set dedupeBySgName: false if you want every matching row (e.g. for diagnostic "why didn't my preferred row match?" exploration).

Related