mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-11 19:24:10 +01:00
RM: Now doesn't crash when the radio is disabled.
This commit is contained in:
parent
0dd8caeec0
commit
c4c58331e5
@ -567,8 +567,10 @@ int32_t PIOS_RFM22B_Init(uint32_t *rfm22b_id, uint32_t spi_id, uint32_t slave_nu
|
|||||||
rfm22b_dev->send_ppm = false;
|
rfm22b_dev->send_ppm = false;
|
||||||
rfm22b_dev->datarate = RFM22B_DEFAULT_RX_DATARATE;
|
rfm22b_dev->datarate = RFM22B_DEFAULT_RX_DATARATE;
|
||||||
|
|
||||||
// Initialize the com configuration callback.
|
// Initialize the com callbacks.
|
||||||
rfm22b_dev->com_config_cb = NULL;
|
rfm22b_dev->com_config_cb = NULL;
|
||||||
|
rfm22b_dev->rx_in_cb = NULL;
|
||||||
|
rfm22b_dev->tx_out_cb = NULL;
|
||||||
|
|
||||||
// Initialize the stats.
|
// Initialize the stats.
|
||||||
rfm22b_dev->stats.packets_per_sec = 0;
|
rfm22b_dev->stats.packets_per_sec = 0;
|
||||||
@ -1319,9 +1321,8 @@ static bool rfm22_ready_to_send(struct pios_rfm22b_dev *rfm22b_dev)
|
|||||||
if (dp->header.data_size > 0)
|
if (dp->header.data_size > 0)
|
||||||
return true;
|
return true;
|
||||||
bool need_yield = false;
|
bool need_yield = false;
|
||||||
dp->header.data_size =
|
if (rfm22b_dev->tx_out_cb)
|
||||||
(rfm22b_dev->tx_out_cb)(rfm22b_dev->tx_out_context, dp->data,
|
dp->header.data_size = (rfm22b_dev->tx_out_cb)(rfm22b_dev->tx_out_context, dp->data, PH_MAX_DATA, NULL, &need_yield);
|
||||||
PH_MAX_DATA, NULL, &need_yield);
|
|
||||||
if (dp->header.data_size > 0)
|
if (dp->header.data_size > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -1375,9 +1376,8 @@ static enum pios_rfm22b_event rfm22_txStart(struct pios_rfm22b_dev *rfm22b_dev)
|
|||||||
p = &rfm22b_dev->data_packet;
|
p = &rfm22b_dev->data_packet;
|
||||||
p->header.type = PACKET_TYPE_DATA;
|
p->header.type = PACKET_TYPE_DATA;
|
||||||
p->header.destination_id = rfm22b_dev->destination_id;
|
p->header.destination_id = rfm22b_dev->destination_id;
|
||||||
if (p->header.data_size == 0)
|
if (rfm22b_dev->tx_out_cb && (p->header.data_size == 0))
|
||||||
p->header.data_size = (rfm22b_dev->tx_out_cb)(rfm22b_dev->tx_out_context, p->data,
|
p->header.data_size = (rfm22b_dev->tx_out_cb)(rfm22b_dev->tx_out_context, p->data, PH_MAX_DATA, NULL, &need_yield);
|
||||||
PH_MAX_DATA, NULL, &need_yield);
|
|
||||||
|
|
||||||
// Don't send any data until we're connected.
|
// Don't send any data until we're connected.
|
||||||
if (rfm22b_dev->stats.link_state != OPLINKSTATUS_LINKSTATE_CONNECTED)
|
if (rfm22b_dev->stats.link_state != OPLINKSTATUS_LINKSTATE_CONNECTED)
|
||||||
@ -1766,6 +1766,7 @@ static enum pios_rfm22b_event rfm22_rxData(struct pios_rfm22b_dev *rfm22b_dev)
|
|||||||
{
|
{
|
||||||
// Send the data to the com port
|
// Send the data to the com port
|
||||||
bool rx_need_yield;
|
bool rx_need_yield;
|
||||||
|
if (rfm22b_dev->rx_in_cb)
|
||||||
(rfm22b_dev->rx_in_cb)(rfm22b_dev->rx_in_context, rfm22b_dev->rx_packet.data, rfm22b_dev->rx_packet.header.data_size, NULL, &rx_need_yield);
|
(rfm22b_dev->rx_in_cb)(rfm22b_dev->rx_in_context, rfm22b_dev->rx_packet.data, rfm22b_dev->rx_packet.header.data_size, NULL, &rx_need_yield);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -637,15 +637,6 @@ void PIOS_Board_Init(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the packet handler
|
|
||||||
PacketHandlerConfig pios_ph_cfg = {
|
|
||||||
.default_destination_id = 0xffffffff, // Broadcast
|
|
||||||
.source_id = PIOS_RFM22B_DeviceID(pios_rfm22b_id),
|
|
||||||
.win_size = PIOS_PH_WIN_SIZE,
|
|
||||||
.max_connections = PIOS_PH_MAX_CONNECTIONS,
|
|
||||||
};
|
|
||||||
pios_packet_handler = PHInitialize(&pios_ph_cfg);
|
|
||||||
#endif /* PIOS_INCLUDE_RFM22B */
|
#endif /* PIOS_INCLUDE_RFM22B */
|
||||||
|
|
||||||
/* Configure the receiver port*/
|
/* Configure the receiver port*/
|
||||||
|
Loading…
Reference in New Issue
Block a user