pub struct SDM72;tokio-rtu or tokio-tcp only.Expand description
An asynchronous client for the SDM72 energy meter.
This struct provides a high-level interface for interacting with the SDM72
energy meter. It uses an asynchronous tokio-modbus context for communication.
An instance of this client can be created using the new method.
Implementations§
Source§impl SDM72
impl SDM72
Sourcepub async fn system_type(ctx: &mut Context) -> Result<SystemType, Error>
pub async fn system_type(ctx: &mut Context) -> Result<SystemType, Error>
Reads the proto::SystemType value from the Modbus holding register.
Sourcepub async fn set_system_type(
ctx: &mut Context,
value: SystemType,
) -> Result<(), Error>
pub async fn set_system_type( ctx: &mut Context, value: SystemType, ) -> Result<(), Error>
Writes the proto::SystemType value to the Modbus holding register.
Sourcepub async fn pulse_width(ctx: &mut Context) -> Result<PulseWidth, Error>
pub async fn pulse_width(ctx: &mut Context) -> Result<PulseWidth, Error>
Reads the proto::PulseWidth value from the Modbus holding register.
Sourcepub async fn set_pulse_width(
ctx: &mut Context,
value: PulseWidth,
) -> Result<(), Error>
pub async fn set_pulse_width( ctx: &mut Context, value: PulseWidth, ) -> Result<(), Error>
Writes the proto::PulseWidth value to the Modbus holding register.
Sourcepub async fn kppa(ctx: &mut Context) -> Result<KPPA, Error>
pub async fn kppa(ctx: &mut Context) -> Result<KPPA, Error>
Reads the proto::KPPA value from the Modbus holding register.
Sourcepub async fn set_kppa(
ctx: &mut Context,
password: Password,
) -> Result<(), Error>
pub async fn set_kppa( ctx: &mut Context, password: Password, ) -> Result<(), Error>
Sets the Key Parameter Programming Authorization (KPPA).
This is required to change settings on the meter.
Sourcepub async fn parity_and_stop_bit(
ctx: &mut Context,
) -> Result<ParityAndStopBit, Error>
pub async fn parity_and_stop_bit( ctx: &mut Context, ) -> Result<ParityAndStopBit, Error>
Reads the proto::ParityAndStopBit value from the Modbus holding register.
Sourcepub async fn set_parity_and_stop_bit(
ctx: &mut Context,
value: ParityAndStopBit,
) -> Result<(), Error>
pub async fn set_parity_and_stop_bit( ctx: &mut Context, value: ParityAndStopBit, ) -> Result<(), Error>
Writes the proto::ParityAndStopBit value to the Modbus holding register.
Sourcepub async fn address(ctx: &mut Context) -> Result<Address, Error>
pub async fn address(ctx: &mut Context) -> Result<Address, Error>
Reads the proto::Address value from the Modbus holding register.
Sourcepub async fn set_address(ctx: &mut Context, value: Address) -> Result<(), Error>
pub async fn set_address(ctx: &mut Context, value: Address) -> Result<(), Error>
Writes the proto::Address value to the Modbus holding register.
Sourcepub async fn pulse_constant(ctx: &mut Context) -> Result<PulseConstant, Error>
pub async fn pulse_constant(ctx: &mut Context) -> Result<PulseConstant, Error>
Reads the proto::PulseConstant value from the Modbus holding register.
Sourcepub async fn set_pulse_constant(
ctx: &mut Context,
value: PulseConstant,
) -> Result<(), Error>
pub async fn set_pulse_constant( ctx: &mut Context, value: PulseConstant, ) -> Result<(), Error>
Writes the proto::PulseConstant value to the Modbus holding register.
Sourcepub async fn password(ctx: &mut Context) -> Result<Password, Error>
pub async fn password(ctx: &mut Context) -> Result<Password, Error>
Reads the proto::Password value from the Modbus holding register.
Sourcepub async fn set_password(
ctx: &mut Context,
value: Password,
) -> Result<(), Error>
pub async fn set_password( ctx: &mut Context, value: Password, ) -> Result<(), Error>
Writes the proto::Password value to the Modbus holding register.
Sourcepub async fn baud_rate(ctx: &mut Context) -> Result<BaudRate, Error>
pub async fn baud_rate(ctx: &mut Context) -> Result<BaudRate, Error>
Reads the proto::BaudRate value from the Modbus holding register.
Sourcepub async fn set_baud_rate(
ctx: &mut Context,
value: BaudRate,
) -> Result<(), Error>
pub async fn set_baud_rate( ctx: &mut Context, value: BaudRate, ) -> Result<(), Error>
Writes the proto::BaudRate value to the Modbus holding register.
Sourcepub async fn auto_scroll_time(
ctx: &mut Context,
) -> Result<AutoScrollTime, Error>
pub async fn auto_scroll_time( ctx: &mut Context, ) -> Result<AutoScrollTime, Error>
Reads the proto::AutoScrollTime value from the Modbus holding register.
Sourcepub async fn set_auto_scroll_time(
ctx: &mut Context,
value: AutoScrollTime,
) -> Result<(), Error>
pub async fn set_auto_scroll_time( ctx: &mut Context, value: AutoScrollTime, ) -> Result<(), Error>
Writes the proto::AutoScrollTime value to the Modbus holding register.
Sourcepub async fn backlight_time(ctx: &mut Context) -> Result<BacklightTime, Error>
pub async fn backlight_time(ctx: &mut Context) -> Result<BacklightTime, Error>
Reads the proto::BacklightTime value from the Modbus holding register.
Sourcepub async fn set_backlight_time(
ctx: &mut Context,
value: BacklightTime,
) -> Result<(), Error>
pub async fn set_backlight_time( ctx: &mut Context, value: BacklightTime, ) -> Result<(), Error>
Writes the proto::BacklightTime value to the Modbus holding register.
Sourcepub async fn pulse_energy_type(
ctx: &mut Context,
) -> Result<PulseEnergyType, Error>
pub async fn pulse_energy_type( ctx: &mut Context, ) -> Result<PulseEnergyType, Error>
Reads the proto::PulseEnergyType value from the Modbus holding register.
Sourcepub async fn set_pulse_energy_type(
ctx: &mut Context,
value: PulseEnergyType,
) -> Result<(), Error>
pub async fn set_pulse_energy_type( ctx: &mut Context, value: PulseEnergyType, ) -> Result<(), Error>
Writes the proto::PulseEnergyType value to the Modbus holding register.
Sourcepub async fn reset_historical_data(ctx: &mut Context) -> Result<(), Error>
pub async fn reset_historical_data(ctx: &mut Context) -> Result<(), Error>
Resets the historical data on the meter.
This requires KPPA authorization.
Sourcepub async fn serial_number(ctx: &mut Context) -> Result<SerialNumber, Error>
pub async fn serial_number(ctx: &mut Context) -> Result<SerialNumber, Error>
Reads the proto::SerialNumber value from the Modbus holding register.
Sourcepub async fn meter_code(ctx: &mut Context) -> Result<MeterCode, Error>
pub async fn meter_code(ctx: &mut Context) -> Result<MeterCode, Error>
Reads the proto::MeterCode value from the Modbus holding register.
Sourcepub async fn software_version(
ctx: &mut Context,
) -> Result<SoftwareVersion, Error>
pub async fn software_version( ctx: &mut Context, ) -> Result<SoftwareVersion, Error>
Reads the proto::SoftwareVersion value from the Modbus holding register.
Sourcepub async fn read_all_settings(
ctx: &mut Context,
delay: &Duration,
) -> Result<AllSettings, Error>
pub async fn read_all_settings( ctx: &mut Context, delay: &Duration, ) -> Result<AllSettings, Error>
Reads all settings from the meter in a single batch operation.
This method is more efficient than reading each setting individually because it minimizes the number of Modbus requests by batching them. The SDM72 meter has a limit of 30 parameters per request, so this function splits the reads into multiple batches.
§Arguments
delay- The delay to be inserted between Modbus requests. This is necessary for some Modbus devices, which may need a short pause to process a request before they are ready to accept the next one. A typical value is 100 milliseconds, but this may vary depending on the device and network conditions.
Sourcepub async fn read_all(
ctx: &mut Context,
delay: &Duration,
) -> Result<AllValues, Error>
pub async fn read_all( ctx: &mut Context, delay: &Duration, ) -> Result<AllValues, Error>
Reads all measurement values from the meter in a single batch operation.
This method is more efficient than reading each value individually because it minimizes the number of Modbus requests by batching them. The SDM72 meter has a limit of 30 parameters per request, so this function splits the reads into multiple batches.
§Arguments
delay- The delay to be inserted between Modbus requests. This is necessary for some Modbus devices, which may need a short pause to process a request before they are ready to accept the next one. A typical value is 100 milliseconds, but this may vary depending on the device and network conditions.