Fix buffer overrun and freezing bugs
This commit is contained in:
parent
858a35b2f9
commit
f6fe7e2b5f
3
Config.h
3
Config.h
@ -80,8 +80,7 @@
|
||||
bool memory_low = false;
|
||||
uint8_t implicit_l = 0;
|
||||
|
||||
volatile bool packet_ready = false;
|
||||
volatile uint8_t packet_interface = 0xFF;
|
||||
uint8_t packet_interface = 0xFF;
|
||||
|
||||
uint8_t op_mode = MODE_HOST;
|
||||
uint8_t model = 0x00;
|
||||
|
@ -79,8 +79,8 @@ typedef struct {
|
||||
size_t len;
|
||||
int rssi;
|
||||
int snr_raw;
|
||||
uint8_t data[];
|
||||
uint8_t interface;
|
||||
uint8_t data[];
|
||||
} modem_packet_t;
|
||||
static xQueueHandle modem_packet_queue = NULL;
|
||||
|
||||
@ -392,7 +392,7 @@ inline void getPacketData(RadioInterface* radio, uint16_t len) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool queuePacket(RadioInterface* radio, uint8_t index) {
|
||||
inline bool queue_packet(RadioInterface* radio, uint8_t index) {
|
||||
// Allocate packet struct, but abort if there
|
||||
// is not enough memory available.
|
||||
modem_packet_t *modem_packet = (modem_packet_t*)malloc(sizeof(modem_packet_t) + read_len);
|
||||
@ -413,7 +413,9 @@ inline bool queuePacket(RadioInterface* radio, uint8_t index) {
|
||||
memcpy(modem_packet->data, pbuf, read_len);
|
||||
if (!modem_packet_queue || xQueueSendFromISR(modem_packet_queue, &modem_packet, NULL) != pdPASS) {
|
||||
free(modem_packet);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ISR_VECT receive_callback(uint8_t index, int packet_size) {
|
||||
@ -500,7 +502,7 @@ void ISR_VECT receive_callback(uint8_t index, int packet_size) {
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
queuePacket(selected_radio, index);
|
||||
queue_packet(selected_radio, index);
|
||||
}
|
||||
|
||||
last_rx = millis();
|
||||
|
@ -129,7 +129,7 @@ sx126x::sx126x(uint8_t index, SPIClass* spi, bool tcxo, bool dio2_as_rf_switch,
|
||||
setTimeout(0);
|
||||
// TODO, figure out why this has to be done. Using the index to reference the
|
||||
// interface_obj list causes a crash otherwise
|
||||
_index = getIndex();
|
||||
//_index = getIndex();
|
||||
}
|
||||
|
||||
bool sx126x::preInit() {
|
||||
@ -1098,7 +1098,7 @@ sx127x::sx127x(uint8_t index, SPIClass* spi, int ss, int sclk, int mosi, int mis
|
||||
setTimeout(0);
|
||||
// TODO, figure out why this has to be done. Using the index to reference the
|
||||
// interface_obj list causes a crash otherwise
|
||||
_index = getIndex();
|
||||
//_index = getIndex();
|
||||
}
|
||||
|
||||
void sx127x::setSPIFrequency(uint32_t frequency) { _spiSettings = SPISettings(frequency, MSBFIRST, SPI_MODE0); }
|
||||
@ -1628,7 +1628,7 @@ sx128x::sx128x(uint8_t index, SPIClass* spi, bool tcxo, int ss, int sclk, int mo
|
||||
setTimeout(0);
|
||||
// TODO, figure out why this has to be done. Using the index to reference the
|
||||
// interface_obj list causes a crash otherwise
|
||||
_index = getIndex();
|
||||
//_index = getIndex();
|
||||
}
|
||||
|
||||
bool sx128x::preInit() {
|
||||
|
@ -451,7 +451,6 @@ private:
|
||||
int _fifo_tx_addr_ptr;
|
||||
int _fifo_rx_addr_ptr;
|
||||
bool _preinit_done;
|
||||
uint8_t _index;
|
||||
bool _tcxo;
|
||||
bool _dio2_as_rf_switch;
|
||||
};
|
||||
@ -545,7 +544,6 @@ private:
|
||||
int _packetIndex;
|
||||
int _implicitHeaderMode;
|
||||
bool _preinit_done;
|
||||
uint8_t _index;
|
||||
uint8_t _sf;
|
||||
uint8_t _cr;
|
||||
};
|
||||
@ -664,7 +662,6 @@ private:
|
||||
int _fifo_rx_addr_ptr;
|
||||
bool _preinit_done;
|
||||
int _rxPacketLength;
|
||||
uint8_t _index;
|
||||
bool _tcxo;
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user