Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add read/write of voltaic modbus address #1102

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Meadow.Modbus;
using Meadow.Units;
using System;
using System.Threading.Tasks;

namespace Meadow.Foundation.Batteries.Voltaic;

Expand Down Expand Up @@ -133,4 +134,28 @@
// value is one register in 1/100 of a unit
return registers[0] / 100d;
}

/// <summary>
/// Reads the device's Modbus Address.
/// </summary>
/// <remarks>
/// The device can be discovered using an initial broadcast address of 254, then the actual sensor can be read using this method
/// </remarks>
public async Task<byte> ReadModbusAddress()
{
var registers = await base.ReadHoldingRegisters(9020, 1);
return (byte)registers[0];
}

/// <summary>
/// Reads the device's Modbus Address.
/// </summary>
/// <remarks>
/// The device can be discovered using an initial broadcast address of 254, then the actual sensor can be read using this method
/// </remarks>
public async Task WriteModbusAddress(byte address)
{
await base.WriteHoldingRegister(9020, address);
base.BusAddress = address;

Check failure on line 159 in Source/Meadow.Foundation.Peripherals/Batteries.Voltaic.V10x/Driver/V10x.cs

View workflow job for this annotation

GitHub Actions / build

'ModbusPolledDevice' does not contain a definition for 'BusAddress'

Check failure on line 159 in Source/Meadow.Foundation.Peripherals/Batteries.Voltaic.V10x/Driver/V10x.cs

View workflow job for this annotation

GitHub Actions / build

'ModbusPolledDevice' does not contain a definition for 'BusAddress'
}
}
Loading