Add DBC view (#180)

This commit is contained in:
Piotr Rogowski 2023-11-01 20:23:41 +01:00 committed by GitHub
parent 2014a411ee
commit b5ecf4c1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 376 additions and 3 deletions

View File

@ -26,6 +26,7 @@
"DFCO",
"dyno",
"easyops",
"endianess",
"FOME",
"footwell",
"GPPMW",
@ -43,6 +44,7 @@
"pinout",
"Polygonus",
"powerband",
"Pulsewidth",
"pushrod",
"rehype",
"standardised",

View File

@ -1,8 +1,30 @@
import DbcViewer from '@site/src/components/DbcViewer';
# CAN
## What is CANBUS?
## What is CAN and CANBUS?
CANBUS is a communication protocol that allows devices to talk to each other.
**CAN** (Controller Area Network) is a robust vehicle bus standard designed to facilitate communication among various components without a host computer. It is used in many modern cars, and is a great way to get data from the car to the **ECU**. It is also a great way to get data from the **ECU** to other devices, such as a dash, or a data logger.
It is used in many modern cars, and is a great way to get data from the car to the ECU. It is also a great way to get data from the ECU to other devices, such as a dash, or a data logger.
**CANBUS / CAN bus**, or Controller Area Network Bus, refers to the physical medium (wires and connections) through which the CAN protocol operates. It's the network of interconnected CAN devices within a vehicle or industrial setup.
## DBC
A **DBC** (Database Container) file is a standard file format used in the context of Controller Area Network (CAN) networks. It contains information about messages and signals that can be transmitted over a CAN network.
In a **DBC** file:
- Messages represent specific packets of data sent over the CAN network, each identified by a unique ID.
- Signals are individual pieces of data within messages, specifying the data's name, start bit, length, endianess, and other attributes. Signals can represent information such as vehicle speed, engine RPM, or sensor readings.
## FOME's DBC file
:::info SOURCE
[FOME-Tech/fome-fw/blob/master/firmware/controllers/can/rusEFI_CAN_verbose.dbc](https://github.com/FOME-Tech/fome-fw/blob/master/firmware/controllers/can/rusEFI_CAN_verbose.dbc)
:::
<DbcViewer />

3
global.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
declare module '*.txt';
declare module '*.html';
declare module '*.dbc';

79
package-lock.json generated
View File

@ -13,6 +13,7 @@
"@docusaurus/preset-classic": "^3.0.0",
"@easyops-cn/docusaurus-search-local": "^0.36.0",
"@mdx-js/react": "^3.0.0",
"candied": "^2.2.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.1.0",
"react": "^18.2.0",
@ -28,6 +29,7 @@
"@tsconfig/docusaurus": "^2.0.2",
"@types/node": "^20.8.10",
"docusaurus-prince-pdf": "^1.2.1",
"raw-loader": "^4.0.2",
"typescript": "^5.2.2"
},
"engines": {
@ -6653,6 +6655,14 @@
"node": ">= 6"
}
},
"node_modules/candied": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/candied/-/candied-2.2.0.tgz",
"integrity": "sha512-r2C6Ekh7nF8TbgLFL94r1SMWijiYKS8MBw6yb99FKVXvpa8OeH15WgRwV6PfPKENVAsMFQP0YU6SqemkUrWmXQ==",
"dependencies": {
"candied": "^2.1.0"
}
},
"node_modules/caniuse-api": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz",
@ -14837,6 +14847,75 @@
"node": ">= 0.8"
}
},
"node_modules/raw-loader": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.2.tgz",
"integrity": "sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==",
"dev": true,
"dependencies": {
"loader-utils": "^2.0.0",
"schema-utils": "^3.0.0"
},
"engines": {
"node": ">= 10.13.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"peerDependencies": {
"webpack": "^4.0.0 || ^5.0.0"
}
},
"node_modules/raw-loader/node_modules/ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"dev": true,
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/raw-loader/node_modules/ajv-keywords": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
"integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
"dev": true,
"peerDependencies": {
"ajv": "^6.9.1"
}
},
"node_modules/raw-loader/node_modules/json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
},
"node_modules/raw-loader/node_modules/schema-utils": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz",
"integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.8",
"ajv": "^6.12.5",
"ajv-keywords": "^3.5.2"
},
"engines": {
"node": ">= 10.13.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
}
},
"node_modules/rc": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",

View File

@ -28,6 +28,7 @@
"@docusaurus/preset-classic": "^3.0.0",
"@easyops-cn/docusaurus-search-local": "^0.36.0",
"@mdx-js/react": "^3.0.0",
"candied": "^2.2.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.1.0",
"react": "^18.2.0",
@ -43,6 +44,7 @@
"@tsconfig/docusaurus": "^2.0.2",
"@types/node": "^20.8.10",
"docusaurus-prince-pdf": "^1.2.1",
"raw-loader": "^4.0.2",
"typescript": "^5.2.2"
},
"browserslist": {

View File

@ -0,0 +1,95 @@
import { Dbc } from 'candied';
import { DbcData } from 'candied/lib/dbc/Dbc';
import { dbcReader } from 'candied/lib/filesystem/DbcWebFs';
import { useEffect, useState } from 'react';
import fomeDbcFileRaw from '!!raw-loader!../data/FOME_CAN_verbose.dbc';
const DbcViewer = () => {
const [dbcData, setDbcData] = useState<DbcData>(null);
useEffect(() => {
const dbc = new Dbc();
dbcReader(new File([fomeDbcFileRaw], 'file.dbc'), (content) => {
const data = dbc.load(content);
setDbcData(data);
});
}, []);
if (!dbcData) {
return <span>Loading</span>;
}
return (
<div>
{Array.from(dbcData.messages.values())
.sort((a, b) => Number(a.id) - Number(b.id))
.map((message) => (
<div key={message.id}>
<h3 id={`#${message.name}`}>Message {message.name}</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>CAN ID</th>
<th>DLC</th>
<th>Sending Node</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>{message.name}</td>
<td>{message.id}</td>
<td>{message.dlc}</td>
<td>{message.sendingNode}</td>
<td>{message.description}</td>
</tr>
</tbody>
</table>
<h4>Signals</h4>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Format</th>
<th>Start</th>
<th>Length</th>
<th>Factor</th>
<th>Offset</th>
<th>Min</th>
<th>Max</th>
<th>Unit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{Array.from(message.signals.values()).map((signal) => (
<tr key={`${signal.name}-${signal.startBit}`}>
<td>{signal.name}</td>
<td>{signal.dataType}</td>
<td>{signal.endian}</td>
<td>{signal.startBit}</td>
<td>{signal.length}</td>
<td>{signal.factor}</td>
<td>{signal.offset}</td>
<td>{signal.min}</td>
<td>{signal.max}</td>
<td>{signal.unit}</td>
<td>{signal.description}</td>
</tr>
))}
</tbody>
</table>
<hr />
</div>
))}
</div>
);
};
export default DbcViewer;

View File

@ -0,0 +1,170 @@
VERSION "HIPBNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY/4/%%%/4/'%**4YYY///"
NS_ :
NS_DESC_
CM_
BA_DEF_
BA_
VAL_
CAT_DEF_
CAT_
FILTER
BA_DEF_DEF_
EV_DATA_
ENVVAR_DATA_
SGTYPE_
SGTYPE_VAL_
BA_DEF_SGTYPE_
BA_SGTYPE_
SIG_TYPE_REF_
VAL_TABLE_
SIG_GROUP_
SIG_VALTYPE_
SIGTYPE_VALTYPE_
BS_:
BU_:
BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX
SG_ AFR : 7|16@0+ (0.001,0) [0|0] "AFR" Vector__XXX
SG_ VVTPos : 24|16@1- (0.02,0) [0|0] "deg" Vector__XXX
SG_ NewSignal_0010 : 24|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ NewSignal_0009 : 16|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ NewSignal_0008 : 8|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ NewSignal_0015 : 8|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ NewSignal_0016 : 16|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ NewSignal_0024 : 0|8@1+ (1,0) [0|0] "" Vector__XXX
BO_ 512 BASE0: 8 Vector__XXX
SG_ WarningCounter : 0|16@1+ (1,0) [0|0] "" Vector__XXX
SG_ LastError : 16|16@1+ (1,0) [0|0] "" Vector__XXX
SG_ RevLimAct : 32|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ MainRelayAct : 33|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ FuelPumpAct : 34|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ CELAct : 35|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ EGOHeatAct : 36|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ LambdaProtectAct : 37|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ CurrentGear : 40|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ DistanceTraveled : 48|16@1+ (0.1,0) [0|6553.5] "km" Vector__XXX
SG_ Fan : 38|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ Fan2 : 39|1@1+ (1,0) [0|0] "" Vector__XXX
BO_ 513 BASE1: 8 Vector__XXX
SG_ RPM : 0|16@1+ (1,0) [0|0] "RPM" Vector__XXX
SG_ IgnitionTiming : 16|16@1- (0.02,0) [0|0] "deg" Vector__XXX
SG_ InjDuty : 32|8@1+ (0.5,0) [0|100] "%" Vector__XXX
SG_ IgnDuty : 40|8@1+ (0.5,0) [0|100] "%" Vector__XXX
SG_ VehicleSpeed : 48|8@1+ (1,0) [0|255] "kph" Vector__XXX
SG_ FlexPct : 56|8@1+ (1,0) [0|100] "%" Vector__XXX
BO_ 514 BASE2: 8 Vector__XXX
SG_ PPS : 0|16@1- (0.01,0) [0|100] "%" Vector__XXX
SG_ TPS1 : 16|16@1- (0.01,0) [0|100] "%" Vector__XXX
SG_ TPS2 : 32|16@1- (0.01,0) [0|100] "%" Vector__XXX
SG_ Wastegate : 48|16@1- (0.01,0) [0|100] "%" Vector__XXX
BO_ 515 BASE3: 8 Vector__XXX
SG_ MAP : 0|16@1+ (0.03333333,0) [0|0] "kPa" Vector__XXX
SG_ CoolantTemp : 16|8@1+ (1,-40) [-40|200] "deg C" Vector__XXX
SG_ IntakeTemp : 24|8@1+ (1,-40) [-40|200] "deg C" Vector__XXX
SG_ AUX1Temp : 32|8@1+ (1,-40) [-40|200] "deg C" Vector__XXX
SG_ AUX2Temp : 40|8@1+ (1,-40) [-40|200] "deg C" Vector__XXX
SG_ MCUTemp : 48|8@1+ (1,-40) [-40|100] "deg C" Vector__XXX
SG_ FuelLevel : 56|8@1+ (0.5,0) [0|0] "%" Vector__XXX
BO_ 516 BASE4: 8 Vector__XXX
SG_ OilPress : 16|16@1+ (0.03333333,0) [0|0] "kPa" Vector__XXX
SG_ OilTemperature : 32|8@1+ (1,-40) [-40|215] "deg C" Vector__XXX
SG_ FuelTemperature : 40|8@1+ (1,-40) [-40|215] "deg C" Vector__XXX
SG_ BattVolt : 48|16@1+ (0.001,0) [0|25] "mV" Vector__XXX
BO_ 517 BASE5: 8 Vector__XXX
SG_ CylAM : 0|16@1+ (1,0) [0|0] "mg" Vector__XXX
SG_ EstMAF : 16|16@1+ (0.01,0) [0|0] "kg/h" Vector__XXX
SG_ InjPW : 32|16@1+ (0.003333333,0) [0|0] "ms" Vector__XXX
SG_ KnockCt : 48|16@1+ (1,0) [0|0] "count" Vector__XXX
BO_ 518 BASE6: 8 Vector__XXX
SG_ FuelUsed : 0|16@1+ (1,0) [0|0] "g" Vector__XXX
SG_ FuelFlow : 16|16@1+ (0.005,0) [0|327] "g/s" Vector__XXX
SG_ FuelTrim1 : 32|16@1+ (0.01,0) [-50|50] "%" Vector__XXX
SG_ FuelTrim2 : 48|16@1+ (0.01,0) [-50|50] "%" Vector__XXX
BO_ 519 BASE7: 8 Vector__XXX
SG_ Lam1 : 0|16@1+ (0.0001,0) [0|2] "lambda" Vector__XXX
SG_ Lam2 : 16|16@1+ (0.0001,0) [0|2] "lambda" Vector__XXX
SG_ FpLow : 32|16@1+ (0.03333333,0) [0|0] "kPa" Vector__XXX
SG_ FpHigh : 48|16@1+ (0.1,0) [0|0] "bar" Vector__XXX
BO_ 520 BASE8: 8 Vector__XXX
SG_ Cam1I : 0|8@1- (1,0) [-100|100] "deg" Vector__XXX
SG_ Cam1Itar : 8|8@1- (1,0) [-100|100] "deg" Vector__XXX
SG_ Cam1E : 16|8@1- (1,0) [-100|100] "deg" Vector__XXX
SG_ Cam1Etar : 24|8@1- (1,0) [-100|100] "deg" Vector__XXX
SG_ Cam2I : 32|8@1- (1,0) [-100|100] "deg" Vector__XXX
SG_ Cam2Itar : 40|8@1- (1,0) [-100|100] "deg" Vector__XXX
SG_ Cam2E : 48|8@1- (1,0) [-100|100] "deg" Vector__XXX
SG_ Cam2Etar : 56|8@1- (1,0) [-100|100] "deg" Vector__XXX
CM_ SG_ 3221225472 AFR "Current AFR Reading
";
CM_ SG_ 3221225472 VVTPos "Current VVT Position Reading";
CM_ SG_ 512 WarningCounter "Total warnings since ECU start time";
CM_ SG_ 512 LastError "Last error code";
CM_ SG_ 512 RevLimAct "RPM Limiter Active";
CM_ SG_ 512 MainRelayAct "Main Relay Active";
CM_ SG_ 512 FuelPumpAct "Fuel Pump Output Active";
CM_ SG_ 512 CELAct "Check Engine Light Active";
CM_ SG_ 512 EGOHeatAct "EGO Heater Commanded On";
CM_ SG_ 512 LambdaProtectAct "Lambda protection active (fault detected)";
CM_ SG_ 512 CurrentGear "Current detected gear. 0 means neutral, 1 means first, etc.";
CM_ SG_ 512 DistanceTraveled "Distance traveled since reset";
CM_ SG_ 513 RPM "Current RPM";
CM_ SG_ 513 IgnitionTiming "Current Ignition Timing. Positive is advance.";
CM_ SG_ 513 InjDuty "Injection Duty
";
CM_ SG_ 513 IgnDuty "Ignition Duty";
CM_ SG_ 513 VehicleSpeed "Current Vehicle Speed";
CM_ SG_ 513 FlexPct "Ethanol percent";
CM_ BO_ 514 "Throttle positions";
CM_ SG_ 514 PPS "Current Accelerator Pedal Position
";
CM_ SG_ 514 TPS1 "Throttle Body 1 Position";
CM_ SG_ 514 TPS2 "Throttle Body 2 Position";
CM_ SG_ 514 Wastegate "Wastegate actuator position";
CM_ SG_ 515 MAP "Current MAP Reading";
CM_ SG_ 515 CoolantTemp "Current Coolant Temperature Reading";
CM_ SG_ 515 IntakeTemp "Current Intake Air Temperature";
CM_ SG_ 515 AUX1Temp "Current Aux1 Temperature";
CM_ SG_ 515 AUX2Temp "Current Aux2 Temperature";
CM_ SG_ 515 MCUTemp "Current MCU Temperature";
CM_ SG_ 515 FuelLevel "Current Fuel Level";
CM_ SG_ 516 OilPress "Current Oil Pressure Reading";
CM_ SG_ 516 BattVolt "Current Battery Voltage Reading";
CM_ SG_ 517 CylAM "Current Estimated Cylinder Airmass";
CM_ SG_ 517 EstMAF "Current Estimated Total Airflow
";
CM_ SG_ 517 InjPW "Current Commanded Injector Pulsewidth";
CM_ SG_ 517 KnockCt "Knock detection counter";
CM_ SG_ 518 FuelUsed "Total fuel consumed";
CM_ SG_ 518 FuelFlow "Fuel flow rate";
CM_ SG_ 518 FuelTrim1 "Fuel trim bank 1";
CM_ SG_ 518 FuelTrim2 "Fuel trim bank 2";
CM_ BO_ 519 "Fueling";
CM_ SG_ 519 Lam1 "Lambda sensor 1";
CM_ SG_ 519 Lam2 "Lambda sensor 2";
CM_ SG_ 519 FpLow "Fuel pressure - low sensor";
CM_ SG_ 519 FpHigh "Fuel pressure - high (GDI) sensor";
CM_ BO_ 520 "Cams";
CM_ SG_ 520 Cam1I "Cam bank 1 intake actual";
CM_ SG_ 520 Cam1Itar "Cam bank 1 intake target";
CM_ SG_ 520 Cam1E "Cam bank 1 exhaust actual";
CM_ SG_ 520 Cam1Etar "Cam bank 1 exhaust target";
CM_ SG_ 520 Cam2I "Cam bank 2 intake actual";
CM_ SG_ 520 Cam2Itar "Cam bank 2 intake target";
CM_ SG_ 520 Cam2E "Cam bank 2 exhaust actual";
CM_ SG_ 520 Cam2Etar "Cam bank 2 exhaust target";