Hello,
I’m trying to use the CSAFE_SETUSERCFG1_CMD with the tkcmdsetCSAFE_command function as a wrapper for three other PM commands; namely: CSAFE_GETHORIZONTAL_CMD, CSAFE_GETCADENCE_CMD and CSAFE_GETPACE_CMD; but have not been successful. My call to the above CSAFE method returns without any error but I never get any results back.
I’ve had no problems calling the commands individually (see here: https://www.youtube.com/watch?v=9wshu_TufRs) but now I would like to bundle them together for efficiency reasons.
I got the idea to do so from the documentation: “Command Example #2 – Get PM3Worktime and Get PM3Workdistance Command” but now believe that I may have misunderstood something.
My code without the initialization looks as follows:
/----------------------------------------------------------------------------------------------/
void pollpm4()
{
UINT16_T unit_address = 0;
UINT16_T cmd_data_size = 0;
UINT32_T cmd_data[64] = {0x00};
UINT16_T rsp_data_size = 100;
UINT32_T rsp_data[64] = {0x00};
ERRCODE_T ecode;
unit_address = 0;
cmd_data[0] = (UINT32_T) 0x1A;
cmd_data[1] = (UINT32_T) 3;
cmd_data[2] = (UINT32_T) 0xA1; //CSAFE_GETHORIZONTAL_CMD
cmd_data[3] = (UINT32_T) 0xA7; //CSAFE_GETCADENCE_CMD
cmd_data[4] = (UINT32_T) 0xA6; //CSAFE_GETPACE_CMD 0xA6
cmd_data_size = 5;
int cnt = 1;
while(1){
rsp_data_size = 100;
memset(rsp_data, 0x00, sizeof(rsp_data));
ecode = tkcmdsetCSAFE_command(unit_address, cmd_data_size, cmd_data, &rsp_data_size, rsp_data);
printf("%04d -> %d %d : %X %u : %X %u %u %u : %X %u %u %u : %X %u %u %u \n",
cnt, ecode, rsp_data_size,
rsp_data[0], rsp_data[1],
rsp_data[2], rsp_data[3], rsp_data[4], rsp_data[5],
rsp_data[6], rsp_data[7], rsp_data[8], rsp_data[9],
rsp_data[10], rsp_data[11], rsp_data[12], rsp_data[13]);
cnt++;
if(ecode){
printError(ecode);
}
//
Sleep(500);
}
}
/----------------------------------------------------------------------------------------------/
And the output as follows:
intialization successful
COMMAND_DISCOVER successful: message is: PM's discovered: 1
COMMAND_GET_SERIAL_NUM successful: message is: 4XXXXXXXX
COMMAND_INIT_PROTOCOL successful: message is:
0001 -> 0 2 : 1A 0 : 0 0 0 0 : 0 0 0 0 : 0 0 0 0
0002 -> 0 2 : 1A 0 : 0 0 0 0 : 0 0 0 0 : 0 0 0 0
0003 -> 0 2 : 1A 0 : 0 0 0 0 : 0 0 0 0 : 0 0 0 0
0004 -> 0 2 : 1A 0 : 0 0 0 0 : 0 0 0 0 : 0 0 0 0
0005 -> 0 2 : 1A 0 : 0 0 0 0 : 0 0 0 0 : 0 0 0 0
Many thanks for your help,
William
bundling commands with CSAFE_SETUSERCFG1_CMD for PM4
Re: bundling commands with CSAFE_SETUSERCFG1_CMD for PM4
Ok, maybe I’ve found it. It seems as if I should be using the CSAFE_GETPMDATA_CMD as a command wrapper instead of the CSAFE_SETUSERCFG1_CMD; however, this is a proprietary command, which requires “authentication”. Can someone tell me what is meant by authentication is this case?
In the SDK documentation, I found the following: These commands are not accessible via the “public” interface and require special “authentication” with the PM3/PM4 to function.
In the SDK documentation, I found the following: These commands are not accessible via the “public” interface and require special “authentication” with the PM3/PM4 to function.
Re: bundling commands with CSAFE_SETUSERCFG1_CMD for PM4
I downloaded the code for the “Concept2 Watt Challenge” and built is using the libraries supplied with the code and it worked. The application bundles the PM commands together exactly as I would like to.
I then rebuilt the application to run with the “newer” libraries from the SDK and it didn't work anymore. I get a checksum error:
C2Erg::PollThread->Error (-161): TKFRAME_CSAFE_FRAME_CHKSM_ERR CSAFE frame checksum error.
I realize that I had to change some minor things in the application in oder for it to work with the new libraries but I don’t think my changes have anything to do with the above error.
On the wire they every thing looks fine:
Request:
f0:fd:00:1a:03:a3:a6:b4:a8:f2:00:00:00:3a:f2
Reply:
f0:00:fd:01:1a:07:a3:05:00:00:00:00:00:ba:f2
So I don’t understand the error message.
I guess I could use the libraries provided with the Watt Challenge application rather than those with the SDK but that wouldn’t be so nice.
I then rebuilt the application to run with the “newer” libraries from the SDK and it didn't work anymore. I get a checksum error:
C2Erg::PollThread->Error (-161): TKFRAME_CSAFE_FRAME_CHKSM_ERR CSAFE frame checksum error.
I realize that I had to change some minor things in the application in oder for it to work with the new libraries but I don’t think my changes have anything to do with the above error.
On the wire they every thing looks fine:
Request:
f0:fd:00:1a:03:a3:a6:b4:a8:f2:00:00:00:3a:f2
Reply:
f0:00:fd:01:1a:07:a3:05:00:00:00:00:00:ba:f2
So I don’t understand the error message.
I guess I could use the libraries provided with the Watt Challenge application rather than those with the SDK but that wouldn’t be so nice.
- tijmenvangulik
- 500m Poster
- Posts: 64
- Joined: November 25th, 2012, 10:24 am
Re: bundling commands with CSAFE_SETUSERCFG1_CMD for PM4
I also bundle my commands. You can see to following example how it is done:
https://github.com/tijmenvangulik/PM3Mo ... onitor.cpp
I do not know what you are exactly trying to write but I have published a more friendly C++ interfaces which does do the hard work for you. Check the header:
https://github.com/tijmenvangulik/PM3Mo ... 3Monitor.h
Tijmen
https://github.com/tijmenvangulik/PM3Mo ... onitor.cpp
I do not know what you are exactly trying to write but I have published a more friendly C++ interfaces which does do the hard work for you. Check the header:
https://github.com/tijmenvangulik/PM3Mo ... 3Monitor.h
Tijmen
- tijmenvangulik
- 500m Poster
- Posts: 64
- Joined: November 25th, 2012, 10:24 am
Re: bundling commands with CSAFE_SETUSERCFG1_CMD for PM4
A more recent version can be downloaded here:
https://webergometer.codeplex.com/SourceControl/latest
https://webergometer.codeplex.com/SourceControl/latest
Re: bundling commands with CSAFE_SETUSERCFG1_CMD for PM4
Thank you. That really helped. I was just trying to make the libraries accessible to Java applications via JNI (jc2pmon)