Skip to content

Commit

Permalink
Merge pull request #1102 from WildernessLabs/feature/voltaic-address
Browse files Browse the repository at this point in the history
add read/write of voltaic modbus address
  • Loading branch information
adrianstevens authored Dec 27, 2024
2 parents 24d81ad + 7b15813 commit eaf9d4a
Showing 1 changed file with 25 additions and 0 deletions.
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 @@ private object ConvertRegisterToRawValue(ushort[] registers)
// 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'
}
}

0 comments on commit eaf9d4a

Please sign in to comment.