Skip to content

Commit

Permalink
Updated build files
Browse files Browse the repository at this point in the history
  • Loading branch information
bytewizer committed Oct 31, 2021
1 parent a11ebab commit 7341c3f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Bytewizer.TinyCLR.Drivers.Blues.Notecard.Diagnostics.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@

namespace Bytewizer.TinyCLR.Drivers.Blues.Notecard.Diagnostics
{
/// <summary>
/// Configures the <see cref="NotecardLogger"/> to use the serial interface for communication with the host.
/// </summary>
public sealed class NotecardLogger : IDisposable
{
private readonly GpioPin enablePin;
private readonly UartController uartController;
private readonly GpioController gpioController;

/// <summary>
/// Initializes a default instance of the <see cref="NotecardLogger"/> class.
/// </summary>
/// <param name="uartController">The uart controller to use.</param>
/// <param name="enablePin">The gpio pin to use enable the serial interface.</param>
public NotecardLogger(UartController uartController, int enablePin)
: this(uartController, new UartSetting()
{
Expand All @@ -21,9 +29,14 @@ public NotecardLogger(UartController uartController, int enablePin)
StopBits = UartStopBitCount.One,
Handshaking = UartHandshake.None
}, enablePin)
{
}

{ }

/// <summary>
/// Initializes a new instance of the <see cref="NotecardLogger"/> class.
/// </summary>
/// <param name="uartController">The uart controller to use.</param>
/// <param name="uartSettings">The uart controller settings to use.</param>
/// <param name="enablePin">The gpio pin to use enable the serial interface.</param>
public NotecardLogger(UartController uartController, UartSetting uartSettings, int enablePin)
{
this.uartController = uartController;
Expand All @@ -38,10 +51,19 @@ public NotecardLogger(UartController uartController, UartSetting uartSettings, i
this.enablePin.Write(GpioPinValue.High);
}

/// <summary>
/// Enable the notecard debug interface.
/// </summary>
public void Enable() => this.enablePin.Write(GpioPinValue.High);

/// <summary>
/// Disable the notecard debug interface.
/// </summary>
public void Disable() => this.enablePin.Write(GpioPinValue.Low);

/// <summary>
/// Enable debug message logging.
/// </summary>
public void TraceOn()
{
Enable();
Expand All @@ -50,6 +72,9 @@ public void TraceOn()
this.uartController.Write(writeBuffer);
}

/// <summary>
/// Disable degug message logging.
/// </summary>
public void TraceOff()
{
var writeBuffer = Encoding.UTF8.GetBytes("{\"req\":\"card.trace\",\"mode\":\"off\"}\n");
Expand All @@ -58,14 +83,26 @@ public void TraceOff()
Disable();
}

/// <summary>
/// Pro-actively frees resources owned by this instance.
/// </summary>
public void Dispose()
{
this.enablePin.Dispose();
this.uartController.Dispose();
this.gpioController.Dispose();
}


/// <summary>
/// An event that is raised when a message is available.
/// </summary>
public event MessageAvailableEventHandler MessageAvailable;


/// <summary>
/// An event that is raised when a message is available.
/// </summary>
public delegate void MessageAvailableEventHandler(string message);

private string TempData { set; get; } = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Bytewizer.TinyCLR.Drivers.Blues.Notecard.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down

0 comments on commit 7341c3f

Please sign in to comment.