mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 21:08:12 +00:00
Q90C: checksum fix
This commit is contained in:
parent
a10e169573
commit
b9f00bdbc5
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_REVISION 1
|
||||
#define VERSION_PATCH_LEVEL 3
|
||||
#define VERSION_PATCH_LEVEL 4
|
||||
|
||||
//******************
|
||||
// Protocols
|
||||
|
@ -192,13 +192,6 @@ static void __attribute__((unused)) XN297L_WriteEnhancedPayload(uint8_t* msg, ui
|
||||
static uint8_t pid=0;
|
||||
|
||||
// address
|
||||
if (xn297_addr_len < 4)
|
||||
{
|
||||
// If address length (which is defined by receive address length)
|
||||
// is less than 4 the TX address can't fit the preamble, so the last
|
||||
// byte goes here
|
||||
buf[last++] = 0x55;
|
||||
}
|
||||
for (uint8_t i = 0; i < xn297_addr_len; ++i)
|
||||
{
|
||||
buf[last] = xn297_tx_addr[xn297_addr_len-i-1];
|
||||
@ -235,9 +228,8 @@ static void __attribute__((unused)) XN297L_WriteEnhancedPayload(uint8_t* msg, ui
|
||||
// crc
|
||||
//if (xn297_crc)
|
||||
{
|
||||
uint8_t offset = xn297_addr_len < 4 ? 1 : 0;
|
||||
uint16_t crc = 0xb5d2;
|
||||
for (uint8_t i = offset; i < last; ++i)
|
||||
for (uint8_t i = 0; i < last; ++i)
|
||||
crc = crc16_update(crc, buf[i], 8);
|
||||
crc = crc16_update(crc, buf[last] & 0xc0, 2);
|
||||
if (xn297_scramble_enabled)
|
||||
|
@ -47,13 +47,11 @@ static void __attribute__((unused)) Q90C_send_packet()
|
||||
packet[8] = 0;
|
||||
packet[9] = 0;
|
||||
packet[10] = rx_tx_addr[4];
|
||||
packet[11] = 0x3a; // initial checksum value ?
|
||||
}
|
||||
else
|
||||
{
|
||||
XN297L_Hopping(hopping_frequency_no++); // RF Freq
|
||||
if (hopping_frequency_no >= Q90C_RF_NUM_CHANNELS)
|
||||
hopping_frequency_no = 0;
|
||||
hopping_frequency_no %= Q90C_RF_NUM_CHANNELS;
|
||||
packet[0]= convert_channel_8b(THROTTLE); // 0..255
|
||||
// A,E,R have weird scaling, 0x00-0xff range (unsigned) but center isn't 7f or 80
|
||||
// rudder ff-7a-00
|
||||
@ -83,16 +81,21 @@ static void __attribute__((unused)) Q90C_send_packet()
|
||||
packet[8] = 0x00; // flags: 3 position flight mode (Angle - Horizon - Acro), VTX Toggle HIGH = next vTX frequency
|
||||
packet[9] = 0x00;
|
||||
packet[10] = packet_count++;
|
||||
packet[11] = 0x9c; // initial checksum value ?
|
||||
}
|
||||
|
||||
uint8_t sum=0;
|
||||
// checksum
|
||||
for (uint8_t i = 0; i < Q90C_PACKET_SIZE - 1; i++)
|
||||
packet[11] += packet[i];
|
||||
{
|
||||
sum += packet[i];
|
||||
debug("%02X ", packet[i]);
|
||||
}
|
||||
packet[11] = sum ^ (IS_BIND_IN_PROGRESS? 0xc6 : 0xa4);
|
||||
debugln("%02X",packet[11]);
|
||||
|
||||
XN297L_SetFreqOffset(); // Set frequency offset
|
||||
XN297L_WriteEnhancedPayload(packet, Q90C_PACKET_SIZE, 0);
|
||||
XN297L_SetPower(); // Set tx_power
|
||||
XN297L_WriteEnhancedPayload(packet, Q90C_PACKET_SIZE, 0);
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) Q90C_initialize_txid()
|
||||
|
Loading…
x
Reference in New Issue
Block a user