Successfully Connected With The Pm3?
-
- Posts: 0
- Joined: March 18th, 2006, 10:32 pm
Hi experts<br /><br />I was playing with my PM3 Monitor and the shared dll's and the documentation<br />and...and they were my experiences:<br /><br />1. The functions tkcmdsetDDI_discover_pm3s and tkcmdsetUSB_init are working<br />but I think they are the only functions working<br /><br />2. tkcmdsetUSB_do_DDIcommand following the example in the documentation<br />brings the monitor to an error 122? (It was my best result until now)<br /><br />3. The function tkcmdsetDDI_init_protocol requires a pointer to a function:<br /><br /> ERRCODE_T *frame_builder() Ptr to frame builder function and<br /> ERRCODE_T *frame_checker() Ptr to frame checker function<br /><br />Any idea how to find those functions?<br /><br />4. My goal was to send a "get status" request to the monito and to receive an answer. <br />With all my tests and combinations<br />I received many different errors:<br /><br />[-10150]<br />Name=TKDDI_INVALID_PORT_ERR<br />Text=An invalid port number was specified<br /><br />[-10100]<br />Name=TKUSB_INVALID_PORT_ERR<br />Text=An invalid port number was specified<br /><br />[-10109]<br />Name=TKUSB_NO_PORT_INIT_ERR<br />Text=The USB port has not been initialized<br /><br />[-10107]<br />Name=TKUSB_READ_TIMEOUT_ERR<br />Text=The USB read operation did not complete within the timeout period<br /><br />5. Only the RPPM3USB.lib could be linked in C++ the another *.lib<br />brought a linked error. I had to work loading the dll's dynamically<br /><br />6. PM3APIDemo.exe doesn't work<br /><br /><br />I am disappoinment with all my tests, it is maybe because I am don't experience working with usb?<br /><br />Has somebody here a better result sending a command to the monitor?<br /><br />Thanks in advance<br /><br />Marilyn<br />
Marilyn,<br /><br />What firmware is your PM3 running? Did you use the tool from Concept2 to upgrade to rev 970? PM3APIDemo.exe works "mostly" on my system, so I'm thinking that you have a version conflict.<br /><br />What compiler are you using? What linker error are you getting? I'm not sure why the libs aren't all working for you. I believe that the libraries were created with Visual Studio 6.0 or .NET, and so they should work with both of those compilers.<br /><br />I'll hold off on working through your other questions until I know what platform you're working with. But in #3, I don't think that function is intended for general use. It's probably already called by the general USB_Init() function, where it passes in non-exported functions from the library.<br /><br />If you link with the USB API, and use USB_Init(), followed by a do_DDICommand(), with the command frame (0xF0, 0xFD, 0x00, 0x80, 0x80, 0xF2) you should get a valid response back with no errors.
-
- Posts: 0
- Joined: March 18th, 2006, 10:32 pm
Hi haboustak <br /><br />Thanks for your answer. I am thinking all the time I have the wrong versions<br />and I downloaded them again from:<br /><br /><a href='http://www.concept2.com/products/pm3/sdk.asp' target='_blank'>http://www.concept2.com/products/pm3/sdk.asp</a><br /><br />The RPPM3CSAFE.dll is from 09.09.04 and the others from 06.06.04, exactly than mine. Only my Apidemo was older<br /><br />It makes me happy to know that you can send a command to the PM3 because it didn't work for me until now.<br /><br />In the example:<br /><br />if (ecode = tkcmdsetUSB_init())...<br /><br />there is a function tkcmdsetUSB_init() -without parameters<br />In my header file there is not that function and if I call it I receive an error "function unknown"<br /><br />The only function with init is this one:<br /><br />PM3USB_API ERRCODE_T tkcmdsetUSB_init(INT8_T * product_name, UINT8_T * num_found, UINT8_T port_list[]); This functions work and returns num_found=1<br />but it doesn't help for nothing more.<br /><br />I am using Visual C++ 2005 Express Edition Beta<br /><br />Many thanks my demoapi was the only thing in a false version and now it is working! Thanks At least something that works <br /><br />I will delete all my versions and I will copy them again and I will try the example<br />again, if it worked for you, maybe it works for me. I will let you know<br /><br />Marilyn<br /><br /><br /><br /><br /><br /> <br />
Marilyn,<br /><br />You're right on the usage of tkcmdsetUSB_init() -- the code in the SDK documentation is either just a rough example or it was written before the SDK supported multiple PM3 devices on a single computer. Your call is correct and it's a good sign that it's finding the monitor.<br /><br />The documentation's example call to tkcmdsetUSB_do_DDIcommand() is wrong too. In my version it's missing the port parameter. It should look more like:<br /><br />tkcmdsetUSB_do_DDIcommand(port_list[0], cmd_data, rsp_data, 70);<br /><br />Where port_list is the array of ports returned from tkcmdsetUSB_Init(), cmd_data and rsp_data are UINT8_T arrays, and 70 is the USB timeout delay in milliseconds.<br /><br /><br />I also wanted to point out something that I've been noticing. The documentation indicates that the PM3 always returns some data to the host application, but this doesn't seem to be the case on my system. If you send a CSAFE command that has "N/A" listed in its response data, tkcmdsetUSB_do_DDIcommand() will return the error TKUSB_READ_TIMEOUT_ERR. This shouldn't be considered a critical error if you're sending a command that has no response. Let me know if you observe the same behavior. <br /><br /><br />Mike
From my perspective the SDK documentation is pretty good. I'll list some issues that I've found.<br /><br />1: The documentation lists the max CSAFE frame size as 96 bytes (p. 12, among others), but you created a USB report 120 bytes in length, and in the library code (PM3Csafe.h) the developer has "#define CSAFE_BUFFER_SIZE 256". Which one is it? The answer probably depends on who you ask: Firmware, USB bus, or Library.<br /><br />If you ask me, I would say that an ideal [max buffer size / max frame size / report length] is 63 bytes, because then each message (and report ID) can be sent in a single 64-byte HID USB packet. Right now we're limited to either 20-byte single packets or a 120-byte two-packet message. Using the 120-byte USB reports vs. a 63-byte report cuts the responsiveness of the PM3 by a large amount. I think that a 63-byte report would be much more than twice as fast as a 120-byte one, because there's at least an 8ms delay between each packet. 120-byte works though, and I'm willing to accept that it was chosen for a reason I don't understand yet.<br /><br />2: The response data for CSAFE_PM_SET_SPLITDURATION is incorrect (p. 40). The table of commands lists N/A for the response data, but the sample frames below the table show data coming back, and my test code sometimes(!) returns data from this command. Not sure what's up there, but it's inconsistent.<br /><br />3: I've already mentioned flgAck (p. 18). I think this is a firmware bug, or it's a Mike Haboustak bug - I don't know for sure.<br /><br />4: The sample CSAFE on (p. 18) is also missing some spacing/characters. The CSAFE_SETHORIZONTAL_CMD command is missing "0x" before the "00" in it's second-last byte. And CSAFE_SETPOWER_CMD is missing a space between it's last two bytes (also missing it in the combined command format). I know this is minor, but CSAFE is hard to read as it is! See also the response frame on p. 40.<br /><br />I want to say overall that I appreciate the available documentation, it's taken me a long way. I know these are minor corrections, and sorry I'm so long-winded.<br /><br />Mike
-
- Posts: 0
- Joined: March 18th, 2006, 10:32 pm
Hi Scott!<br /><br />I am agree with Mike, the documentation is very nice, a good start to understand<br />the monitor.<br />My problems are because I was never programmig with usb or protocols<br />and with c++ no more since a long of time ago, so I had a lot of difficulties<br />trying to fix my compiler, etc.<br /><br />My versions were also false. With Mike's help I am getting light in the dark<br />tunnel<br /><br />I was using the APIdemo and it works now, anyway I don't know too much about <br />the pm3. I set a 2KM workout but I don't find a start command, or a countdown analog to the PM2. The same problem with a time based workout<br /><br />My PM3 is not connected to my rower. For example if I set a 2KM workout or a 30min workout, how do I know when it starts? My timer never starts, should I begin to row to start the timer?<br /><br />I receive the same timeout error with N/A commands<br /><br />I tried to set the date with this command. My idea was to set the date to 04/04/04<br /><br />F1, 12, 03, 04, 04, 04, 15, F2<br /><br />but the date in the rower is not changed. Where is my error?<br /><br />Anyway it is getting fun, when I finally can communicate with the monitor<br /><br />Marilyn<br />
<!--QuoteBegin-Marilyn+Mar 5 2005, 05:32 AM--><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><div class='genmed'><b>QUOTE(Marilyn @ Mar 5 2005, 05:32 AM)</b></div></td></tr><tr><td class='quote'><!--QuoteEBegin-->I tried to set the date with this command. My idea was to set the date to 04/04/04<br /><br />F1, 12, 03, 04, 04, 04, 15, F2<br /><br />but the date in the rower is not changed. Where is my error?<br /> </td></tr></table><br /><br />Are you prefixing these digits by "0x" in the C++ code? The compiler needs that to identify it as hex (base 16). Try extended frame addressing. 0xF0 0xFD 0x00, instead of 0xF1.<br /><br />UINT8_T cmd_data[10] = { 0xF0, 0xFD, 0x00, 0x12, 0x03, 0x04, 0x04, 0x04, 0x15, 0xF2 };<br /><br />You should try to get the DDI and CSAFE libraries working. I think they'll make sending packets easier on you. Maybe you can post the error you get when using those libraries?<br /><br />I'll test the SETDATE command on my Macintosh in a few minutes and report back on whether I could get the command to work.<br /><br />Mike<br /><br />[Edited to Add]<br />You can ignore all of the above now that I've tested it on the Mac. The problem is the 'Year' byte. This byte is the number of years since 1900. Let's hope no one tries to use their PM3 after 2,155. The correct packet is as follows:<br /><br />{ 0xF1 0x12 0x03 0x68 0x04 0x04 0x79 0xF2 }<br /><br />My test packet was:<br />{ 0xF0 0xFD 0x00 0x12 0x03 0x69 0x03 0x05 0x7E 0xF2 }<br /><br />I've found you have to switch screens and come back for the main menu date display to update.<br /><br />In regards to the 2K workout, my PM3 screen changes to the workout display (the one that shows distance remaining, HR, etc) after I send the SETPROGRAM_CMD. So once your 2K workout is programmed the workout starts automatically. In my other thread I've mentioned problems with CSAFE states. You have to decode the GETSTATUS packet in order to make sure the PM3 is in the 'Ready' state, otherwise the PM3 can't accept the workout. Watch out for a status byte of 0x09 or 0x89! This means that the PM3 is in the 'Offline' state and very few commands will work (state or workout related). I've had to reset the monitor at times in order to get it out of 'Offline', particularly after Just Rows.