fix for actually working

This commit is contained in:
Alex Janka 2022-09-04 17:54:32 +10:00
parent afe4885c4c
commit 0c0178b316
2 changed files with 31 additions and 31 deletions

View file

@ -8,7 +8,7 @@ use crate::offsets::{OffsetsEeprom, OffsetsRam};
const DEVICE_ID: u8 = 0x01;
const RAM_DATA_SIZE: u16 = 0x005B;
const EEPROM_BEGIN: u16 = 0xE000;
const EEPROM_DATA_SIZE: u16 = 0xE021 - EEPROM_BEGIN;
const EEPROM_DATA_SIZE: u16 = 0x0021;
// const EEPROM_DATA_SIZE: u16 = 0xE0CD - EEPROM_BEGIN;
#[derive(Serialize, Deserialize, Debug)]
@ -104,7 +104,7 @@ struct MpptEeprom {
ETb_max: u16,
ETb_min: u16,
EV_soc_g_gy: f32,
EV_soc_gy_g: f32,
EV_soc_gy_y: f32,
EV_soc_y_yr: f32,
EV_soc_yr_r: f32,
Emodbus_id: u16,
@ -266,7 +266,7 @@ fn main() {
ETb_max: data_in[OffsetsEeprom::ETb_max],
ETb_min: data_in[OffsetsEeprom::ETb_min],
EV_soc_g_gy: info.scale_voltage(&data_in[OffsetsEeprom::EV_soc_g_gy]),
EV_soc_gy_g: info.scale_voltage(&data_in[OffsetsEeprom::EV_soc_gy_g]),
EV_soc_gy_y: info.scale_voltage(&data_in[OffsetsEeprom::EV_soc_gy_y]),
EV_soc_y_yr: info.scale_voltage(&data_in[OffsetsEeprom::EV_soc_y_yr]),
EV_soc_yr_r: info.scale_voltage(&data_in[OffsetsEeprom::EV_soc_yr_r]),
Emodbus_id: data_in[OffsetsEeprom::Emodbus_id],
@ -282,6 +282,6 @@ fn main() {
let value = 50.;
let value_scaled = ((value / info.v_scale) / f32::powf(2., -15.)) as u16;
// modbus
// .write_register(OffsetsEeprom::EV_soc_g_gy as u16, value_scaled)
// .write_register(EEPROM_BEGIN as u16 + OffsetsEeprom::EV_soc_g_gy as u16, value_scaled)
// .expect("could not set value");
}

View file

@ -76,31 +76,31 @@ impl OffsetsRam {
pub struct OffsetsEeprom {}
impl OffsetsEeprom {
pub const EV_absorp: usize = 0xE000;
pub const EV_float: usize = 0xE001;
pub const Et_absorp: usize = 0xE002;
pub const Et_absorp_ext: usize = 0xE003;
pub const EV_absorp_ext: usize = 0xE004;
pub const EV_float_cancel: usize = 0xE005;
pub const Et_float_exit_cum: usize = 0xE006;
pub const EV_eq: usize = 0xE007;
pub const Et_eqcalendar: usize = 0xE008;
pub const Et_eq_above: usize = 0xE009;
pub const Et_eq_reg: usize = 0xE00A;
pub const Et_batt_service: usize = 0xE00B;
pub const EV_tempcomp: usize = 0xE00D;
pub const EV_hvd: usize = 0xE00E;
pub const EV_hvr: usize = 0xE00F;
pub const Evb_ref_lim: usize = 0xE010;
pub const ETb_max: usize = 0xE011;
pub const ETb_min: usize = 0xE012;
pub const EV_soc_g_gy: usize = 0xE015;
pub const EV_soc_gy_g: usize = 0xE016;
pub const EV_soc_y_yr: usize = 0xE017;
pub const EV_soc_yr_r: usize = 0xE018;
pub const Emodbus_id: usize = 0xE019;
pub const Emeterbus_id: usize = 0xE01A;
pub const EIb_lim: usize = 0xE01D;
pub const EVa_ref_fixed_init: usize = 0xE020;
pub const EVa_ref_fixed_pct_init: usize = 0xE021;
pub const EV_absorp: usize = 0x0000;
pub const EV_float: usize = 0x0001;
pub const Et_absorp: usize = 0x0002;
pub const Et_absorp_ext: usize = 0x0003;
pub const EV_absorp_ext: usize = 0x0004;
pub const EV_float_cancel: usize = 0x0005;
pub const Et_float_exit_cum: usize = 0x0006;
pub const EV_eq: usize = 0x0007;
pub const Et_eqcalendar: usize = 0x0008;
pub const Et_eq_above: usize = 0x0009;
pub const Et_eq_reg: usize = 0x000A;
pub const Et_batt_service: usize = 0x000B;
pub const EV_tempcomp: usize = 0x000D;
pub const EV_hvd: usize = 0x000E;
pub const EV_hvr: usize = 0x000F;
pub const Evb_ref_lim: usize = 0x0010;
pub const ETb_max: usize = 0x0011;
pub const ETb_min: usize = 0x0012;
pub const EV_soc_g_gy: usize = 0x0015;
pub const EV_soc_gy_y: usize = 0x0016;
pub const EV_soc_y_yr: usize = 0x0017;
pub const EV_soc_yr_r: usize = 0x0018;
pub const Emodbus_id: usize = 0x0019;
pub const Emeterbus_id: usize = 0x001A;
pub const EIb_lim: usize = 0x001D;
pub const EVa_ref_fixed_init: usize = 0x0020;
pub const EVa_ref_fixed_pct_init: usize = 0x0021;
}