Skip to main content
Glama

Rake

Calculate CAN bit timing

calc_can_bit_timing
Read-onlyIdempotent

Computes the CAN bit timing for a clock, a bit rate and a sample point: prescaler, time quanta, both segments and the jump width, with the real bit rate, the real sample point and the register value. Use it when setting up CAN or CAN FD instead of working the values out by hand. The controller classic gives the counts for a classic CAN controller whose time quantum is the prescaler times the clock period, within the fields most of them have: a prescaler up to 64, segments up to 16 and 8 quanta, and a jump width up to 4. sja1000 and mcp2515 are those two controllers, which halve the oscillator before the prescaler and have limits of their own. With bxcan (CAN_BTR of STM32) or mcan-nominal and mcan-data (NBTP and DBTP of Bosch M_CAN, which several vendors use for CAN FD), it also packs the register value.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "controller": "<controller>",
      "clock_hz": "<clock_hz>",
      "bit_rate": "<bit_rate>"
    },
    "name": "calc_can_bit_timing"
  }
}

Input Schema

NameRequiredDescriptionDefault
bit_rateYesThe bit rate in bits per second, for example 500000. Above 1000000 only for mcan-data.
clock_hzYesThe clock that feeds the bit timing logic of the CAN controller, in Hz. It is often not the core clock. For sja1000 and mcp2515, the frequency of the oscillator.
controllerYesclassic (counts only, a plain prescaler), sja1000 or mcp2515 (counts only), bxcan, mcan-nominal (arbitration phase) or mcan-data (the data phase of CAN FD).
sample_pointNoThe wanted sample point as a fraction of the bit. Default 0.875, which CANopen and DeviceNet use.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover the safety profile (read-only, idempotent, non-destructive, closed-world), so the description correctly spends its words elsewhere: it discloses that sja1000 and mcp2515 halve the oscillator before the prescaler, that mcan-nominal vs mcan-data map to different M_CAN registers, and that bit rates above 1 MHz are only valid for mcan-data. It stops short of saying what happens when no valid timing exists or how it reports failures.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded in the first sentence and every subsequent sentence carries distinct information about a controller family. It loses a point for being one undifferentiated block with awkward phrasing such as "The controller classic gives the counts" and "sja1000 and mcp2515 are those two controllers," which would read better split by controller family.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description carries the burden of describing return values, and it does so by naming every returned field plus the packed register value. With 100% schema coverage on parameters and annotations covering side effects, the only remaining gap is error/feasibility behavior for impossible clock/bit-rate combinations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is already 100%, so the baseline is 3, but the description adds real meaning beyond the schema: the classic controller's field limits (prescaler up to 64, segments 16 and 8, jump width 4) tell the agent which inputs will actually succeed, and the mcan register mapping clarifies the controller enum's practical meaning. It does not restate or obscure the sample-point default already documented in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening clause names a specific verb (computes) and resource (CAN bit timing) and enumerates the exact outputs: prescaler, time quanta, both segments, jump width, real bit rate, real sample point, and register value. The rest of the description disambiguates the controller variants, so an agent can tell this apart from calc_i2c_timing or calc_uart_baud without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

"Use it when setting up CAN or CAN FD instead of working the values out by hand" gives clear context for when to reach for this tool. It also implicitly routes the agent among the enum choices by explaining which controllers are counts-only versus register-packing, though it never states a when-not condition or names an alternative tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources