-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from rnd-ash/dev
Version 0.2.0
- Loading branch information
Showing
39 changed files
with
3,332 additions
and
2,290 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Remote deploy code documentation | ||
|
||
on: | ||
push: | ||
branches: ["dev", "main"] | ||
|
||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
deploy_docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: | | ||
rustup set auto-self-update disable | ||
rustup toolchain install stable --profile minimal | ||
- run: | | ||
rustup set auto-self-update disable | ||
rustup toolchain install stable --profile minimal | ||
- uses: Swatinem/rust-cache@v2 | ||
- name: Install deps | ||
run: sudo apt-get update && sudo apt-get install -y binutils coreutils desktop-file-utils fakeroot fuse libgdk-pixbuf2.0-dev patchelf python3-pip python3-setuptools squashfs-tools strace util-linux zsync libgtk-3-dev | ||
- name: Cargo doc | ||
run: cargo doc | ||
- name: Deploy docs | ||
uses: appleboy/scp-action@v0.1.4 | ||
with: | ||
source: "target/doc/*" | ||
target: "/var/www/html/config_app/${{ env.BRANCH_NAME }}" | ||
username: ${{ secrets.USER }} | ||
host: ${{ secrets.HOST }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
rm: true | ||
|
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
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,21 +1,25 @@ | ||
[package] | ||
name = "backend" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
ecu_diagnostics="0.95.0" | ||
ecu_diagnostics="0.95.6" | ||
#ecu_diagnostics = { git = "https://github.com/rnd-ash/ecu_diagnostics", branch="diag_server_unified" } | ||
#ecu_diagnostics = { path = "../../ecu_diagnostics" } | ||
serial-rs = "0.2.1" | ||
packed_struct="0.10.0" | ||
static_assertions = "1.1.0" | ||
serde_yaml="0.9.21" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde-big-array = "0.5.1" | ||
serde_derive = "1.0.197" | ||
chrono="0.4.24" | ||
strum = "0.25.0" | ||
strum_macros = "0.25" | ||
strum = "0.26.2" | ||
strum_macros = "0.26.2" | ||
serde_json = "1.0.97" | ||
miette="5.10.0" | ||
miette="7.2.0" | ||
bitflags="2.4.0" | ||
flate2="1.0" |
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,121 @@ | ||
use std::collections::{BTreeMap, BTreeSet}; | ||
use packed_struct::derive::PackedStruct; | ||
use serde_big_array::BigArray; | ||
use serde_derive::{Serialize, Deserialize}; | ||
|
||
#[derive(PackedStruct, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] | ||
#[repr(C)] | ||
#[packed_struct(endian = "lsb")] | ||
pub struct EgsHydraulicConfiguration { | ||
pub multiplier_1: u16, | ||
pub multiplier_other: u16, | ||
pub lp_reg_pressure: u16, | ||
pub spc_overlap_circuit_factor: [u16; 8], | ||
pub mpc_overlap_circuit_factor: [u16; 8], | ||
pub spring_overlap_pressure: [i16; 8], | ||
pub shift_reg_pressure: u16, | ||
pub spc_gain_factor_shift: [u16; 8], | ||
pub min_mpc_pressure: u16, | ||
pub unk1: u8, | ||
pub unk2: u8, | ||
pub unk3: u16, | ||
pub unk4: u16, | ||
pub unk5: u16, | ||
pub shift_pressure_addr_percent: u16, | ||
pub inlet_pressure_offset: u16, | ||
pub inlet_pressure_input_min: u16, | ||
pub inlet_pressure_input_max: u16, | ||
pub inlet_pressure_output_min: u16, | ||
pub inlet_pressure_output_max: u16, | ||
pub extra_pressure_pump_speed_min: u16, | ||
pub extra_pressure_pump_speed_max: u16, | ||
pub extra_pressure_adder_r1_1: u16, | ||
pub extra_pressure_adder_other_gears: u16, | ||
pub shift_pressure_factor_percent: u16, | ||
pub pcs_map_x: [u16; 7], | ||
pub pcs_map_y: [u16; 4], | ||
#[serde(with = "BigArray")] | ||
pub pcs_map_z: [u16; 28] | ||
} | ||
|
||
#[derive(PackedStruct, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] | ||
#[repr(C)] | ||
#[packed_struct(endian = "lsb")] | ||
pub struct EgsMechanicalConfiguration { | ||
pub gb_ty: u8, | ||
pub ratio_table: [u16; 8], | ||
#[serde(alias="shift_something_unk1")] | ||
pub intertia_factor_table: [u16; 8], | ||
#[serde(with = "BigArray")] | ||
pub friction_map: [u16; 48], | ||
pub max_torque_on_clutch: [u16; 4], | ||
pub max_torque_off_clutch: [u16; 4], | ||
pub release_spring_pressure: [u16; 6], | ||
#[serde(alias="torque_byte_unk2")] | ||
pub intertia_torque: [u16; 8], | ||
pub strongest_loaded_clutch_idx: [u8; 8], | ||
pub unk3: [u16; 8], | ||
pub atf_density_minus_50c: u16, | ||
pub atf_density_drop_per_c: u16, | ||
pub atf_density_centrifugal_force_factor: [u16; 3] | ||
} | ||
|
||
#[derive(PackedStruct, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] | ||
#[repr(C)] | ||
#[packed_struct(endian = "lsb")] | ||
pub struct EgsTorqueConverterConfiguration { | ||
pub loss_map_x: [u16; 2], | ||
pub loss_map_z: [u16; 2], | ||
pub pump_map_x: [u16; 11], | ||
pub pump_map_z: [u16; 11] | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct CalibrationRecord<T> | ||
where T: PartialEq + Eq + PartialOrd + Ord { | ||
pub name: String, | ||
pub data: T, | ||
pub valid_egs_pns: Vec<String> | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct ChassisConfig { | ||
pub gearbox: String, | ||
pub chassis: String, | ||
pub hydr_cfg: String, | ||
pub mech_cfg: String, | ||
pub tcc_cfg: String | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct EgsData { | ||
pub pn: String, | ||
pub chassis: Vec<ChassisConfig> | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct CalibrationDatabase { | ||
pub egs_list: Vec<EgsData>, | ||
pub hydralic_calibrations: Vec<CalibrationRecord<EgsHydraulicConfiguration>>, | ||
pub mechanical_calibrations: Vec<CalibrationRecord<EgsMechanicalConfiguration>>, | ||
pub torqueconverter_calibrations: Vec<CalibrationRecord<EgsTorqueConverterConfiguration>> | ||
} | ||
|
||
// On the TCU itself (At address 0x34900) | ||
#[derive(PackedStruct, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] | ||
#[repr(C)] | ||
#[packed_struct(endian = "lsb")] | ||
pub struct EgsStoredCalibration { | ||
pub magic: u32, | ||
pub len: u16, | ||
pub crc: u16, | ||
pub tcc_cal_name: [u8;16], | ||
#[packed_field(element_size_bytes="52")] | ||
pub tcc_cal: EgsTorqueConverterConfiguration, | ||
pub mech_cal_name: [u8;16], | ||
#[packed_field(element_size_bytes="207")] | ||
pub mech_cal: EgsMechanicalConfiguration, | ||
pub hydr_cal_name: [u8;16], | ||
#[packed_field(element_size_bytes="182")] | ||
pub hydr_cal: EgsHydraulicConfiguration | ||
} |
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,65 @@ | ||
use bitflags::{bitflags}; | ||
use ecu_diagnostics::{DiagServerResult, DiagError, kwp2000::KwpSessionType, dynamic_diag::DiagSessionMode}; | ||
|
||
use super::Nag52Diag; | ||
|
||
bitflags! { | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct TcuDeviceMode: u16 { | ||
const NORMAL = 1 << 0; | ||
// Bit 1 ? | ||
const ROLLER = 1 << 2; | ||
const SLAVE = 1 << 3; | ||
const TEMPORARY_ERROR = 1 << 4; | ||
// Bit 5? | ||
const ERROR = 1 << 6; | ||
const NO_CALIBRATION = 1 << 7; | ||
// Bit 8? | ||
// Bit 9? | ||
// Bit 10? | ||
// Bit 11? | ||
// Bit 12? | ||
// Bit 13? | ||
// Bit 14? | ||
const CANLOGGER = 1 << 15; | ||
} | ||
} | ||
|
||
impl Nag52Diag { | ||
pub fn read_device_mode(&self) -> DiagServerResult<TcuDeviceMode> { | ||
let res = self.with_kwp(|kwp| { | ||
kwp.kwp_set_session(KwpSessionType::ExtendedDiagnostics.into())?; | ||
kwp.send_byte_array_with_response(&[0x30, 0x10, 0x01]) | ||
})?; | ||
if res.len() != 5 { | ||
Err(DiagError::InvalidResponseLength) | ||
} else { | ||
let x: u16 = u16::from_be_bytes(res[3..].try_into().unwrap()); | ||
//self.set_device_mode(TcuDeviceMode::SLAVE, true)?; | ||
//Ok(TcuDeviceMode::NORMAL) | ||
Ok(TcuDeviceMode::from_bits_retain(x)) | ||
} | ||
} | ||
|
||
pub fn set_device_mode(&self, mode: TcuDeviceMode, store_in_eeprom: bool) -> DiagServerResult<()> { | ||
let _ = self.with_kwp(|kwp| { | ||
let x = mode.bits(); | ||
kwp.kwp_set_session(KwpSessionType::ExtendedDiagnostics.into())?; | ||
kwp.send_byte_array_with_response(&[ | ||
0x30, | ||
0x10, | ||
if store_in_eeprom {0x08} else {0x07}, | ||
((x >> 8) & 0xFF) as u8, | ||
((x >> 0) & 0xFF) as u8 | ||
]) | ||
})?; | ||
Ok(()) | ||
} | ||
|
||
pub fn return_mode_control_to_ecu(&self) -> DiagServerResult<()> { | ||
let _ = self.with_kwp(|kwp| { | ||
kwp.send_byte_array_with_response(&[0x30, 0x10, 0x00]) | ||
})?; | ||
Ok(()) | ||
} | ||
} |
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
Oops, something went wrong.