Skip to content

Commit

Permalink
Merge pull request #611 from WildernessLabs/xml_comments
Browse files Browse the repository at this point in the history
Add missing XML comments
  • Loading branch information
ctacke authored Jan 28, 2025
2 parents 35abe0d + 25e5f22 commit 6840f13
Show file tree
Hide file tree
Showing 9 changed files with 687 additions and 129 deletions.
10 changes: 8 additions & 2 deletions Source/implementations/mac/Meadow.Mac/Mac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@

namespace Meadow;

/// <summary>
/// Represents a Mac device running the Meadow OS.
/// </summary>
public class Mac : IMeadowDevice, IPixelDisplayProvider
{
private readonly Lazy<NativeNetworkAdapterCollection> _networkAdapters;

/// <inheritdoc/>
public IPlatformOS PlatformOS { get; }
/// <inheritdoc/>
public DeviceCapabilities Capabilities { get; private set; }
public DeviceCapabilities Capabilities { get; private set; } = default!;
/// <inheritdoc/>
public IDeviceInformation Information { get; private set; }
public IDeviceInformation Information { get; private set; } = default!;
/// <inheritdoc/>
public INetworkAdapterCollection NetworkAdapters => _networkAdapters.Value;

/// <summary>
/// Creates a new instance of the Mac class.
/// </summary>
public Mac()
{
PlatformOS = new MacPlatformOS();
Expand Down
90 changes: 46 additions & 44 deletions Source/implementations/mac/Meadow.Mac/MacDeviceInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,58 @@
using System;
using System.Diagnostics;

namespace Meadow
namespace Meadow;

/// <summary>
/// Represents information about the device running the application.
/// </summary>
public class MacDeviceInformation : IDeviceInformation
{
public class MacDeviceInformation : IDeviceInformation
{
/// <inheritdoc/>
public string DeviceName { get; set; }
/// <inheritdoc/>
public string Model { get; }
/// <inheritdoc/>
public MeadowPlatform Platform => MeadowPlatform.OSX;
/// <inheritdoc/>
public string ProcessorType { get; }
/// <inheritdoc/>
public string ProcessorSerialNumber => "Unknown";
/// <inheritdoc/>
public string UniqueID { get; }
/// <inheritdoc/>
public string CoprocessorType => "None";
/// <inheritdoc/>
public string? CoprocessorOSVersion => null;
/// <inheritdoc/>
public string OSVersion => Environment.OSVersion.ToString();
/// <inheritdoc/>
public string DeviceName { get; set; }
/// <inheritdoc/>
public string Model { get; }
/// <inheritdoc/>
public MeadowPlatform Platform => MeadowPlatform.OSX;
/// <inheritdoc/>
public string ProcessorType { get; }
/// <inheritdoc/>
public string ProcessorSerialNumber => "Unknown";
/// <inheritdoc/>
public string UniqueID { get; }
/// <inheritdoc/>
public string CoprocessorType => "None";
/// <inheritdoc/>
public string? CoprocessorOSVersion => null;
/// <inheritdoc/>
public string OSVersion => Environment.OSVersion.ToString();

internal MacDeviceInformation()
{
DeviceName = Environment.MachineName;
Model = $"{Environment.OSVersion.Platform} {Environment.OSVersion.Version.ToString(2)}";
var cpu = ExecuteBashCommandLine("sysctl -n machdep.cpu.brand_string");
ProcessorType = cpu.Trim();
var mac_id = ExecuteBashCommandLine("ioreg -l | grep IOPlatformSerialNumber | sed 's/.*= //' | sed 's/\\\"//g'");
UniqueID = mac_id.Trim();
// sysctl -n machdep.cpu.brand_string
}
internal MacDeviceInformation()
{
DeviceName = Environment.MachineName;
Model = $"{Environment.OSVersion.Platform} {Environment.OSVersion.Version.ToString(2)}";
var cpu = ExecuteBashCommandLine("sysctl -n machdep.cpu.brand_string");
ProcessorType = cpu.Trim();
var mac_id = ExecuteBashCommandLine("ioreg -l | grep IOPlatformSerialNumber | sed 's/.*= //' | sed 's/\\\"//g'");
UniqueID = mac_id.Trim();
// sysctl -n machdep.cpu.brand_string
}

private string ExecuteBashCommandLine(string command)
private string ExecuteBashCommandLine(string command)
{
var psi = new ProcessStartInfo()
{
var psi = new ProcessStartInfo()
{
FileName = "/bin/bash",
Arguments = $"-c \"{command}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
FileName = "/bin/bash",
Arguments = $"-c \"{command}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};

using var process = Process.Start(psi);
using var process = Process.Start(psi);

process?.WaitForExit();
process?.WaitForExit();

return process?.StandardOutput.ReadToEnd() ?? string.Empty;
}
return process?.StandardOutput.ReadToEnd() ?? string.Empty;
}
}
3 changes: 3 additions & 0 deletions Source/implementations/mac/Meadow.Mac/MacFileSystemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Meadow;

/// <summary>
/// Represents the file system information for the Mac platform
/// </summary>
public class MacFileSystemInfo : IPlatformOS.FileSystemInfo
{
/// <inheritdoc/>
Expand Down
Loading

0 comments on commit 6840f13

Please sign in to comment.