Need Help On Win64 SDK C# Integration

Post questions and issues with Concept2 PM3 SDK
Post Reply
quinn33
Paddler
Posts: 2
Joined: May 15th, 2024, 2:29 am

Need Help On Win64 SDK C# Integration

Post by quinn33 » May 15th, 2024, 2:46 am

Need help on the pm-connection-initialization problem encountered while using the msvc2022_64 SDK provided by Concept2 support. Upon integration with my C# application, which is designed to interface with a PM5 device connected via USB, the SDK returns an error code -10151.

The error is identified as "TKDDI_NOT_IMPLEMENTED_ERR" with the message "Feature not implemented." when calling the "tkcmdsetDDI_discover_pm3s". The behavior is consistent with an undetected PM5 device, despite it being properly connected.

My example code and .dll files are attached as follows. Please advise on any known resolutions or further steps to address this error.

Code: Select all

using System.Runtime.InteropServices;

if (PM3DDICPd.tkcmdsetDDI_init() == 0 && PM3CSAFECPd.tkcmdsetCSAFE_init_protocol() == 0)
{
	const string PM5_PRODUCT_NAME = "Concept2 Performance Monitor 5 (PM5)";
	ushort startingAddress = 0;
	// errorCode = -10151
	// errorName = TKDDI_NOT_IMPLEMENTED_ERR
	// errorText = Feature not implemented
	// numUnits = 0
	short errorCode = PM3DDICPd.tkcmdsetDDI_discover_pm3s(PM5_PRODUCT_NAME, startingAddress, out ushort numUnits);
}

public static class PM3DDICPd
{
	public static short tkcmdsetDDI_discover_pm3s(string productName, ushort startingAddress, out ushort numUnits)
	{
		IntPtr sbyteArray = Marshal.StringToHGlobalAnsi(productName);
		short result = tkcmdsetDDI_discover_pm3s(sbyteArray, startingAddress, out numUnits);
		Marshal.FreeHGlobal(sbyteArray);
		return result;
	}
	
	[DllImport(nameof(PM3DDICPd), CallingConvention = CallingConvention.Cdecl)]
	public static extern short tkcmdsetDDI_init();
	
	[DllImport(nameof(PM3DDICPd), CallingConvention = CallingConvention.Cdecl)]
	private static extern short tkcmdsetDDI_discover_pm3s([In] IntPtr sbyteArray, [In] ushort startingAddress, [Out] out ushort numUnits);
}

public static class PM3CSAFECPd
{
	[DllImport(nameof(PM3CSAFECPd), CallingConvention = CallingConvention.Cdecl)]
	public static extern short tkcmdsetCSAFE_init_protocol([In] ushort timeout = 100);
}


kingpeterking
Paddler
Posts: 13
Joined: September 11th, 2022, 10:07 am

Re: Need Help On Win64 SDK C# Integration

Post by kingpeterking » June 3rd, 2024, 11:48 am

I gave up with the SDK and wrote my own bluetooth and USB routines.
There might be a clue to the answer to your question - last time I looked there were only 32 bit versions.
Sorry not to be of more help.

quinn33
Paddler
Posts: 2
Joined: May 15th, 2024, 2:29 am

Re: Need Help On Win64 SDK C# Integration

Post by quinn33 » June 4th, 2024, 4:44 am

It's alright. I figured it out eventually.
kingpeterking wrote:
June 3rd, 2024, 11:48 am

There might be a clue to the answer to your question - last time I looked there were only 32 bit versions.
The SDK I was referring to was acquired from the Concept2 support team, yet it was not working properly as I described.
Turns out the Win64 build from the Github repo https://github.com/ryanvalentin/Concept2SDKs_x64 works fine, and I made a separate socket server dedicated to polling data and forwarding to my game clients.
This forum posed limited attachment file size. If anyone is interested in the aforementioned SDK or my socket server, leave a reply and I will create a repo to share it.

Post Reply