DBDelve
Dive deep into your data. A fast, native, multi-engine database client written in Rust. Free and open source, no telemetry.
翻訳待ち
No updates detected yet. GitHub releases will appear here.
C99 CAN FD bit-timing library for Bosch M_CAN: finds exact settings, encodes NBTP/DBTP/TDCR with transmitter delay compensation. No heap, tested against the web calculator, CI with sanitizers.
翻訳待ち
Loading the full README.
Read the full README ↗A small C99 library that finds CAN FD bit timings for Bosch M_CAN-style controllers, and encodes them into
the NBTP, DBTP and TDCR registers, including transmitter delay compensation. No dependencies, no heap,
one header. It is the C version of the calculator on
moutazm.com/projects/can-tools, and the tests check that both agree.
$ ./canfd-bt 40 500 80 2000 75
4 valid settings, best:
nominal brp 1 tq 80 = 1 + 63 + 16 sjw 16 sample point 80.00 %
data brp 1 tq 20 = 1 + 14 + 5 sjw 5 sample point 75.00 %
TDC on, TDCO = 15 clock cycles
M_CAN NBTP 0x1E003E0F DBTP 0x00800D44 TDCR 0x00000F00
Linux ip link set can0 up type can bitrate 500000 sample-point 0.800 dbitrate 2000000 dsample-point 0.750 fd on
For a CAN clock, a nominal and a data bit rate and two target sample points it:
m_can driver uses):
nominal prescaler 1–512, TSEG1 2–256, TSEG2 2–128; data prescaler 1–32, TSEG1 1–32, TSEG2 1–16;TDCO = data BRP × (1 + TSEG1) and says whether TDC is
allowed (ISO 11898-1: data prescaler 1 or 2 only);#include "canfd_bittiming.h"
cfd_setting best[3];
size_t n = cfd_solve(40000000u, 500000u, 0.80, 2000000u, 0.75, true, best, 3);
if (n) {
bool tdc = cfd_tdc_possible(&best[0].data);
uint32_t nbtp = cfd_mcan_nbtp(&best[0].nominal);
uint32_t dbtp = cfd_mcan_dbtp(&best[0].data, tdc);
uint32_t tdcr = cfd_mcan_tdcr(&best[0].data);
}
cfd_solve returns how many valid settings exist and writes the best max (up to 64) into your buffer, best
first. Pass NULL, 0 to only count.
make # libcanfd_bittiming.a + the canfd-bt command-line tool
make test # unit tests
CI builds with gcc and clang, -std=c99 -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Werror, and runs the
tests again under AddressSanitizer and UndefinedBehaviorSanitizer. The reference cases in
tests/test_bittiming.c (prescalers, time quanta, segments, SJW, register values, TDCO, number of solutions) were
generated by the website's JavaScript, so a change in either one shows up as a failing test.
MIT