# dronecan.ts

> TypeScript implementation of the [DroneCAN](https://dronecan.github.io) protocol.

Latest version **0.22.0** (published 2026-08-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install dronecan.ts
pnpm add dronecan.ts
yarn add dronecan.ts
bun add dronecan.ts
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.22.0 |
| Published | 2026-08-17 |
| First published | 2023-12-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 96.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | gribbet |

## Links

- npm: https://www.npmjs.com/package/dronecan.ts
- Repository: https://github.com/gribbet/dronecan.ts
- Homepage: https://github.com/gribbet/dronecan.ts#readme
- Issues: https://github.com/gribbet/dronecan.ts/issues
- npm.io page: https://npm.io/package/dronecan.ts

## Dependencies (1)

- [@petamoriken/float16](https://npm.io/package/@petamoriken/float16.md) ^3.9.3

## Recent versions

- 0.22.0 (latest) — 2026-08-17
- 0.21.0 — 2026-03-05
- 0.20.2 — 2026-02-25
- 0.20.1 — 2026-01-23
- 0.20.0 — 2026-01-21
- 0.19.0 — 2025-12-16
- 0.18.0 — 2025-12-12
- 0.17.1 — 2025-11-21
- 0.17.0 — 2025-10-30
- 0.16.0 — 2024-10-22
- 0.15.0 — 2024-06-22
- 0.14.0 — 2024-06-22
- 0.13.0 — 2024-06-22
- 0.12.1 — 2024-06-22
- 0.12.0 — 2024-06-18
- … 16 more at https://npm.io/package/dronecan.ts/versions

## README

# Dronecan.ts

TypeScript implementation of the [DroneCAN](https://dronecan.github.io) protocol.

[Example](https://github.com/gribbet/dronecan.ts-example)

## Usage overview

### Define protocol schema
```ts
export const schema = {
  messages: [
    message({
      id: 341,
      type: "uavcan.protocol.NodeStatus",
      definition: {
        uptimeSec: uint(32),
        health: enumeration(2, ["ok", "warning", "error", "critical"] as const),
        mode: enumeration(3, [
          "operational",
          "initialization",
          "maintenance",
          "software update",
          4,
          5,
          6,
          "offline",
        ] as const),
        subMode: uint(3),
        vendorSpecificStatusCode: uint(16),
      },
    }),
  ],
  services: [],
} as const;
```
### Broadcast
```ts
 dronecan.broadcast("uavcan.protocol.NodeStatus", {
    uptimeSec: 0,
    health: "ok",
    mode: "operational",
    subMode: 0,
    vendorSpecificStatusCode: 0,
  })
```
### Request
```ts
const info = await dronecan.request("uavcan.protocol.GetNodeInfo", destinationId, {});
```

### Respond
```ts
dronecan.onRequest("uavcan.protocol.GetNodeInfo", () => ({
  status: {
    uptimeSec: 0,
    health: "ok",
    mode: "operational",
    subMode: 0,
    vendorSpecificStatusCode: 0,
  },
  softwareVersion: {
    major: 1,
    minor: 0,
    optionalFieldFlags: 0,
    vcsCommit: 0,
    imageCrc: 0n,
  },
  hardwareVersion: {
    major: 1,
    minor: 0,
    uniqueId: new Uint8Array(new Array(16)),
    certificateOfAuthenticity: new Uint8Array(),
  },
  name: "",
});
```

---
_Source: https://npm.io/package/dronecan.ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
