From d1feef97be4a240c343db34bc8c359d490e604bf Mon Sep 17 00:00:00 2001 From: Pascal Langer Date: Sat, 13 Jun 2020 16:20:51 +0200 Subject: [PATCH] DSM: adjust end points, solve SAFE? --- Multiprotocol/DSM_Rx_cyrf6936.ino | 11 ++++++++++- Multiprotocol/DSM_cyrf6936.ino | 12 ++++++------ Multiprotocol/Multiprotocol.h | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Multiprotocol/DSM_Rx_cyrf6936.ino b/Multiprotocol/DSM_Rx_cyrf6936.ino index e4326b7..59452a7 100644 --- a/Multiprotocol/DSM_Rx_cyrf6936.ino +++ b/Multiprotocol/DSM_Rx_cyrf6936.ino @@ -18,6 +18,7 @@ Multiprotocol is distributed in the hope that it will be useful, #include "iface_cyrf6936.h" //#define DSM_DEBUG_RF +//#define DSM_DEBUG_CH uint8_t DSM_rx_type; @@ -85,6 +86,11 @@ static uint8_t __attribute__((unused)) DSM_Rx_check_packet() packet[0] ^= 0xff; packet[1] ^= 0xff; } + #ifdef DSM_DEBUG_CH + for(uint8_t i=0;i>nbr_bits; // retrieve channel index 0..12 + idx=(value&0x7FFF)>>nbr_bits; // retrieve channel index + #ifdef DSM_DEBUG_CH + debugln("i=%d,v=%d,u=%X",idx,value&0x7FF,value&0x8000); + #endif if(idx<13) { if(nbr_bits==10) value <<= 1; // switch to 11 bits diff --git a/Multiprotocol/DSM_cyrf6936.ino b/Multiprotocol/DSM_cyrf6936.ino index 2b3213b..bb5cb32 100644 --- a/Multiprotocol/DSM_cyrf6936.ino +++ b/Multiprotocol/DSM_cyrf6936.ino @@ -54,12 +54,12 @@ const uint8_t PROGMEM DSM_ch_map_progmem[][14] = { {1, 5, 2, 3, 6, 0xff, 0xff, 4, 0, 7, 8, 0xff, 0xff, 0xff}, //9ch - Guess {1, 5, 2, 3, 6, 0xff, 0xff, 4, 0, 7, 8, 9, 0xff, 0xff}, //10ch - Guess {1, 5, 2, 3, 6, 10, 0xff, 4, 0, 7, 8, 9, 0xff, 0xff}, //11ch - Guess - {1, 5, 2, 4, 6, 10, 0xff, 0, 7, 3, 8, 9 , 11 , 0xff}, //12ch - DX18 + {1, 5, 2, 4, 6, 10, 0xff, 0, 7, 3, 8, 9 , 11 , 0xff}, //12ch - DX18/DX8G2 //11ms for 8..11 channels {1, 5, 2, 3, 6, 7, 0xff, 1, 5, 2, 4, 0, 0xff, 0xff}, //8ch - DX7 {1, 5, 2, 3, 6, 7, 0xff, 1, 5, 2, 4, 0, 8, 0xff}, //9ch - Guess - {1, 5, 2, 3, 4, 8, 9, 1, 5, 2, 3, 0, 7, 6 }, //10ch - DX18 - {1, 5, 2, 3, 4, 8, 9, 1, 10, 2, 3, 0, 7, 6 }, //11ch - Guess + {1, 5, 2, 3, 4, 8, 9, 1, 5, 2, 3, 0, 7, 6 }, //10ch - DX18 + {1, 5, 2, 3, 4, 8, 9, 1, 10, 2, 3, 0, 7, 6 }, //11ch - Guess }; static void __attribute__((unused)) DSM_build_bind_packet() @@ -179,7 +179,7 @@ static void __attribute__((unused)) DSM_build_data_packet(uint8_t upper) if(option & 0x80) value=Channel_data[CH_TAER[idx]]; // -100%..+100% => 1024..1976us and -125%..+125% => 904..2096us based on Redcon 6 channel DSM2 RX else - value=convert_channel_16b_nolimit(CH_TAER[idx],0x150,0x6B0); // -100%..+100% => 1100..1900us and -125%..+125% => 1000..2000us based on Redcon 6 channel DSM2 RX + value=convert_channel_16b_nolimit(CH_TAER[idx],0x156,0x6AA); // -100%..+100% => 1100..1900us and -125%..+125% => 1000..2000us based on a DX8 G2 dump #endif if(bits==10) value>>=1; value |= (upper && i==0 ? 0x8000 : 0) | (idx << bits); @@ -191,7 +191,7 @@ static void __attribute__((unused)) DSM_build_data_packet(uint8_t upper) static uint8_t __attribute__((unused)) DSM_Check_RX_packet() { - uint8_t result=1; // assume good packet + uint8_t result=1; // assume good packet uint16_t sum = 384 - 0x10; for(uint8_t i = 1; i < 9; i++) @@ -199,7 +199,7 @@ static uint8_t __attribute__((unused)) DSM_Check_RX_packet() sum += packet_in[i]; if(i<5) if(packet_in[i] != (0xff ^ cyrfmfg_id[i-1])) - result=0; // bad packet + result=0; // bad packet } if( packet_in[9] != (sum>>8) && packet_in[10] != (uint8_t)sum ) result=0; diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 363c40a..263a5af 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 1 -#define VERSION_PATCH_LEVEL 17 +#define VERSION_PATCH_LEVEL 18 //****************** // Protocols