Skip to content

Commit

Permalink
Merge pull request #19 from WildernessLabs/bugfix
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
adrianstevens authored Nov 19, 2024
2 parents a0bff0e + 8d8cb30 commit 76e7345
Show file tree
Hide file tree
Showing 7 changed files with 238 additions and 169 deletions.
Binary file added Source/Devices/MBM55R4 Data Sheet.pdf
Binary file not shown.
7 changes: 3 additions & 4 deletions Source/Driver/MBusSerialServer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Meadow.Hardware;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;

Expand Down Expand Up @@ -112,7 +111,7 @@ public byte[] WriteTelegram(ITelegram frame)
Port.ReadTimeout = TimeSpan.FromSeconds(1);
}

Debug.WriteLine($"TX-Buffer:\r\n{BitConverter.ToString(frameData)}");
Resolver.Log.Debug($"TX-Buffer:\r\n{BitConverter.ToString(frameData)}");
Port.Write(frameData);

// wait for ack
Expand All @@ -123,7 +122,7 @@ public byte[] WriteTelegram(ITelegram frame)

var read = Port.Read(_rxBuffer, 0, _rxBuffer.Length);

Debug.WriteLine($"Read: {read}");
Resolver.Log.Debug($"Read: {read}");

if (read == 0)
{
Expand All @@ -139,7 +138,7 @@ public byte[] WriteTelegram(ITelegram frame)

var data = new byte[read];
Array.Copy(_rxBuffer, data, read);
Debug.WriteLine($"RX-Buffer:\r\n{BitConverter.ToString(data)}");
Resolver.Log.Debug($"RX-Buffer:\r\n{BitConverter.ToString(data)}");
return data;

}
Expand Down
2 changes: 1 addition & 1 deletion Source/Driver/Meadow.MBus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ItemGroup>
<None Include=".\Readme.md" Pack="true" PackagePath="" />
<None Include="..\icon.png" Link="icon.png" Pack="true" PackagePath="" />
<ProjectReference Include="..\..\..\Meadow.Core\source\Meadow.Core\Meadow.Core.csproj" />
<PackageReference Include="Meadow" Version="1.12.8" />
</ItemGroup>

</Project>
326 changes: 163 additions & 163 deletions Source/MBus.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Meadow.Core\source\implementations\windows\Meadow.Windows\Meadow.Windows.csproj" />
<PackageReference Include="Meadow.Windows" Version="1.12.8" />
<ProjectReference Include="..\..\Devices\SchneiderElectric\IEM3135\Driver\IEM3135.csproj" />
<ProjectReference Include="..\..\Driver\Meadow.MBus.csproj" />
</ItemGroup>
Expand Down
17 changes: 17 additions & 0 deletions Source/Samples/MBus_Feather_Sample/MBus_Feather_Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.Foundation</RepositoryUrl>
<Company>Wilderness Labs, Inc</Company>
<Authors>Wilderness Labs, Inc</Authors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Meadow.Core\source\implementations\f7\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\Devices\RelayMBus\PadPulsM2\Driver\PadPulsM2.csproj" />
<ProjectReference Include="..\..\Driver\Meadow.MBus.csproj" />
</ItemGroup>
</Project>
53 changes: 53 additions & 0 deletions Source/Samples/MBus_Feather_Sample/MeadowApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Meadow.Devices;
using Meadow.Foundation.MBus.RelayMBus;
using Meadow.Hardware;
using System.Threading.Tasks;

namespace Meadow.Foundation.MBus.MBus_Feather_Sample;


public class MBM55R : MBusSerialServer
{
public MBM55R(ISerialPort port)
: base(port)
{
port.BaudRate = 9600;
port.Parity = Parity.Even;
port.Open();
}
}

public class MeadowApp : App<F7FeatherV2>
{
//<!=SNIP=>
private PadPulsM2 pulseCounter;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

var port = Device.PlatformOS.GetSerialPortName("com1").CreateSerialPort(9600, parity: Parity.Even);

var mbm = new MBM55R(port);
pulseCounter = new PadPulsM2(mbm);
pulseCounter.StartMonitoring();

Resolver.Log.Info($"Counter ports: {pulseCounter.Ports[0].ID} {pulseCounter.Ports[1].ID}");

return base.Initialize();
}

public override async Task Run()
{
Resolver.Log.Info("Run");

while (true)
{
Resolver.Log.Info($"now: {pulseCounter.Ports[0].CurrentDateTime}");
await Task.Delay(2000);
}

}

//<!=SNOP=>
}

0 comments on commit 76e7345

Please sign in to comment.