UNPKG

lin-ldf

Version:

WebAssembly parser for LDF files that describe automotive LIN bus networks.

406 lines (362 loc) 10.1 kB
/* tslint:disable */ /* eslint-disable */ /** * Enhanced TypeScript definitions for lin-ldf WASM package * * This file combines wasm-bindgen generated function signatures with * ts-rs generated type definitions for perfect type safety. */ /** * Parse LDF file content and return a JavaScript-friendly structure * * This is the main entry point for the library. Pass in LDF file content * as a string and get back a parsed structure that can be used in JavaScript. * * The returned structure uses the same types as the main lin-ldf library * but is serialized to JavaScript-compatible format. */ export function parse_ldf_file(ldf_content: string): LinLdf; /** * Parse LDF file content and return it as a JSON string * * This function is useful if you prefer working with JSON strings * instead of JavaScript objects. */ export function parse_ldf_to_json(ldf_content: string): string; /** * Parse LDF file content and return it as a pretty-printed JSON string * * This function is useful for debugging or when you want formatted JSON output. */ export function parse_ldf_to_pretty_json(ldf_content: string): string; /** * Create a LinLdf object from a JSON string * * This function allows you to deserialize a previously serialized LinLdf object. * Useful for saving/loading parsed LDF data. */ export function ldf_from_json(json_str: string): LinLdf; /** * Get the version of the WASM wrapper */ export function get_wasm_version(): string; /** * Get the version of the underlying lin-ldf library */ export function get_core_version(): string; /** * Validate LDF file content without fully parsing it * * Returns true if the LDF content appears to be valid, false otherwise. * This is faster than full parsing for validation purposes. */ export function validate_ldf(ldf_content: string): boolean; /** * Get basic statistics about an LDF file * * Returns a JavaScript object with counts of various LDF elements. */ export function get_ldf_stats(ldf_content: string): LdfStats; export function main(): void; export type LdfDiagnosticFrame = { /** * Frame name */ frame_name: string, /** * Frame ID */ frame_id: number, /** * Frame signals */ signals: Array<LdfDiagnosticFrameSignal>, }; export type LdfDiagnosticFrameSignal = { /** * Signal name */ signal_name: string, /** * Signal start bit */ start_bit: number, }; export type LdfDiagnosticSignal = { /** * All identifiers must be unique within the LDF file. */ name: string, /** * Length of the signal in bits. */ length: number, /** * Initial value of the signal. */ init_value: number, }; export type LdfFrame = { /** * Frame name */ frame_name: string, /** * Frame ID */ frame_id: number, /** * Frame publisher */ published_by: string, /** * Frame length in bytes */ frame_size: number, /** * Frame signals */ signals: Array<LdfFrameSignal>, }; export type LdfFrameDelay = { /** * Frame name */ frame_name: string, /** * Frame delay in milliseconds */ frame_time: number, }; export type LdfFrameSignal = { /** * Signal name */ signal_name: string, /** * Signal start bit */ start_bit: number, }; export type LdfHeader = { /** * LIN protocol version number (e.g. 2.1). * Shall be in the range of "0.01" to "99.99". */ lin_protocol_version: string, /** * LIN language version number (e.g. 2.1) * Shall be in the range of "0.01" to "99.99". */ lin_language_version: string, /** * LIN speed in bits per second (e.g. 19.2 kbps = 19200). * This sets the nominal bit rate for the cluster. It shall be in the range of 1 to 20 kbit/second. */ lin_speed: number, /** * Channel_name is optional and was added in LIN 2.2 version. */ channel_name: string | null, }; export type LdfNodeAttributes = { /** * Node name */ node_name: string, /** * LIN protocol version */ lin_protocol: string, /** * Configured NAD */ configured_nad: number, /** * Initial NAD */ initial_nad: number, /** * Part of the product ID */ supplier_id: number, /** * Part of the product ID */ function_id: number, /** * Variant of the product ID */ variant: number, /** * Response error */ response_error: string, /** * P2_min */ p2_min: string, /** * ST_min */ st_min: string, /** * N_As_timeout */ n_as_timeout: string, /** * N_Cr_timeout */ n_cr_timeout: string, /** * Configurable frames */ configurable_frames: Array<string>, }; export type LdfNodes = { master: MasterNode, slaves: Array<Node>, }; export type LdfScheduleTable = { /** * Schedule table name. * All schedule_table_name identifiers shall be unique within the schedule table identifier set */ schedule_table_name: string, /** * Frame delays */ frame_delays: Array<LdfFrameDelay>, }; export type LdfSignal = { /** * All identifiers must be unique within the LDF file. */ name: string, /** * The signal_size specifies the size of the signal. It shall be in the range 1 to 16 bits for * scalar signals and 8, 16, 24, 32, 40, 48, 56 or 64 for byte array signals. */ signal_size: number, /** * ```text * <init_value> ::= <init_value_scalar> | <init_value_array> * <init_value_scalar> ::= integer * <init_value_array> ::= {integer ([, integer])} * ``` * * The init_value specifies the signal value that shall be used by all subscriber nodes * until the frame containing the signal is received. The init_value_scalar is used for * scalar signals and the init_value_array is used for byte array signals. The initial_value for * byte arrays shall be arranged in big-endian order (i.e. with the most significant byte * first). * * The only way to describe if a signal with size 8 or 16 is a byte array with one or two * elements or a scalar signal is by analyzing the init_value, i.e. the curly parenthesis are * very important to distinguish between arrays and scalar values. */ init_value: LdfSignalInitValue, /** * The published_by specifies the node that is publishing the signal. * The published_by identifier shall exist in the node identifier set. */ published_by: string, /** * The subscribed_by specifies the node(s) that is subscribing to the signal. * The subscribed_by identifiers shall exist in the node identifier set. */ subscribed_by: Array<string>, }; export type LdfSignalEncodingType = { /** * Signal encoding type name */ encoding_type_name: string, /** * Signal encoding type values */ encoding_type_values: Array<LdfSignalEncodingTypeValue>, }; export type LdfSignalEncodingTypeValue = { "LogicalValue": { /** * Value */ value: number, /** * Value description */ value_description: string, } } | { "PhysicalValue": { /** * Minimum value */ min_value: number, /** * Maximum value */ max_value: number, /** * Scaling factor */ scaling_factor: number, /** * Offset */ offset: number, /** * Unit */ unit: string, } }; export type LdfSignalInitValue = { "Scalar": number } | { "Array": Array<number> }; export type LdfSignalRepresentation = { /** * Signal encoding type name */ encoding_type_name: string, /** * Signal names */ signal_names: Array<string>, }; export type LinLdf = { header: LdfHeader, nodes: LdfNodes, signals: Array<LdfSignal>, diagnostic_signals: Array<LdfDiagnosticSignal>, frames: Array<LdfFrame>, diagnostic_frames: Array<LdfDiagnosticFrame>, node_attributes: Array<LdfNodeAttributes>, schedule_tables: Array<LdfScheduleTable>, signal_encoding_types: Array<LdfSignalEncodingType>, signal_representations: Array<LdfSignalRepresentation>, }; export type MasterNode = { name: string, time_base: string, jitter: string, }; export type Node = { name: string, }; /** * Statistics about an LDF file's contents */ export interface LdfStats { signal_count: number; frame_count: number; node_count: number; schedule_table_count: number; diagnostic_signal_count: number; diagnostic_frame_count: number; node_attributes_count: number; signal_encoding_types_count: number; signal_representations_count: number; lin_protocol_version: string; lin_language_version: string; lin_speed: number; } export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly parse_ldf_file: (a: number, b: number) => [number, number, number]; readonly parse_ldf_to_json: (a: number, b: number) => [number, number, number, number]; readonly parse_ldf_to_pretty_json: (a: number, b: number) => [number, number, number, number]; readonly ldf_from_json: (a: number, b: number) => [number, number, number]; readonly get_wasm_version: () => [number, number]; readonly get_core_version: () => [number, number]; readonly validate_ldf: (a: number, b: number) => number; readonly get_ldf_stats: (a: number, b: number) => [number, number, number]; readonly main: () => void; readonly __wbindgen_export_0: WebAssembly.Table; readonly __wbindgen_malloc: (a: number, b: number) => number; readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; readonly __externref_table_dealloc: (a: number) => void; readonly __wbindgen_free: (a: number, b: number, c: number) => void; readonly __wbindgen_start: () => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. * * @returns {InitOutput} */ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. * * @returns {Promise<InitOutput>} */ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;