From 3a09283f225be7872becea623516b1ae673ee351 Mon Sep 17 00:00:00 2001 From: Arnaud Taffanel Date: Thu, 26 Jan 2017 15:36:29 +0100 Subject: [PATCH] #113: Move commander_generic into CRTP port 7 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 --- src/modules/interface/crtp.h | 17 +++++++++-------- src/modules/interface/crtp_commander.h | 3 --- src/modules/src/crtp_commander.c | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/modules/interface/crtp.h b/src/modules/interface/crtp.h index fe7ecc8c5a..1ff9947932 100644 --- a/src/modules/interface/crtp.h +++ b/src/modules/interface/crtp.h @@ -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 diff --git a/src/modules/interface/crtp_commander.h b/src/modules/interface/crtp_commander.h index 7ac79c4708..1e923cb241 100644 --- a/src/modules/interface/crtp_commander.h +++ b/src/modules/interface/crtp_commander.h @@ -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); diff --git a/src/modules/src/crtp_commander.c b/src/modules/src/crtp_commander.c index b91e132a61..946b232f2d 100644 --- a/src/modules/src/crtp_commander.c +++ b/src/modules/src/crtp_commander.c @@ -43,7 +43,7 @@ void crtpCommanderInit(void) crtpInit(); crtpRegisterPortCB(CRTP_PORT_SETPOINT, commanderCrtpCB); - + crtpRegisterPortCB(CRTP_PORT_SETPOINT_GENERIC, commanderCrtpCB); isInit = true; } @@ -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); }