Crtp TOC-Access

Firmware/software/electronics/mechanics
Post Reply
RomanG
Beginner
Posts: 3
Joined: Thu Apr 23, 2015 12:28 pm

Crtp TOC-Access

Post by RomanG »

Hi CrazyFliers,

After the last Weekend I'm now having a working communication between a FRDM-KL26z-Board and my beloved Crazyflie :-). So I am able to fly without the use of my PC.
While it was easy to send the Copter all controlling values (like thrust, yaw, roll and pitch) my focus is now on the different parameters and the functions thereof.
The first thing i wanted to check is the Battery-Status. It turns out, that it's not as easy as the controlling. That why I'm writing this in the hope, that someone can help me.
From my understanding, to know exactly where the Battery-Voltage is stored I need to access the TOC. So first thing I need to do, is to read all Parameter-Elements as described here: https://wiki.bitcraze.io/doc:crazyflie:crtp:param
But already there a Problem emerges:
When I send the command

Code: Select all

Port/Channel, Data
2/0, 0
Instead of the first TOC-Element I'll receive no Data.
But sending the command

Code: Select all

Port/Channel, Data
2/0, 1
Will get me the following answer:

Code: Select all

Port/Channel,Data
 2/0, [1, 64, 106, 134, 208, 63]
which is clearly not a TOC-Element but more like the Num. Of Parameters and the CRC32, which should be returned by command 2/0, 3.
Since this lead to nothing I tired to read me in some Code: Where I found:

Code: Select all

# TOC access command
TOC_RESET = 0
TOC_GETNEXT = 1
TOC_GETCRC32 = 2
in
https://github.com/bitcraze/crazyflie-c ... e/param.py
This lead to more confusion since it is clearly stated, that the GetCRC32 should be command 3.

So at this point I started the CrazyFlie-Client and in it its Crtp-Sniffer. After that I Connected my Crazyflie and got all the nice data sets. Hoping to find the point where the parameters are accessed. There I had to find next mysterious thing.
In the connection-start there is a command

Code: Select all

2/0, 1
and its Answer is:

Code: Select all

2/0, [1, 64, 106, 134, 208, 63]
Exactly the same as the one I get (so my Code is working the way it should). But after that the Client starts to refresh all parameters. This even indicates that the GETCRC32 is command 1. Which state that there are 64 Parameters and a 4 Byte CRC32 (Since the CRC32 is known by the Client it is not necessary to get the complete parameter-set again. So instead just update the data).
Now in order to get the Parameter-List with my uC, it would be great, if someone would explain how exactly I get the Parameter-List and in a further step the Parameter itself.
Thanks.

Greetings,
RomanG
Post Reply