Skip to content

Commit

Permalink
#113: Move commander_generic into CRTP port 7
Browse files Browse the repository at this point in the history
This is to make it easier to keep backward compatibility.
The new commander generic packet is set to port 7 channel 0,
this was previously unused so it can be used by TX-only clients
  • Loading branch information
ataffanel committed Jan 26, 2017
1 parent 2e8ec16 commit 3a09283
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
17 changes: 9 additions & 8 deletions src/modules/interface/crtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@
#define CRTP_IS_NULL_PACKET(P) ((P.header&0xF3)==0xF3)

typedef enum {
CRTP_PORT_CONSOLE = 0x00,
CRTP_PORT_PARAM = 0x02,
CRTP_PORT_SETPOINT = 0x03,
CRTP_PORT_MEM = 0x04,
CRTP_PORT_LOG = 0x05,
CRTP_PORT_POSITION = 0x06,
CRTP_PORT_PLATFORM = 0x0D,
CRTP_PORT_LINK = 0x0F,
CRTP_PORT_CONSOLE = 0x00,
CRTP_PORT_PARAM = 0x02,
CRTP_PORT_SETPOINT = 0x03,
CRTP_PORT_MEM = 0x04,
CRTP_PORT_LOG = 0x05,
CRTP_PORT_POSITION = 0x06,
CRTP_PORT_SETPOINT_GENERIC = 0x07,
CRTP_PORT_PLATFORM = 0x0D,
CRTP_PORT_LINK = 0x0F,
} CRTPPort;

typedef struct _CRTPPacket
Expand Down
3 changes: 0 additions & 3 deletions src/modules/interface/crtp_commander.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
#include "stabilizer_types.h"
#include "crtp.h"

#define CRTP_CONTROLLER_RPYT_CH 0
#define CRTP_CONTROLLER_GENERIC_CH 1

void crtpCommanderInit(void);
void crtpCommanderRpytDecodeSetpoint(setpoint_t *setpoint, CRTPPacket *pk);
void crtpCommanderGenericDecodeSetpoint(setpoint_t *setpoint, CRTPPacket *pk);
Expand Down
6 changes: 3 additions & 3 deletions src/modules/src/crtp_commander.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void crtpCommanderInit(void)

crtpInit();
crtpRegisterPortCB(CRTP_PORT_SETPOINT, commanderCrtpCB);

crtpRegisterPortCB(CRTP_PORT_SETPOINT_GENERIC, commanderCrtpCB);
isInit = true;
}

Expand All @@ -52,10 +52,10 @@ static void commanderCrtpCB(CRTPPacket* pk)
{
static setpoint_t setpoint;

if(pk->channel == CRTP_CONTROLLER_RPYT_CH) {
if(pk->port == CRTP_PORT_SETPOINT && pk->channel == 0) {
crtpCommanderRpytDecodeSetpoint(&setpoint, pk);
commanderSetSetpoint(&setpoint, COMMANDER_PRIORITY_CRTP);
} else if (pk->channel == CRTP_CONTROLLER_GENERIC_CH) {
} else if (pk->port == CRTP_PORT_SETPOINT_GENERIC && pk->channel == 0) {
crtpCommanderGenericDecodeSetpoint(&setpoint, pk);
commanderSetSetpoint(&setpoint, COMMANDER_PRIORITY_CRTP);
}
Expand Down

0 comments on commit 3a09283

Please sign in to comment.