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

@embedded32/can

v1.0.0

Published

CAN bus abstraction for the Embedded32 platform

Readme

@embedded32/can

Lightweight, driver-agnostic CAN bus abstraction for the Embedded32 platform.

Overview

This package provides a TypeScript interface for CAN communication with support for:

  • SocketCAN - Linux, Raspberry Pi, WSL
  • MockCANDriver - Testing, CI, simulation
  • Custom Drivers - Implement your own hardware layer

This module does not implement J1939 encoding/decoding. PGN/SPN logic is part of @embedded32/j1939.

Installation

npm install @embedded32/can

Platform Support

| Platform | Driver | Status | |----------|--------|--------| | Linux / Raspberry Pi / WSL | SocketCAN | ✅ Full support | | macOS / Windows | MockCANDriver | ✅ Simulation only |

Usage

SocketCAN (Linux)

import { CANInterface, SocketCANDriver } from "@embedded32/can";

const driver = new SocketCANDriver("can0");
const can = new CANInterface(driver);

// Send a CAN frame
can.send({
  id: 0x123,
  data: [0x01, 0x02, 0x03],
  extended: false
});

// Receive frames
can.onMessage((frame) => {
  console.log("CAN RX:", frame);
});

// Cleanup
can.close();

MockCANDriver (Cross-Platform Testing)

import { CANInterface, MockCANDriver } from "@embedded32/can";

const can = new CANInterface(new MockCANDriver());

can.onMessage((f) => console.log("Mock RX:", f));

can.send({
  id: 0x456,
  data: [0x10, 0x20, 0x30]
});

Custom Driver

import { ICANDriver, CANFrame } from "@embedded32/can";

export class MyDriver implements ICANDriver {
  send(frame: CANFrame) {
    // Write to hardware
  }

  onMessage(handler: (frame: CANFrame) => void) {
    // Call handler when frame arrives
  }

  close() {
    // Cleanup
  }
}

const can = new CANInterface(new MyDriver());

API Reference

CANFrame

interface CANFrame {
  id: number;
  data: number[];
  extended?: boolean;  // true = 29-bit, false = 11-bit
  timestamp?: number;
}

CANInterface

| Method | Description | |--------|-------------| | send(frame) | Send a CAN frame | | onMessage(handler) | Register message handler | | close() | Close the interface |

ICANDriver

interface ICANDriver {
  send(frame: CANFrame): void | Promise<void>;
  onMessage(handler: (frame: CANFrame) => void): void;
  close(): void;
}

SocketCAN Setup

# Install CAN utilities
sudo apt-get install can-utils

# Create virtual CAN interface
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0

# Setup hardware CAN (500 kbps)
sudo ip link set can0 type can bitrate 500000
sudo ip link set up can0

License

MIT © Mukesh Mani Tripathi