Description
Hi Jim (and sorry to bother), but I found the following link you participated in and I had a question related to this for C# you might be able to help.
First, let me thank you for providing current tidbits to help the community on related topic. Very helpful so far.
I'm creating a C# wrapper class for the STM32CubProg and was successful using similar code to get a list of connected ST-LINKs. The major hurdle now is setting up basic code to pass the selected DebugConnectParameters
to connect with the device. When calling the connect function, it always returns -8 (Invalid Parameters). Below is some basic code I've setup...
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class DebugConnectParameters
{
public DebugPort DebugPort;
public int Index;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 33)]
public string SerialNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string FirmwareVersion;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5)]
public string TargetVoltage;
public int AccesPortNumber;
public int AccessPort;
public DebugConnectMode ConnectionMode;
public DebugResetMode ResetMode;
public int IsOldFirmware;
public Frequencies Frequencies;
public int Frequency;
public int IsBridge;
public int Shared;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string Board;
public int DebugSleep;
public int Speed;
}
Stm32CubeProgrammer.Commands.StLink.GetList(false, out Stm32CubeProgrammer.Types.DebugConnectParameters[] stLinkList);
int result = Stm32CubeProgrammer.Commands.StLink.Connect(stLinkList[0]);
public static int Connect(DebugConnectParameters debugParameters)
{
IntPtr stListPtr = Marshal.AllocHGlobal(Marshal.SizeOf<DebugConnectParameters>());
Marshal.StructureToPtr(debugParameters, stListPtr, true);
return NativeCommands.ConnectStLink(stListPtr);
}
[DllImport(Native.CubeProgrammerApiDllFilePath, CallingConvention = CallingConvention.Cdecl, EntryPoint = "connectStLink")]
public static extern int ConnectStLink(IntPtr debugParameters);
Were you successful in passing in the DebugConnectParameters
data structure to make a successful connection?
Again, sorry for intruding (especially since this is a Python API). Any help will be appreciated.