1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-190: Final testing and bug fixes.

This commit is contained in:
Brian Webb 2016-07-09 14:57:22 -07:00
parent 91ea8966da
commit 0738c8a78a
12 changed files with 62 additions and 48 deletions

View File

@ -157,17 +157,17 @@ static void systemTask(__attribute__((unused)) void *parameters)
if (pios_rfm22b_id) {
// Update the status
oplinkStatus.DeviceID = PIOS_RFM22B_DeviceID(pios_rfm22b_id);
oplinkStatus.RxGood = radio_stats.rx_good;
oplinkStatus.RxCorrected = radio_stats.rx_corrected;
oplinkStatus.RxErrors = radio_stats.rx_error;
oplinkStatus.RxMissed = radio_stats.rx_missed;
oplinkStatus.RxFailure = radio_stats.rx_failure;
oplinkStatus.TxDropped = radio_stats.tx_dropped;
oplinkStatus.TxFailure = radio_stats.tx_failure;
oplinkStatus.DeviceID = PIOS_RFM22B_DeviceID(pios_rfm22b_id);
oplinkStatus.RxGood = radio_stats.rx_good;
oplinkStatus.RxCorrected = radio_stats.rx_corrected;
oplinkStatus.RxErrors = radio_stats.rx_error;
oplinkStatus.RxMissed = radio_stats.rx_missed;
oplinkStatus.RxFailure = radio_stats.rx_failure;
oplinkStatus.TxDropped = radio_stats.tx_dropped;
oplinkStatus.TxFailure = radio_stats.tx_failure;
oplinkStatus.Resets = radio_stats.resets;
oplinkStatus.Timeouts = radio_stats.timeouts;
oplinkStatus.RSSI = radio_stats.rssi;
oplinkStatus.RSSI = radio_stats.rssi;
oplinkStatus.LinkQuality = radio_stats.link_quality;
if (first_time) {
first_time = false;
@ -190,8 +190,6 @@ static void systemTask(__attribute__((unused)) void *parameters)
oplinkStatus.TXSeq = radio_stats.tx_seq;
oplinkStatus.RXSeq = radio_stats.rx_seq;
oplinkStatus.LinkState = radio_stats.link_state;
} else {
oplinkStatus.LinkState = OPLINKSTATUS_LINKSTATE_DISABLED;
}
if (radio_stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED) {

View File

@ -170,13 +170,13 @@ static int32_t RadioComBridgeStart(void)
}
// Configure our UAVObjects for updates.
UAVObjConnectQueue(UAVObjGetByID(OPLINKSTATUS_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ);
UAVObjConnectQueue(UAVObjGetByID(OBJECTPERSISTENCE_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL);
if (data->isCoordinator) {
UAVObjConnectQueue(UAVObjGetByID(OPLINKRECEIVER_OBJID), data->radioEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ);
} else {
UAVObjConnectQueue(UAVObjGetByID(OPLINKRECEIVER_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ);
}
registerObject(OPLinkStatusHandle());
if (data->isCoordinator) {
registerObject(RadioComBridgeStatsHandle());

View File

@ -283,17 +283,17 @@ static void systemTask(__attribute__((unused)) void *parameters)
static uint16_t prev_tx_seq = 0;
static uint16_t prev_rx_seq = 0;
oplinkStatus.DeviceID = PIOS_RFM22B_DeviceID(pios_rfm22b_id);
oplinkStatus.RxGood = radio_stats.rx_good;
oplinkStatus.RxCorrected = radio_stats.rx_corrected;
oplinkStatus.RxErrors = radio_stats.rx_error;
oplinkStatus.RxMissed = radio_stats.rx_missed;
oplinkStatus.RxFailure = radio_stats.rx_failure;
oplinkStatus.TxDropped = radio_stats.tx_dropped;
oplinkStatus.TxFailure = radio_stats.tx_failure;
oplinkStatus.DeviceID = PIOS_RFM22B_DeviceID(pios_rfm22b_id);
oplinkStatus.RxGood = radio_stats.rx_good;
oplinkStatus.RxCorrected = radio_stats.rx_corrected;
oplinkStatus.RxErrors = radio_stats.rx_error;
oplinkStatus.RxMissed = radio_stats.rx_missed;
oplinkStatus.RxFailure = radio_stats.rx_failure;
oplinkStatus.TxDropped = radio_stats.tx_dropped;
oplinkStatus.TxFailure = radio_stats.tx_failure;
oplinkStatus.Resets = radio_stats.resets;
oplinkStatus.Timeouts = radio_stats.timeouts;
oplinkStatus.RSSI = radio_stats.rssi;
oplinkStatus.RSSI = radio_stats.rssi;
oplinkStatus.LinkQuality = radio_stats.link_quality;
if (first_time) {
first_time = false;

View File

@ -272,7 +272,7 @@ int32_t TelemetryInitialize(void)
OPLinkSettingsData data;
OPLinkSettingsGet(&data);
bool ppm_only = (data.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
bool ppm_only = (data.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
if (ppm_only) {
radio_port = 0;
} else {

View File

@ -57,8 +57,6 @@ static uint8_t rfmGetRSSI(struct pios_openlrs_dev *openlrs_dev);
static void to_rx_mode(struct pios_openlrs_dev *openlrs_dev);
static void tx_packet(struct pios_openlrs_dev *openlrs_dev, uint8_t *pkt, uint8_t size);
static OPLinkStatusData oplink_status;
static struct pios_openlrs_dev *pios_openlrs_alloc();
static bool pios_openlrs_validate(struct pios_openlrs_dev *openlrs_dev);
@ -789,6 +787,9 @@ static void pios_openlrs_setup(struct pios_openlrs_dev *openlrs_dev, bool bind)
printVersion(OPENLRSNG_VERSION);
#endif
// Get the OPLinkStatus UAVO
OPLinkStatusData oplink_status;
OPLinkStatusGet(&oplink_status);
if (bind) {
oplink_status.LinkState = OPLINKSTATUS_LINKSTATE_BINDING;
if (pios_openlrs_bind_receive(openlrs_dev, 0)) {
@ -817,6 +818,9 @@ static void pios_openlrs_setup(struct pios_openlrs_dev *openlrs_dev, bool bind)
openlrs_dev->link_acquired = 0;
openlrs_dev->lastPacketTimeUs = micros();
// Update the OPLinkStatus UAVO
OPLinkStatusSet(&oplink_status);
DEBUG_PRINTF(2, "OpenLRSng RX setup complete\r\n");
}
@ -835,6 +839,13 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
to_rx_mode(openlrs_dev);
}
// Get the OPLinkStatus UAVO
OPLinkStatusData oplink_status;
OPLinkStatusGet(&oplink_status);
// Update the RSSI
oplink_status.RSSI = openlrs_dev->rssi;
timeUs = micros();
timeMs = millis();
@ -922,7 +933,7 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
tx_buf[0] |= (0x37 + bytes);
} else {
// tx_buf[0] lowest 6 bits left at 0
tx_buf[1] = oplink_status.RSSI;
tx_buf[1] = openlrs_dev->rssi;
if (FlightBatteryStateHandle()) {
FlightBatteryStateData bat;
FlightBatteryStateGet(&bat);
@ -1043,6 +1054,11 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
uint8_t PIOS_OpenLRS_RSSI_Get(void)
{
// Get the OPLinkStatus UAVO
OPLinkStatusData oplink_status;
OPLinkStatusGet(&oplink_status);
if (oplink_status.LinkState != OPLINKSTATUS_LINKSTATE_CONNECTED) {
return 0;
} else {
@ -1286,9 +1302,9 @@ static void pios_openlrs_task(void *parameters)
// We timed out to sample RSSI
if (openlrs_dev->numberOfLostPackets < 2) {
openlrs_dev->lastRSSITimeUs = openlrs_dev->lastPacketTimeUs;
oplink_status.RSSI = rfmGetRSSI(openlrs_dev); // Read the RSSI value
openlrs_dev->rssi = rfmGetRSSI(openlrs_dev); // Read the RSSI value
// DEBUG_PRINTF(3, "Sampled RSSI: %d %d\r\n", oplink_status.RSSI, delay);
// DEBUG_PRINTF(3, "Sampled RSSI: %d %d\r\n", openlrs_dev->RSSI, delay);
}
} else {
// We timed out because packet was missed

View File

@ -602,7 +602,6 @@ void PIOS_RFM22B_SetChannelConfig(uint32_t rfm22b_id, enum rfm22b_datarate datar
if (!PIOS_RFM22B_Validate(rfm22b_dev)) {
return;
}
ppm_mode = ppm_mode;
rfm22b_dev->coordinator = coordinator;
rfm22b_dev->ppm_send_mode = ppm_mode && coordinator;
rfm22b_dev->ppm_recv_mode = ppm_mode && !coordinator;

View File

@ -184,6 +184,8 @@ struct pios_openlrs_dev {
uint8_t rx_buf[64];
uint8_t tx_buf[9];
int8_t rssi;
// Variables from OpenLRS for radio control
uint8_t hopcount;
uint32_t lastPacketTimeUs;

View File

@ -230,8 +230,8 @@ void PIOS_Board_Init(void)
bool ppm_only = (oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
bool data_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATA) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool is_enabled = ((oplinkSettings.Protocol != OPLINKSETTINGS_PROTOCOL_DISABLED) &&
((oplinkSettings.MaxRFPower != OPLINKSETTINGS_MAXRFPOWER_0) || openlrs));
bool is_enabled = ((oplinkSettings.Protocol != OPLINKSETTINGS_PROTOCOL_DISABLED) &&
((oplinkSettings.MaxRFPower != OPLINKSETTINGS_MAXRFPOWER_0) || openlrs));
bool ppm_mode = false;
bool servo_main = false;
bool servo_flexi = false;

View File

@ -850,12 +850,12 @@ void PIOS_Board_Init(void)
/* Is the radio turned on? */
bool is_coordinator = (oplinkSettings.Protocol == OPLINKSETTINGS_PROTOCOL_OPLINKCOORDINATOR);
bool openlrs = (oplinkSettings.Protocol == OPLINKSETTINGS_PROTOCOL_OPENLRS);
bool data_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATA) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool ppm_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool ppm_only = (oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
bool openlrs = (oplinkSettings.Protocol == OPLINKSETTINGS_PROTOCOL_OPENLRS);
bool data_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATA) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool ppm_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool ppm_only = (oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
bool is_enabled = ((oplinkSettings.Protocol != OPLINKSETTINGS_PROTOCOL_DISABLED) &&
((oplinkSettings.MaxRFPower != OPLINKSETTINGS_MAXRFPOWER_0) || openlrs));
if (is_enabled) {

View File

@ -790,12 +790,12 @@ void PIOS_Board_Init(void)
/* Is the radio turned on? */
bool is_coordinator = (oplinkSettings.Protocol == OPLINKSETTINGS_PROTOCOL_OPLINKCOORDINATOR);
bool openlrs = (oplinkSettings.Protocol == OPLINKSETTINGS_PROTOCOL_OPENLRS);
bool data_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATA) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool ppm_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool ppm_only = (oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
bool openlrs = (oplinkSettings.Protocol == OPLINKSETTINGS_PROTOCOL_OPENLRS);
bool data_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATA) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool ppm_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL) ||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
bool ppm_only = (oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
bool is_enabled = ((oplinkSettings.Protocol != OPLINKSETTINGS_PROTOCOL_DISABLED) &&
((oplinkSettings.MaxRFPower != OPLINKSETTINGS_MAXRFPOWER_0) || openlrs));
if (is_enabled) {

View File

@ -259,8 +259,8 @@ void ConfigOPLinkWidget::protocolChanged()
bool is_receiver = isComboboxOptionSelected(m_oplink->Protocol, OPLinkSettings::PROTOCOL_OPLINKRECEIVER);
bool is_openlrs = isComboboxOptionSelected(m_oplink->Protocol, OPLinkSettings::PROTOCOL_OPENLRS);
bool is_ppm_only = isComboboxOptionSelected(m_oplink->LinkType, OPLinkSettings::LINKTYPE_CONTROL);
bool is_oplm = m_oplink->MainPort->isVisible();
bool is_bound = (m_oplink->CoordID->text() != "");
bool is_oplm = m_oplink->MainPort->isVisible();
bool is_bound = (m_oplink->CoordID->text() != "");
m_oplink->ComSpeed->setEnabled(!is_ppm_only && is_oplm && !is_openlrs && is_enabled);
m_oplink->CoordID->setEnabled(is_receiver & is_enabled);
@ -268,8 +268,8 @@ void ConfigOPLinkWidget::protocolChanged()
m_oplink->CustomDeviceID->setEnabled(is_coordinator);
m_oplink->MinimumChannel->setEnabled(is_receiver || is_coordinator);
m_oplink->MaximumChannel->setEnabled(is_receiver || is_coordinator);
m_oplink->MainPort->setEnabled((is_receiver || is_coordinator) && is_oplm);
m_oplink->FlexiPort->setEnabled((is_receiver || is_coordinator) && is_oplm);
m_oplink->MainPort->setEnabled(is_oplm);
m_oplink->FlexiPort->setEnabled(is_oplm);
m_oplink->VCPPort->setEnabled((is_receiver || is_coordinator) && is_oplm);
m_oplink->LinkType->setEnabled(is_enabled && !is_openlrs);
m_oplink->MaxRFTxPower->setEnabled(is_enabled && !is_openlrs);
@ -346,7 +346,6 @@ void ConfigOPLinkWidget::updateCustomDeviceID()
void ConfigOPLinkWidget::unbind()
{
if (settingsUpdated) {
// Clear the coordinator ID
oplinkSettingsObj->getField("CoordID")->setValue(0);
m_oplink->CoordID->setText("0");

View File

@ -31,7 +31,7 @@
<access gcs="readonly" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>
<telemetryflight acked="false" updatemode="throttled" period="500"/>
<telemetryflight acked="false" updatemode="periodic" period="500"/>
<logging updatemode="manual" period="0"/>
</object>
</xml>