Multi_names mandatory when using multi_telemetry

Validate that sub_proto is valid for the current protocol
Validate that disable channel mapping is valid for the current protocol
This commit is contained in:
pascallanger 2019-11-29 18:50:57 +01:00
parent cf4acc1d4c
commit d3c3fac4f7
5 changed files with 47 additions and 48 deletions

View File

@ -338,6 +338,12 @@ enum MultiPacketTypes
// Macros
#define NOP() __asm__ __volatile__("nop")
//***************
//*** Tests ***
//***************
#define IS_FAILSAFE_PROTOCOL ( (protocol==PROTO_HISKY && sub_protocol==HK310) || protocol==PROTO_AFHDS2A || protocol==PROTO_DEVO || protocol==PROTO_SFHSS || protocol==PROTO_WK2x01 || protocol== PROTO_HOTT || protocol==PROTO_FRSKYX )
#define IS_CHMAP_PROTOCOL ( (protocol==PROTO_HISKY && sub_protocol==HK310) || protocol==PROTO_AFHDS2A || protocol==PROTO_DEVO || protocol==PROTO_SFHSS || protocol==PROTO_WK2x01 || protocol== PROTO_DSM || protocol==PROTO_SLT || protocol==PROTO_FLYSKY || protocol==PROTO_ESKY || protocol==PROTO_J6PRO )
//***************
//*** Flags ***
//***************

View File

@ -1621,24 +1621,6 @@ void update_serial_data()
#endif
}
if(prev_ch_mapping!=IS_DISABLE_CH_MAP_on)
{
prev_ch_mapping=IS_DISABLE_CH_MAP_on;
if(IS_DISABLE_CH_MAP_on)
{
for(uint8_t i=0;i<4;i++)
CH_AETR[i]=CH_TAER[i]=CH_EATR[i]=i;
debugln("DISABLE_CH_MAP_on");
}
else
{
CH_AETR[0]=AILERON;CH_AETR[1]=ELEVATOR;CH_AETR[2]=THROTTLE;CH_AETR[3]=RUDDER;
CH_TAER[0]=THROTTLE;CH_TAER[1]=AILERON;CH_TAER[2]=ELEVATOR;CH_TAER[3]=RUDDER;
CH_EATR[0]=ELEVATOR;CH_EATR[1]=AILERON;CH_EATR[2]=THROTTLE;CH_EATR[3]=RUDDER;
debugln("DISABLE_CH_MAP_off");
}
}
if( (rx_ok_buff[0] != cur_protocol[0]) || ((rx_ok_buff[1]&0x5F) != (cur_protocol[1]&0x5F)) || ( (rx_ok_buff[2]&0x7F) != (cur_protocol[2]&0x7F) ) )
{ // New model has been selected
CHANGE_PROTOCOL_FLAG_on; //change protocol
@ -1679,6 +1661,27 @@ void update_serial_data()
for(uint8_t i=0;i<3;i++)
cur_protocol[i] = rx_ok_buff[i];
//disable channel mapping
if(!IS_CHMAP_PROTOCOL) //not a protocol supporting ch map to be disabled
DISABLE_CH_MAP_off;
if(prev_ch_mapping!=IS_DISABLE_CH_MAP_on)
{
prev_ch_mapping=IS_DISABLE_CH_MAP_on;
if(IS_DISABLE_CH_MAP_on)
{
for(uint8_t i=0;i<4;i++)
CH_AETR[i]=CH_TAER[i]=CH_EATR[i]=i;
debugln("DISABLE_CH_MAP_on");
}
else
{
CH_AETR[0]=AILERON;CH_AETR[1]=ELEVATOR;CH_AETR[2]=THROTTLE;CH_AETR[3]=RUDDER;
CH_TAER[0]=THROTTLE;CH_TAER[1]=AILERON;CH_TAER[2]=ELEVATOR;CH_TAER[3]=RUDDER;
CH_EATR[0]=ELEVATOR;CH_EATR[1]=AILERON;CH_EATR[2]=THROTTLE;CH_EATR[3]=RUDDER;
debugln("DISABLE_CH_MAP_off");
}
}
// decode channel/failsafe values
volatile uint8_t *p=rx_ok_buff+3;
uint8_t dec=-3;

View File

@ -136,37 +136,25 @@ static void multi_send_status()
if (remote_callback != 0)
{
flags |= 0x04;
#ifdef MULTI_NAMES
if((sub_protocol&0x07) && multi_protocols_index != 0xFF)
{
uint8_t nbr=multi_protocols[multi_protocols_index].nbrSubProto;
if((sub_protocol&0x07)>=nbr)
flags &= ~0x04; //Invalid sub protocol
}
#endif
if (IS_WAIT_BIND_on)
flags |= 0x10;
else
if (IS_BIND_IN_PROGRESS)
flags |= 0x08;
switch (protocol)
{
case PROTO_HISKY:
if(sub_protocol!=HK310)
break;
case PROTO_AFHDS2A:
case PROTO_DEVO:
case PROTO_SFHSS:
case PROTO_WK2x01:
#ifdef FAILSAFE_ENABLE
flags |= 0x20; //Failsafe supported
#endif
case PROTO_DSM:
case PROTO_SLT:
case PROTO_FLYSKY:
case PROTO_ESKY:
case PROTO_J6PRO:
if(IS_CHMAP_PROTOCOL)
flags |= 0x40; //Disable_ch_mapping supported
break;
#ifdef FAILSAFE_ENABLE
case PROTO_HOTT:
case PROTO_FRSKYX:
if(IS_FAILSAFE_PROTOCOL)
flags |= 0x20; //Failsafe supported
break;
#endif
}
if(IS_DATA_BUFFER_LOW_on)
flags |= 0x80;
}
@ -197,8 +185,8 @@ static void multi_send_status()
for(uint8_t i=0;i<7;i++)
Serial_write(multi_protocols[multi_protocols_index].ProtoString[i]); // protocol name
// Sub-protocol
uint8_t nbr=multi_protocols[multi_protocols_index].nbrSubProto | (multi_protocols[multi_protocols_index].optionType<<4); // add option display type
Serial_write(nbr); // number of sub protocols
uint8_t nbr=multi_protocols[multi_protocols_index].nbrSubProto;
Serial_write(nbr | (multi_protocols[multi_protocols_index].optionType<<4)); // number of sub protocols && option type
uint8_t j=0;
if(nbr && (sub_protocol&0x07)<nbr)
{

View File

@ -349,6 +349,10 @@
#undef MULTI_NAMES
#endif
#if defined(MULTI_TELEMETRY)
#define MULTI_NAMES
#endif
//Make sure TX is defined correctly
#ifndef AILERON
#error You must select a correct channel order.

View File

@ -283,8 +283,6 @@
//Sends Multi status and allow OpenTX to autodetect the telemetry format. Comment to disable.
//Supported by OpenTX version 2.2 RC9 and newer. NOT supported by er9x/erskyTX use MULTI_STATUS instead.
#define MULTI_TELEMETRY
//Send to OpenTX the current protocol and subprotocol names. Comment to disable.
#define MULTI_NAMES
//Work in progress: Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Uncomment to enable.
//#define MULTI_SYNC