EDUCATION BUILD // NOT SAFETY-CERTIFIED // SYNTHETIC DEMO DATAEmbedded32 is for learning and prototyping - not automotive-certified, safety-certified, or a complete SAE J1939 stack.
Embedded32
Menu

@embedded32/can

Driver-agnostic CAN frame I/O for Embedded32 - mock, virtual, and SocketCAN backends for labs and production prototyping on Linux.

Installation

npm install @embedded32/can

Minimum runnable example

Hardware-free (works on any OS):

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

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

can.onMessage((frame) => {
  console.log('RX', frame.id.toString(16), frame.data);
  can.close();
});

can.send({ id: 0x123, data: [1, 2, 3], extended: false });

From monorepo root: npx tsx embedded32-can/examples/basic-mock.ts (after npm run build).

Public API overview

ExportRole
CANInterfaceSend/receive wrapper around a driver
MockCANDriverIn-memory driver for tests and examples
SocketCANDriverLinux SocketCAN (vcan0, can0)
VirtualCANPortConnect multiple peers on one virtual bus
ICANDriver, CANFrameTypes for custom drivers

J1939 parsing lives in @embedded32/j1939, not this package.

Runtime requirements

  • Node.js 18+
  • ESM (import) or bundler that resolves package exports

Hardware requirements

ModeHardware
Mock / virtualNone
SocketCANLinux or WSL with vcan/can interface and optional socketcan npm module

Browser compatibility

Node.js only. CAN hardware is not available in normal browser environments. Use simulation packages or the browser demo on the docs site.

Common errors

ErrorFix
Cannot find module '@embedded32/can'Run npm run build in monorepo or install published tarball
SocketCAN open failsCreate vcan0 (sudo ip link add dev vcan0 type vcan)
J1939 frames not decodedUse extended: true and decode with @embedded32/j1939
  • @embedded32/j1939 - parse and decode J1939 frames
  • @embedded32/sim - multi-ECU simulation on a virtual bus
  • @embedded32/tools - terminal monitor and simulate commands

Version compatibility

Align all @embedded32/* dependencies to 1.0.0 when installing from npm. Monorepo clones use workspace linking automatically.

License

MIT © Mukesh Mani Tripathi