Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/test-and-measurement/matlab-use-vehicle-network

matlab-use-vehicle-network

Unverified

Use when setting up vehicle network communication in MATLAB using Vehicle Network Toolbox. Covers CAN/CAN FD (fully implemented), with architecture for J1939, XCP, and future protocols. Handles hardware discovery, channel creation, bus configuration, message exchange, signal encoding/decoding, and analysis across all supported vendors. (Vector, Kvaser, PEAK-System, NI, SocketCAN, MathWorks Virtual).

FileKindSize
SKILL.mdskill md13.1 KB
manifest.yamlconfig537 B
references/can/bus-speed-config.mdmarkdown2.2 KB
references/can/channel-creation.mdmarkdown1.5 KB
references/can/database.mdmarkdown3.0 KB
references/can/filters.mdmarkdown2.8 KB
references/can/message-creation.mdmarkdown1.3 KB
references/can/message-extraction.mdmarkdown3.8 KB
references/can/pack-unpack.mdmarkdown2.6 KB
references/can/receive.mdmarkdown1.9 KB
references/can/transmit.mdmarkdown2.3 KB
references/can/troubleshooting/bus-length-guidelines.mdmarkdown3.5 KB
references/can/troubleshooting/diagnostic-workflow.mdmarkdown21.4 KB
references/can/troubleshooting/l1-branches.mdmarkdown11.1 KB
references/can/troubleshooting/l1-domain-knowledge.mdmarkdown6.8 KB
references/can/troubleshooting/l1-failure-scenarios.mdmarkdown3.6 KB
references/can/troubleshooting/l2-analysis-pipeline.mdmarkdown4.5 KB
references/can/troubleshooting/l2-interpretation-tables.mdmarkdown1.8 KB
references/can/troubleshooting/script-interfaces.mdmarkdown2.6 KB
references/shared/channel-lifecycle.mdmarkdown1.1 KB
references/shared/hardware-discovery.mdmarkdown1.1 KB
references/shared/limitations.mdmarkdown1.7 KB
scripts/can/troubleshooting/canBaudRateScanActive.pbinary1.0 KB
scripts/can/troubleshooting/canBaudRateScanPassive.pbinary1.0 KB
scripts/can/troubleshooting/canBurstDetection.pbinary488 B
scripts/can/troubleshooting/canBusLoadCalc.pbinary787 B
scripts/can/troubleshooting/canChannelHealthCheck.pbinary902 B
scripts/can/troubleshooting/canCycleTimeAnalysis.pbinary558 B
scripts/can/troubleshooting/canDiagnosticProbe.pbinary335 B
scripts/can/troubleshooting/canHardwareDiscovery.pbinary290 B
scripts/can/troubleshooting/canLoopbackSelfTest.pbinary628 B
scripts/can/troubleshooting/canSupportSummary.pbinary1.4 KB
scripts/can/troubleshooting/canTrafficOverview.pbinary900 B

references/can/pack-unpack.md

View on GitHub
# Pack / Unpack

## pack — Encode a signal value into message data bytes

```matlab
pack(msg, value, startBit, signalLength, byteOrder);
```

- `msg` — `canMessage` or `canFDMessage` object
- `value` — numeric value to encode (cast determines signedness: `int16`, `uint8`, etc.)
- `startBit` — 0-based bit position where signal starts
- `signalLength` — number of bits the signal occupies
- `byteOrder` — `'LittleEndian'` or `'BigEndian'`

**Writes directly to `msg.Data`** — triggers `transmitEvent` if enabled.

## unpack — Decode a signal value from message data bytes

```matlab
value = unpack(msg, startBit, signalLength, byteOrder, dataType);
```

- `dataType` — output type string: `'int8'`, `'uint16'`, `'single'`, `'double'`, etc.
- Returns the decoded numeric value

## Key Behaviors

- `pack`/`unpack` work on **message objects**, not timetables
- For received timetables: extract the message first, then unpack:
  ```matlab
  msgs = receive(ch, Inf, 'OutputFormat', 'timetable');
  rawData = msgs.Data{1};  % uint8 array
  value = typecast(rawData(1:2), 'int16');  % manual decode
  ```
- Byte order must match the DBC/signal specification exactly
- The `value` type in `pack` determines sign extension: use `int16(-500)` for signed signals
- For CAN FD messages with DLC > 8, bit positions extend beyond 63

## pack vs Database Signals

| Approach | When to Use |
|----------|-------------|
| `pack`/`unpack` | No DBC available, or working with raw proprietary protocols |
| `msg.Signals.Name = value` | DBC attached — handles factor, offset, byte order automatically |

Database signals are higher-level: `msg.Signals.EngineSpeed = 3000` internally calls the equivalent of `pack` with the correct parameters from the DBC definition.

## Typical Patterns

**Manual encode/decode (no database):**
```matlab
msg = canMessage(0x180, false, 8);
pack(msg, int16(3000), 0, 16, 'LittleEndian');   % speed at bits 0-15
pack(msg, uint8(85), 16, 8, 'LittleEndian');     % temp at bits 16-23
transmit(ch, msg);

% On receive side:
rxMsg = receive(ch, 1);
speed = unpack(rxMsg, 0, 16, 'LittleEndian', 'int16');
temp = unpack(rxMsg, 16, 8, 'LittleEndian', 'uint8');
```

**CAN FD with large payload:**
```matlab
msg = canFDMessage(0x300, false, 64);
pack(msg, single(3.14), 0, 32, 'LittleEndian');    % float at bits 0-31
pack(msg, uint32(12345), 32, 32, 'LittleEndian');  % counter at bits 32-63
```

**Event-triggered transmit with pack:**
```matlab
msg = canMessage(0x200, false, 8);
transmitEvent(ch, msg, 'On');
start(ch);

% Each pack writes .Data, triggering auto-transmit
pack(msg, int16(value), 0, 16, 'LittleEndian');
```

----

Copyright 2026 The MathWorks, Inc.

----
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall