forked from FOME-Tech/wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
376 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
import DbcViewer from '@site/src/components/DbcViewer'; | ||
|
||
# CAN | ||
|
||
## What is CANBUS? | ||
## What is CAN and CANBUS? | ||
|
||
**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. | ||
|
||
**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) | ||
|
||
CANBUS is a communication protocol that allows devices to talk to each other. | ||
::: | ||
|
||
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. | ||
<DbcViewer /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare module '*.txt'; | ||
declare module '*.html'; | ||
declare module '*.dbc'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
Oops, something went wrong.