Windows 8 App
Posted: April 8th, 2013, 8:11 pm
Hi All,
I've been working on a PM3 C# WPF app for a little while now, just for my own amusement really, but it's been going pretty well, so I thought I'd share some of what I've learnt so far, in case it's useful for anyone else. So far my app's functionality is basically just a mirror of the PM3 display, but it's working well, so everything else (session logging, live graphs, etc.) should be just sugar.
Latest PM3 DLLs
A few others have noted a problem with using DllImport with PMCSafeCP.dll due it not being built in the correct format to allow the entry points to be found automatically (you need to specify the mangled names, e.g. EntryPoint = "??tkcmdsetCSAFE_get_status@@YAEXZ").
However, it seems that the SDK is somewhat out-of-date. Instead, grab the more recent dlls from the Concept2 Utility, at http://www.concept2.com/service/softwar ... t2-utility. (Note to others in the UK, the utility linked at concept2.co.uk is not as recent). You can now revert to simple DllImport declarations. I would imagine the more recent dlls will also be more compatible with the latest PM3 firmware.
I wonder if Concept2 are going to release an updated SDK any time soon...?
Command Reference
I found the tables in the "Concept2 PM Communication Interface Definition 014" doc describing the available Csafe and PM3 commands to be the most accurate source of what works.
The information proffered by tkcmdsetCSAFE_get_cmd_text, tkcmdsetCSAFE_get_cmd_name and tkcmdsetCSAFE_get_cmd_data_types is tantalising, promising various extra, useful looking commands, but unfortunately it seems that any not listed in the aforementioned tables are not yet supported by the monitors (you'll get no response or an error).
I wonder if Concept2 are going to update the documentation any time soon...?
DLL Reference
It's a similar story here, but even many of the dll functions documented do not work, or at least function as expected. However, this is actually no big deal (for me at least). I've been able to achieve pretty much all I've wanted so far with only the following commands:
I enjoy watching tv/film on my PC while I'm rowing, and it seemed that a nice solution to running video alongside my app was Windows 8 in Modern UI mode, with my app in 'snapped' mode, the video app (or browser) in 'fill' mode (see "Use two apps at the same time" at http://windows.microsoft.com/en-gb/wind ... about-apps).
The most important point here is that this will never be an app that can be published to the Windows 8 App Store because you have to break one or more of the certification guidelines to get it to work:
This also means that I've got PM3 communication working over tcp, which could be useful for someone trying to network several Concept2 machines.
And the biggest ask of all, I wonder if Concept2 would consider updating their dlls to be Windows 8 Store compliant?
Thanks to anyone who made it this far! I hope you realise that my 3 requests aimed at Concept2 are a little tongue-in-cheek - I think it's great that we can access all this stuff and write our own apps and I don't expect any more. Anything we do get is a bonus.
Any questions, please just ask and I'll be happy to try and help (though I don't promise a quick response). I've got the code for all this shared-up somewhere out there on the interweb, and would be happy to share with anyone interested, just figure out how to message me somehow.
Cheers, Karl.
I've been working on a PM3 C# WPF app for a little while now, just for my own amusement really, but it's been going pretty well, so I thought I'd share some of what I've learnt so far, in case it's useful for anyone else. So far my app's functionality is basically just a mirror of the PM3 display, but it's working well, so everything else (session logging, live graphs, etc.) should be just sugar.
Latest PM3 DLLs
A few others have noted a problem with using DllImport with PMCSafeCP.dll due it not being built in the correct format to allow the entry points to be found automatically (you need to specify the mangled names, e.g. EntryPoint = "??tkcmdsetCSAFE_get_status@@YAEXZ").
However, it seems that the SDK is somewhat out-of-date. Instead, grab the more recent dlls from the Concept2 Utility, at http://www.concept2.com/service/softwar ... t2-utility. (Note to others in the UK, the utility linked at concept2.co.uk is not as recent). You can now revert to simple DllImport declarations. I would imagine the more recent dlls will also be more compatible with the latest PM3 firmware.
I wonder if Concept2 are going to release an updated SDK any time soon...?
Command Reference
I found the tables in the "Concept2 PM Communication Interface Definition 014" doc describing the available Csafe and PM3 commands to be the most accurate source of what works.
The information proffered by tkcmdsetCSAFE_get_cmd_text, tkcmdsetCSAFE_get_cmd_name and tkcmdsetCSAFE_get_cmd_data_types is tantalising, promising various extra, useful looking commands, but unfortunately it seems that any not listed in the aforementioned tables are not yet supported by the monitors (you'll get no response or an error).
I wonder if Concept2 are going to update the documentation any time soon...?
DLL Reference
It's a similar story here, but even many of the dll functions documented do not work, or at least function as expected. However, this is actually no big deal (for me at least). I've been able to achieve pretty much all I've wanted so far with only the following commands:
- tkcmdsetDDI_init
- tkcmdsetDDI_discover_pm3s
- tkcmdsetDDI_shutdown_all
- tkcmdsetDDI_get_error_name, tkcmdsetDDI_get_error_text
- tkcmdsetCSAFE_init_protocol
- tkcmdsetCSAFE_command
- tkcmdsetCSAFE_get_error_name, tkcmdsetCSAFE_get_error_text
I enjoy watching tv/film on my PC while I'm rowing, and it seemed that a nice solution to running video alongside my app was Windows 8 in Modern UI mode, with my app in 'snapped' mode, the video app (or browser) in 'fill' mode (see "Use two apps at the same time" at http://windows.microsoft.com/en-gb/wind ... about-apps).
The most important point here is that this will never be an app that can be published to the Windows 8 App Store because you have to break one or more of the certification guidelines to get it to work:
- The PM3 dlls call various disallowed Win32 functions, so cannot be used directly.
- Apps are not allowed to depend on external software (i.e. a windows service), so you cannot provide a desktop app which connects to the PM3 and then have the 2 apps comminicate. Besides, Windows 8 apps have a lot of security that makes this communication almost impossible in any timely manner.
- Whichever solution, it requires using Concept2 proprietary software (the dlls), so would need their agreement.
This also means that I've got PM3 communication working over tcp, which could be useful for someone trying to network several Concept2 machines.
And the biggest ask of all, I wonder if Concept2 would consider updating their dlls to be Windows 8 Store compliant?
Thanks to anyone who made it this far! I hope you realise that my 3 requests aimed at Concept2 are a little tongue-in-cheek - I think it's great that we can access all this stuff and write our own apps and I don't expect any more. Anything we do get is a bonus.
Any questions, please just ask and I'll be happy to try and help (though I don't promise a quick response). I've got the code for all this shared-up somewhere out there on the interweb, and would be happy to share with anyone interested, just figure out how to message me somehow.
Cheers, Karl.