@emdzej/ediabasx-core
v0.8.0
Published
EDIABAS / EdiabasX shared primitives: CP1252 encoding, XOR decryption (key 0xF7), error codes, type definitions.
Readme
@emdzej/ediabasx-core
Shared primitives used across the EdiabasX monorepo. No external dependencies.
Install
pnpm add @emdzej/ediabasx-coreWhat's in here
| Export | Purpose |
|---|---|
| cp1252ToUtf8(bytes) / utf8ToCp1252(str) | Round-trip BMW's Windows-1252 strings to/from JS strings |
| xorDecrypt(bytes, key) / xorEncrypt(bytes, key) | PRG/GRP payload de/encryption (BEST2 uses key 0xF7) |
| EdiabasError, EdiabasErrorCodes | Typed errors mirroring the C# ErrorCodes enum (EDIABAS_IFH_*, EDIABAS_BIP_*, EDIABAS_SYS_*, …) |
| IEdiabas interface | Unified contract for local (EmbeddedEdiabas) and remote (EdiabasClient) usage. Methods mirror the native EDIABAS C API: init/end/job(ecu, name, params?), plus resultSets() / resultText/Int/Real/Binary(name, set) accessors with set 0 = system set, set 1..N = data sets (matches C# EdiabasNet). The params argument covers both apiJob and apiJobData channels — string entries land in the indexed-string slots (pari / pars), Uint8Array entries in the binary payload (pary / parb / parw / parl / parr); accepts string, Uint8Array, or an interleaved array. |
| EdiabasJobResponse, EdiabasResultSet, EdiabasResultEntry | Wire-format types for JSON-RPC job results. EdiabasJobResponse.sets[0] is always the system set (VARIANTE/OBJECT/JOBNAME/SAETZE + persistent metadata); sets[1..N] are the data sets emitted by the bytecode. EdiabasResultEntry carries name/type/value plus optional unit/comment. |
| EdiabasResultType, EdiabasState | Enums for result types and session state |
| Constants & type definitions | Stable shapes shared by parser, interpreter, transports |
Example
import { cp1252ToUtf8, xorDecrypt, EdiabasError, EdiabasErrorCodes } from "@emdzej/ediabasx-core";
// Decode the encoded section of a PRG/GRP file (everything past 0xA0).
const decoded = xorDecrypt(encoded, new Uint8Array([0xf7]));
// Decode a CP1252 byte string (e.g. job comment, table cell).
const text = cp1252ToUtf8(decoded.subarray(0, 64));
throw new EdiabasError(EdiabasErrorCodes.EDIABAS_BIP_0001, "array overflow");