@montra-connect/dbc-parser
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

@montra-connect/dbc-parser

A general-purpose CAN (Controller Area Network) toolbox with support for .dbc file parsing, CAN message decoding, and more.

Table of Contents

Installation

Install the package via npm:

npm install @montra-connect/dbc-parser

Features

  • Parse .dbc files to extract CAN message definitions.
  • Decode CAN messages using the parsed definitions.
  • Filesystem-based .dbc file reading support.
  • Utilities for working with CAN messages and databases.

Usage

Importing the Package

import { Can, Dbc } from '@montra-connect/dbc-parser';
import dbcReader from '@montra-connect/dbc-parser/lib/filesystem/DbcReader';

Parsing a DBC File

const canDB = new Can();
const dbc = new Dbc();

// Read the DBC file content (replace 'path/to/your/file.dbc' with your actual DBC file path)
const result = await dbcReader('path/to/your/file.dbc');

// Load the DBC content into the Dbc instance
const res = dbc.load(result.toString());

// Now you can use the 'canDB' and 'dbc' instances for decoding CAN messages

Decoding a CAN Message

// Assuming you have a CAN message to decode
const canMessage = {
  id: 0x123,
  data: Buffer.from([0x00, 0x01, 0x02, 0x03, 0x04, 0x05])
};

// Decode the message using the DBC definitions
const decodedMessage = canDB.decode(canMessage);

console.log(decodedMessage);

Build

To build the package, run:

npm run build

This will compile the TypeScript source files into JavaScript.

Testing

To run the test suite:

npm run test

This command will execute all test cases to ensure the package works as expected.

Linting

To check the code for linting errors:

npm run lint

This command will run ESLint on the codebase to ensure code quality and consistency.

License

This project is licensed under the MIT License.


Feel free to contribute to the project or report any issues you encounter.

Package Sidebar

Install

npm i @montra-connect/dbc-parser

Weekly Downloads

7

Version

0.0.4

License

MIT

Unpacked Size

1.11 MB

Total Files

121

Last publish

Collaborators

  • kameshkishoreticm
  • saddam-montra