Skip to content

Commit

Permalink
Merge pull request #65 from K-Society/experimental
Browse files Browse the repository at this point in the history
Experimental
  • Loading branch information
maniglia authored Nov 20, 2023
2 parents 17462e1 + 09aee0d commit 9f040af
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@
</ItemGroup>
<ItemGroup>
<StFlashLoaderFiles Include="$(MSBuildThisFileDirectory)/../contentFiles/FlashLoader/*.*" />
<StExternalLoaderFiles Include="$(MSBuildThisFileDirectory)/../contentFiles/ExternalLoader/*.*" Exclude="**\N25Q256A_STM32L476G-EVAL\**\*.*;**\M29W128GL_STM3210E-EVAL\**\*.*;**\M25P64_STM3210E-EVAL\**\*.*;**\IS61WV51216BLL_STM3210E-EVAL\**\*.*"/>
<StDataBaseFiles Include="$(MSBuildThisFileDirectory)/../contentFiles/Data_Base/*.*" />
</ItemGroup>
<Target Name="CopyStFiles" AfterTargets="Build">
<Copy SourceFiles="@(StFlashLoaderFiles)" DestinationFolder="$(TargetDir)/st/Programmer/FlashLoader/%(RecursiveDir)" />
<Copy SourceFiles="@(StExternalLoaderFiles)" DestinationFolder="$(TargetDir)/st/Programmer/ExternalLoader/%(RecursiveDir)" />
<Copy SourceFiles="@(StDataBaseFiles)" DestinationFolder="$(TargetDir)/st/Data_Base/%(RecursiveDir)" />
</Target>
<Target Name="PublishStFiles" AfterTargets="Publish">
<Copy SourceFiles="@(StFlashLoaderFiles)" DestinationFolder="$(PublishDir)/st/Programmer/FlashLoader/%(RecursiveDir)" />
<Copy SourceFiles="@(StExternalLoaderFiles)" DestinationFolder="$(PublishDir)/st/Programmer/ExternalLoader/%(RecursiveDir)" />
<Copy SourceFiles="@(StDataBaseFiles)" DestinationFolder="$(PublishDir)/st/Data_Base/%(RecursiveDir)" />
</Target>
</Project>
54 changes: 46 additions & 8 deletions src/01/KSociety.SharpCubeProgrammer/CubeProgrammerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public CubeProgrammerError ReadUnprotect()
/// <inheritdoc />
public void GetCancelPointer()
{
throw new NotImplementedException();
Native.ProgrammerApi.GetCancelPointer();
}

/// <inheritdoc />
Expand Down Expand Up @@ -877,27 +877,65 @@ public CubeProgrammerError ObDisplay()
//Loaders module groups loaders functions.

/// <inheritdoc />
public void SetExternalLoadersPath(string path)
public void SetLoadersPath(string path)
{
throw new NotImplementedException();
Native.ProgrammerApi.SetLoadersPath(path);
}

/// <inheritdoc />
public void GetExternalLoaders()
public ExternalLoader SetExternalLoaderPath(string path)
{
throw new NotImplementedException();
var externalLoaderStructure = new ExternalLoader();
var externalLoaderPtr = new IntPtr();

try
{
Native.ProgrammerApi.SetExternalLoaderPath(path, ref externalLoaderPtr);
if (externalLoaderPtr != IntPtr.Zero)
{
externalLoaderStructure = Marshal.PtrToStructure<ExternalLoader>(externalLoaderPtr);
}
}
catch (Exception ex)
{
this._logger?.LogError(ex, "SetExternalLoaderPath: ");
}

return externalLoaderStructure;
}

/// <inheritdoc />
public void RemoveExternalLoader()
public ExternalStorageInfo GetExternalLoaders(string path)
{
throw new NotImplementedException();
var externalStorageInfoStructure = new ExternalStorageInfo();
var externalStorageInfoPtr = new IntPtr();

try
{
Native.ProgrammerApi.GetExternalLoaders(path, ref externalStorageInfoPtr);
if (externalStorageInfoPtr != IntPtr.Zero)
{
externalStorageInfoStructure = Marshal.PtrToStructure<ExternalStorageInfo>(externalStorageInfoPtr);
}
}
catch (Exception ex)
{
this._logger?.LogError(ex, "GetExternalLoaders: ");
}

return externalStorageInfoStructure;
}

/// <inheritdoc />
public void RemoveExternalLoader(string path)
{
Native.ProgrammerApi.RemoveExternalLoader(path);
}

/// <inheritdoc />
public void DeleteLoaders()
{
throw new NotImplementedException();
Native.ProgrammerApi.DeleteLoaders();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,27 @@ public interface ICubeProgrammerApi : IDisposable

//Loaders module groups loaders functions.

/// <summary>
/// This routine allows to specify the location of Flash Loader.
/// </summary>
/// <param name="path">Indicates the full path of the considered folder.</param>
void SetLoadersPath(string path);

/// <summary>
/// This routine allows to specify the path of the external Loaders to be loaded.
/// </summary>
/// <param name="path"></param>
void SetExternalLoadersPath(string path);
ExternalLoader SetExternalLoaderPath(string path);

/// <summary>
/// This routine allows to get available external Loaders in th mentioned path.
/// </summary>
void GetExternalLoaders();
ExternalStorageInfo GetExternalLoaders(string path);

/// <summary>
/// This routine allows to unload an external Loaders.
/// </summary>
void RemoveExternalLoader();
void RemoveExternalLoader(string path);

/// <summary>
/// This routine allows to delete all target Flash Loaders.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<None Include="..\..\..\build\Programmer\bin\Win32\Release\*.dll" Pack="true" PackagePath="build\native\x86\Programmer" Visible="false" Link="dll\x86\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Data_Base\*.*" Pack="true" PackagePath="contentFiles\Data_Base" Visible="false" Link="st\Data_Base\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Programmer\FlashLoader\*.*" Pack="true" PackagePath="contentFiles\FlashLoader" Visible="false" Link="st\Programmer\FlashLoader\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Programmer\ExternalLoader\*.*" Pack="true" PackagePath="contentFiles\ExternalLoader" Visible="false" Link="st\Programmer\ExternalLoader\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="**\N25Q256A_STM32L476G-EVAL\**\*.*;**\M29W128GL_STM3210E-EVAL\**\*.*;**\M25P64_STM3210E-EVAL\**\*.*;**\IS61WV51216BLL_STM3210E-EVAL\**\*.*" />
</ItemGroup>

</Project>
28 changes: 14 additions & 14 deletions src/01/KSociety.SharpCubeProgrammer/Native/ProgrammerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,28 +1313,28 @@ internal static void SetLoadersPath(string path)
#region [SetExternalLoaderPath]

[DllImport(ProgrammerDll32, EntryPoint = "SetExternalLoaderPath", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern void SetExternalLoaderPath32(string path, IntPtr externalLoaderInfo);
private static extern void SetExternalLoaderPath32(string path, ref IntPtr externalLoaderInfo);

[DllImport(ProgrammerDll64, EntryPoint = "SetExternalLoaderPath", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern void SetExternalLoaderPath64(string path, IntPtr externalLoaderInfo);
private static extern void SetExternalLoaderPath64(string path, ref IntPtr externalLoaderInfo);

private static void SetExternalLoaderPathNative(string path, IntPtr externalLoaderInfo)
private static void SetExternalLoaderPathNative(string path, ref IntPtr externalLoaderInfo)
{
if (!Environment.Is64BitProcess)
{
SetExternalLoaderPath32(path, externalLoaderInfo);
SetExternalLoaderPath32(path, ref externalLoaderInfo);
}
else
{
SetExternalLoaderPath64(path, externalLoaderInfo);
SetExternalLoaderPath64(path, ref externalLoaderInfo);
}
}

internal static void SetExternalLoaderPath(string path, IntPtr externalLoaderInfo)
internal static void SetExternalLoaderPath(string path, ref IntPtr externalLoaderInfo)
{
try
{
SetExternalLoaderPathNative(path, externalLoaderInfo);
SetExternalLoaderPathNative(path, ref externalLoaderInfo);
}
catch (DllNotFoundException ex)
{
Expand All @@ -1351,28 +1351,28 @@ internal static void SetExternalLoaderPath(string path, IntPtr externalLoaderInf
#region [GetExternalLoaders]

[DllImport(ProgrammerDll32, EntryPoint = "GetExternalLoaders", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern void GetExternalLoaders32(string path, IntPtr externalStorageNfo);
private static extern void GetExternalLoaders32(string path, ref IntPtr externalStorageNfo);

[DllImport(ProgrammerDll64, EntryPoint = "GetExternalLoaders", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern void GetExternalLoaders64(string path, IntPtr externalStorageNfo);
private static extern void GetExternalLoaders64(string path, ref IntPtr externalStorageNfo);

private static void GetExternalLoadersNative(string path, IntPtr externalStorageNfo)
private static void GetExternalLoadersNative(string path, ref IntPtr externalStorageNfo)
{
if (!Environment.Is64BitProcess)
{
GetExternalLoaders32(path, externalStorageNfo);
GetExternalLoaders32(path, ref externalStorageNfo);
}
else
{
GetExternalLoaders64(path, externalStorageNfo);
GetExternalLoaders64(path, ref externalStorageNfo);
}
}

internal static void GetExternalLoaders(string path, IntPtr externalStorageNfo)
internal static void GetExternalLoaders(string path, ref IntPtr externalStorageNfo)
{
try
{
GetExternalLoadersNative(path, externalStorageNfo);
GetExternalLoadersNative(path, ref externalStorageNfo);
}
catch (DllNotFoundException ex)
{
Expand Down
4 changes: 2 additions & 2 deletions src/01/KSociety.Test/KSociety.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 9f040af

Please sign in to comment.