Skip to content

Commit

Permalink
Merge pull request #103 from K-Society/experimental
Browse files Browse the repository at this point in the history
Experimental
  • Loading branch information
maniglia authored Jan 15, 2024
2 parents f06bb2f + 28b330c commit fdfded3
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 90 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,29 @@ You can get KSociety.SharpCubeProgrammer by [grabbing the latest NuGet package](

- Register SharpCubeProgrammer as service with Autofac IoC:

Create the module for Autofac in a dedicated file (in this example under the Bindings folder) with the following contents:

```csharp
namespace MyNamespace.Bindings
{
using Autofac;
using KSociety.SharpCubeProgrammer;
using KSociety.SharpCubeProgrammer.Interface;

public class ProgrammerApi : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<CubeProgrammerApi>().As<ICubeProgrammerApi>().SingleInstance();
}
}
}
```

Register the module:

```csharp
builder.RegisterModule(new KSociety.SharpCubeProgrammer.Bindings.ProgrammerApi());
builder.RegisterModule(new Bindings.ProgrammerApi());
```

- Get ST-Link list and connect:
Expand Down Expand Up @@ -165,4 +186,5 @@ The project is under Microsoft Reciprocal License [(MS-RL)](http://www.opensourc

List of technologies, frameworks and libraries used for implementation:

- [KSociety.Wmi](https://github.com/K-Society/KSociety.Wmi) (WMI)
- [Microsoft.Bcl.AsyncInterfaces](https://www.nuget.org/packages/Microsoft.Bcl.AsyncInterfaces)
- [Microsoft.Extensions.Logging.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions)
26 changes: 24 additions & 2 deletions docs/KSociety.SharpCubeProgrammer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,29 @@ You can get KSociety.SharpCubeProgrammer by [grabbing the latest NuGet package](

- Register SharpCubeProgrammer as service with Autofac IoC:

Create the module for Autofac in a dedicated file (in this example under the Bindings folder) with the following contents:

```csharp
namespace MyNamespace.Bindings
{
using Autofac;
using KSociety.SharpCubeProgrammer;
using KSociety.SharpCubeProgrammer.Interface;

public class ProgrammerApi : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<CubeProgrammerApi>().As<ICubeProgrammerApi>().SingleInstance();
}
}
}
```

Register the module:

```csharp
builder.RegisterModule(new KSociety.SharpCubeProgrammer.Bindings.ProgrammerApi());
builder.RegisterModule(new Bindings.ProgrammerApi());
```

- Get ST-Link list and connect:
Expand Down Expand Up @@ -164,4 +185,5 @@ The project is under Microsoft Reciprocal License [(MS-RL)](http://www.opensourc

List of technologies, frameworks and libraries used for implementation:

- [KSociety.Wmi](https://github.com/K-Society/KSociety.Wmi) (WMI)
- [Microsoft.Bcl.AsyncInterfaces](https://www.nuget.org/packages/Microsoft.Bcl.AsyncInterfaces)
- [Microsoft.Extensions.Logging.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions)
22 changes: 11 additions & 11 deletions src/01/KSociety.SharpCubeProgrammer/Events/StLinkAddedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.
//// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.

namespace KSociety.SharpCubeProgrammer.Events
{
using System;
//namespace KSociety.SharpCubeProgrammer.Events
//{
// using System;

public class StLinkAddedEventArgs : EventArgs
{
public StLinkAddedEventArgs()
{
// public class StLinkAddedEventArgs : EventArgs
// {
// public StLinkAddedEventArgs()
// {

}
}
}
// }
// }
//}
22 changes: 11 additions & 11 deletions src/01/KSociety.SharpCubeProgrammer/Events/StLinkFoundEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.
//// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.

namespace KSociety.SharpCubeProgrammer.Events
{
using System;
//namespace KSociety.SharpCubeProgrammer.Events
//{
// using System;

public class StLinkFoundEventArgs : EventArgs
{
public StLinkFoundEventArgs()
{
// public class StLinkFoundEventArgs : EventArgs
// {
// public StLinkFoundEventArgs()
// {

}
}
}
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.
//// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.

namespace KSociety.SharpCubeProgrammer.Events
{
using System;
//namespace KSociety.SharpCubeProgrammer.Events
//{
// using System;

public class StLinkRemovedEventArgs : EventArgs
{
public StLinkRemovedEventArgs()
{
// public class StLinkRemovedEventArgs : EventArgs
// {
// public StLinkRemovedEventArgs()
// {

}
}
}
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.
//// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.

namespace KSociety.SharpCubeProgrammer.Events
{
using System;
//namespace KSociety.SharpCubeProgrammer.Events
//{
// using System;

public class Stm32BootLoaderAddedEventArgs : EventArgs
{
public Stm32BootLoaderAddedEventArgs()
{
// public class Stm32BootLoaderAddedEventArgs : EventArgs
// {
// public Stm32BootLoaderAddedEventArgs()
// {

}
}
}
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.
//// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.

namespace KSociety.SharpCubeProgrammer.Events
{
using System;
//namespace KSociety.SharpCubeProgrammer.Events
//{
// using System;

public class Stm32BootLoaderFoundEventArgs : EventArgs
{
public Stm32BootLoaderFoundEventArgs()
{
// public class Stm32BootLoaderFoundEventArgs : EventArgs
// {
// public Stm32BootLoaderFoundEventArgs()
// {

}
}
}
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.
//// Copyright © K-Society and contributors. All rights reserved. Licensed under the K-Society License. See LICENSE.TXT file in the project root for full license information.

namespace KSociety.SharpCubeProgrammer.Events
{
using System;
//namespace KSociety.SharpCubeProgrammer.Events
//{
// using System;

public class Stm32BootLoaderRemovedEventArgs : EventArgs
{
public Stm32BootLoaderRemovedEventArgs()
{
// public class Stm32BootLoaderRemovedEventArgs : EventArgs
// {
// public Stm32BootLoaderRemovedEventArgs()
// {

}
}
}
// }
// }
//}
20 changes: 0 additions & 20 deletions src/01/Samples/Programming/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Programming
using System.Text.RegularExpressions;
using Autofac;
using KSociety.SharpCubeProgrammer.Enum;
using KSociety.SharpCubeProgrammer.Events;
using KSociety.SharpCubeProgrammer.Interface;
using KSociety.SharpCubeProgrammer.Struct;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -36,9 +35,6 @@ private static void Main(string[] args)

CubeProgrammerApi = container.Resolve<ICubeProgrammerApi>();

//CubeProgrammerApi.StLinkAdded += CubeProgrammerApiOnStLinkAdded;
//CubeProgrammerApi.StLinkRemoved += CubeProgrammerApiOnStLinkRemoved;
//CubeProgrammerApi.StLinksFoundStatus += CubeProgrammerApiOnStLinksFoundStatus;
Console.WriteLine("Press a button to continue.");
Console.ReadLine();
//var testStLink = CubeProgrammerApi.TryConnectStLink(0, 0, DebugConnectionMode.UnderResetMode);
Expand Down Expand Up @@ -233,26 +229,10 @@ private static void Main(string[] args)

}

//private static void CubeProgrammerApiOnStLinksFoundStatus(object? sender, StLinkFoundEventArgs e)
//{
// Logger?.LogInformation("StLinksFound...");
//}

//private static void CubeProgrammerApiOnStLinkRemoved(object? sender, StLinkRemovedEventArgs e)
//{
// Logger?.LogInformation("StLinkRemoved...");
//}

//private static void CubeProgrammerApiOnStLinkAdded(object? sender, StLinkAddedEventArgs e)
//{
// Logger?.LogInformation("StLinkAdded...");
//}

private static IContainer BuildContainer()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new Bindings.Log());
//builder.RegisterModule(new KSociety.Wmi.Bindings.Wmi());
builder.RegisterModule(new Bindings.ProgrammerApi());
return builder.Build();
}
Expand Down

0 comments on commit fdfded3

Please sign in to comment.