Syslink packet for commander

Firmware/software/electronics/mechanics
Post Reply
briaruwo
Beginner
Posts: 7
Joined: Fri May 17, 2019 2:40 pm

Syslink packet for commander

Post by briaruwo »

Hello,

I'm trying to create a syslink packet that can be sent through the link to make the motors ramp up (like through the commander in the python lib). As I understand, this would be sent in the NRF firmware with syslinkSend() and needs to have a type, length and data. Because it's not a radio or bootloader command, the existing code seems to tell me that the type should be SYSLINK_RADIO_RAW. The data that I've got in the packet is a copy of the data in the packet that is being sent for send_setpoint() commands in the python lib, and the length is the length of the data. Somehow, though, there seems to be a problem and I'm wondering if it's the way that I've got the packet filled. I haven't been able to find anything on this elsewhere but hopefully someone has an idea of where I might be going wrong. The code that I've written to fill the packet is:

static struct syslinkPacket slDebug;
slDebug.type = SYSLINK_RADIO_RAW;
char dataDebug[SYSLINK_MTU] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x00};
slDebug.length = 14;
memcpy(slDebug.data, dataDebug, slDebug.length);

and then the packet is being sent with syslinkSend(&slDebug);

Thanks for your ideas!
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Syslink packet for commander

Post by arnaud »

The content of the packet needs to be a CRTP packet, and this particular packet cannot be sent to a Crazyflie since it has a port/channel of 0/0 which is the Console port, console packets are only send by the Crazyflie not to the Crazyflie.

The CRTP documentation is in the wiki but the easiest to verify that your code is working might be to print-out in python the binary content of the packets that python is sending (this way you are sure of the encoding, when it works you can encode packet by yourself). The python ramp example is using the function send_setpoint. you could add the line

Code: Select all

print(pk.datat)
before the packet is sent: https://github.com/bitcraze/crazyflie-l ... der.py#L81

This would print the CRTP packet binary content.
briaruwo
Beginner
Posts: 7
Joined: Fri May 17, 2019 2:40 pm

Re: Syslink packet for commander

Post by briaruwo »

Thank you so much, I really appreciate the help!
briaruwo
Beginner
Posts: 7
Joined: Fri May 17, 2019 2:40 pm

Re: Syslink packet for commander

Post by briaruwo »

So, just to make sure that I'm correct on this end, I've looked at the documentation for CRTP packets again and mimicked the example that you give to send a 0,0,0,0 setpoint to the commander. When I printed the packet as you suggested on the ramp.py example, I didn't end up with the start bytes, or checksum, but trying to make it work without it didn't end up giving me results.

What I've made as my best guess would be the following
static struct syslinkPacket slDebug;
slDebug.type = SYSLINK_RADIO_RAW;
char dataDebug[SYSLINK_MTU] = { 0xaa, 0xaa, 0x30, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x50, 0xa2 };
slDebug.length = 19;
memcpy(slDebug.data, dataDebug, 19);

So, what I'm doing is putting the entire CRTP packet (with modified thrust values taken from one of the ramp.py runs and checksum calculated as sum of the data mod 256) into the data, setting the length to the length of the entire packet, and copying the CRTP packet into the syslink packet.

Then, at that point, I should be able to send it through the syslink and the crazyflie should respond by spinning the rotors, right? Hopefully this is correct and it's a problem with the rest of my code!

Thanks again!
Post Reply