PM3 Dll - Cannot find hook?

Post questions and issues with Concept2 PM3 SDK
Post Reply
codemonkey
Paddler
Posts: 2
Joined: July 21st, 2009, 5:19 am

PM3 Dll - Cannot find hook?

Post by codemonkey » July 21st, 2009, 5:50 am

I have recently started to try and develop software for my PM3, and have tried to write a small test program for it.

I have copied some of the code from another thread in this forum, and the important parts of my code are here:

Code: Select all

class Program {
	static void Main(string[] args) {
		Program prog = new Program();
		Console.Title = "PM3 Test Program";
		prog.wl("Running program 'PM3Test'...", true);
		prog.runprog();
		prog.wl("Closing...", true);
		prog.wl("Press [Enter] to exit", true);
		Console.ReadLine();
	}

	//Set Enums & Consts

	enum StrokeState {
		Idle = 0,
		Catch = 1,
		Drive = 2,
		Dwell = 3,
		Recovery = 4
	}

	const Int16 NO_ERR = 0;

	//Init Variables
	Int16 ecode = NO_ERR;
	UInt16 device_count = 0;

	//Dll Imports
	[DllImport("PM3DDICP.dll", CallingConvention = CallingConvention.Cdecl)]
	public static extern Int16 tkcmdsetDDI_init();

	[DllImport("PM3DDICP.dll", CallingConvention = CallingConvention.Cdecl)]
	public static extern Int16 tkcmdsetDDI_discover_pm3s(String product_name, UInt16 starting_address, ref UInt16 num_units);

	[DllImport("PM3DDICP.dll", CallingConvention = CallingConvention.Cdecl)]
	public static extern Int16 tkcmdsetDDI_fw_version(UInt16 unit_address, ref string ver_ptr);

	[DllImport("PM3DDICP.dll", CallingConvention = CallingConvention.Cdecl)]
	public static extern void tkcmdsetDDI_shutdown(UInt16 port);

	[DllImport("PM3CSAFECP.dll", CallingConvention = CallingConvention.Cdecl)]
	public static extern UInt16 tkcmdsetCSAFE_init_protocol(UInt16 timeout);

	[DllImport("PM3CsafeCP.dll", CallingConvention = CallingConvention.Cdecl)]
	public static extern Int16 tkcmdsetCSAFE_command(UInt16 unit_address,
	   UInt16 cmd_data_size, UInt32[] cmd_data, ref UInt16 rsp_data_size,
	   UInt32[] rsp_data);

	public void runprog() {
		//Init DDI Interface
		wl("Initialising DDI interface...");
		ecode = tkcmdsetDDI_init();
		if (ecode == NO_ERR) {
			wl("Done");
			//Look for PM3s
			wl("Looking for PM3s...");
			ecode = tkcmdsetDDI_discover_pm3s("Concept2 Performance Monitor 3 (PM3)", 0, ref device_count);
			if (ecode == NO_ERR) {
				wl("Done");
				//init CSAFE communication
				wl("Initialising CSAFE Communication");
				ecode = (short) tkcmdsetCSAFE_init_protocol(1000);
				if (ecode == NO_ERR) {
					wl("Done");
					//Success
					wl("PM3 Comms established");
					wl("Found " + device_count + " device(s)");
				}
			}
		}
		
		wl("Program finished");
	}

	public void wl(string lin) {
		wl(lin, false);
	}
	public void wl(string lin, bool isMain) {
		if (isMain) {
			Console.WriteLine("Main > " + lin);
		}
		else {
			Console.WriteLine("     > " + lin);
		}
	}
}
It works fine until this line:

Code: Select all

ecode = (short) tkcmdsetCSAFE_init_protocol(1000);
Where I get an error saying that there is no such entry point in the dll. Any help?

Thanks in advance.

haboustak
500m Poster
Posts: 77
Joined: March 17th, 2006, 3:02 pm
Location: Cincinnati

Post by haboustak » July 22nd, 2009, 1:09 am

C#, right? Ahhhh, but for the problems caused by an extra U...
[DllImport("PM3CSAFECP.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern UInt16 tkcmdsetCSAFE_init_protocol(UInt16 timeout);
ERRCODE_T is typedef'd to signed 16-bit int.

Hope that helps and good luck,
Mike

codemonkey
Paddler
Posts: 2
Joined: July 21st, 2009, 5:19 am

Post by codemonkey » July 22nd, 2009, 4:22 am

Thanks Mike, but I am still getting the following error:

Code: Select all

System.EntryPointNotFoundException was unhandled
  Message="Unable to find an entry point named 'tkcmdsetCSAFE_init_protocol' in DLL 'PM3CSAFECP.dll'."
  Source="PM3Test"
Could it be the version of the DLL that I have (the newest one) not being compiled proprely? I have tried opening the PM3CsafeCP.h file and the function line is there (PM3CSAFE_API ERRCODE_T tkcmdsetCSAFE_init_protocol(UINT16_T timeout);) though I don't know a lot about C++

My DllImport lines now read:

Code: Select all

[DllImport("PM3CSAFECP.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern Int16 tkcmdsetCSAFE_init_protocol(UInt16 timeout);
Is this correct?

Thanks a lot.

Post Reply