Post questions and issues with Concept2 PM3 SDK
-
angrytongan
- Paddler
- Posts: 33
- Joined: October 30th, 2015, 11:10 pm
Post
by angrytongan » June 21st, 2016, 5:09 am
Hi there,
Implementation of the C2 SDK specification for talking to C2 ergs that is independent of the C2 SDK libraries:
https://github.com/angrytongan/c2api
Hope this is useful
Cheers,
Dean

Male, 46, 5'11", 100kg,
log.
-
kdahlhaus
- 500m Poster
- Posts: 95
- Joined: September 17th, 2006, 2:13 pm
-
Contact:
Post
by kdahlhaus » June 21st, 2016, 6:11 pm
Sounds nice! I'll give it a go on Linux when I get a chance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://powertwenty.com
'Do' or 'Do not', there is no 'Try' -Yoda
-
tijmenvangulik
- 500m Poster
- Posts: 64
- Joined: November 25th, 2012, 10:24 am
Post
by tijmenvangulik » August 3rd, 2016, 4:11 am
Hi Dean,
My own concept 2 api loads a different set of properties. I am looking for ways to build my own api on yours. But it it looks like that your api was not written for this purpose. I have to restructure the code to make this possible. It would be nice to have 2 different api's. One layer which does do the blue tooth and the csafe packaging (this is like the old concept 2 driver) and the other which sends the csafe commands. Since this involves changing your code it would be nice to combine this effort so we can share code as much as possible. Further more I have some more questions:
- What is your licensing model? (I hope apache 2) (This way I know how far I am allowed to use/modify your code)
- I see in your code that you always call send and then wait for a single response. From my experience with the blue tooth csafe commands it is possible that the larger csafe blocks (like the force curve) come in multiple parts. I had to write a loop here to wait for the latest block. Didn't you have this problem with the usb drivers? I must say that I have not tested your force curve functionality yet. But the code just surprised me.
Tijmen
-
angrytongan
- Paddler
- Posts: 33
- Joined: October 30th, 2015, 11:10 pm
Post
by angrytongan » August 3rd, 2016, 4:54 am
Hi tijmenvangulik,
Keep in mind this is just a POC of how to talk to an erg. It's not thoroughly tested and I wouldn't use this for production quality in it's current state. Feel free to send me pull requests if you modify it

To your questions:
- The CSAFE packet builder (csafe.cpp, csafe.h) is independent of everything else; the push commands just append to a buffer held in csafe_buffer_t. You can pull the buffer out and then hand off to whatever delivery mechanism you want. Same on receive; once your receiver has an entire frame just pass it all off for unpacking.
- No specific licence so consider it public domain. If you really want a licence please adhere to the rules of the WTFPL (NSFW).
- I've not tested the forceplot / hr graphs, but according to the spec the whole response should fit inside an entire frame; the spec explicitly mentions that frames do not straddle boundaries. Even if this is not correct, you can implement a transport layer to ensure entire frames are received before unpacking. The spec also notes that the slave only speaks when responding to a master request (rev 0.15, page 16). From what you describe this may be different in the Bluetooth mechanism; I've only played with the USB interface.
Hope that helps. Please do get in touch if you have any more questions


Male, 46, 5'11", 100kg,
log.
-
tijmenvangulik
- 500m Poster
- Posts: 64
- Joined: November 25th, 2012, 10:24 am
Post
by tijmenvangulik » August 4th, 2016, 1:10 pm
Thank you for the answer. Nice license had not seen that one yet.
Tijmen
-
schander
- Paddler
- Posts: 16
- Joined: September 7th, 2009, 4:10 am
Post
by schander » January 6th, 2017, 6:12 pm
Hey @angrytongan
Started trying to use your console application. However I'm running into a problem.
When I try to get erg data with:
It gives me the following error:
Code: Select all
csafe_getodometer_req
csafe_getversion_req
csafe_getserial_req
tx_rx: request
f1 9b 91 94 9e f2 ......
tx_rx: response
f1 01 9b 05 08 aa 25 00 24 91 07 16 02 04 f3 01 ......%.$.......
00 3e 01 94 09 33 31 30 31 31 35 38 37 30 d1 f2 .>...310115870..
csafe_unpack: bad checksum (want d2, got d1)
Odometer: 0 (0 0x00)
Manufacturing ID: 0
CID: 0
Model: 0
Hardware version: 0
Software version: 0
Serial:
I'm running OS X 10.11.6, El Capitan. Any thoughts?
Cheers
Satpal
-
schander
- Paddler
- Posts: 16
- Joined: September 7th, 2009, 4:10 am
Post
by schander » January 9th, 2017, 7:15 pm
Worked it out.
A tweak was required in the code. Basically there is a requirement byte_unstuff before calculating the checksum of a response.
Now just need to workout when I get and error trying to get workouttype.
Thanks
Satpal