mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
LP-190: Moved openlrsstatus UAVO to OPLinkStatus
This commit is contained in:
parent
dc17bd9ad8
commit
021eb21008
@ -43,7 +43,7 @@
|
||||
#include "openlrs.h"
|
||||
#include "flightstatus.h"
|
||||
#include "flightbatterystate.h"
|
||||
#include "openlrsstatus.h"
|
||||
#include "oplinkstatus.h"
|
||||
|
||||
#include "pios_rfm22b_regs.h"
|
||||
|
||||
@ -56,7 +56,8 @@ static void rfmSetCarrierFrequency(struct pios_openlrs_dev *openlrs_dev, uint32_
|
||||
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 OpenLRSStatusData openlrs_status;
|
||||
|
||||
static OPLinkStatusData oplink_status;
|
||||
|
||||
static struct pios_openlrs_dev *pios_openlrs_alloc();
|
||||
static bool pios_openlrs_validate(struct pios_openlrs_dev *openlrs_dev);
|
||||
@ -858,8 +859,8 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
|
||||
|
||||
openlrs_dev->lastPacketTimeUs = timeUs;
|
||||
openlrs_dev->numberOfLostPackets = 0;
|
||||
openlrs_status.LinkQuality <<= 1;
|
||||
openlrs_status.LinkQuality |= 1;
|
||||
oplink_status.LinkQuality <<= 1;
|
||||
oplink_status.LinkQuality |= 1;
|
||||
|
||||
if ((openlrs_dev->rx_buf[0] & 0x3e) == 0x00) {
|
||||
// This flag indicates receiving PPM data
|
||||
@ -890,7 +891,7 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
|
||||
|
||||
// Flag to indicate ever got a link
|
||||
openlrs_dev->link_acquired |= true;
|
||||
openlrs_status.FailsafeActive = OPENLRSSTATUS_FAILSAFEACTIVE_INACTIVE;
|
||||
oplink_status.LinkState = OPLINKSTATUS_LINKSTATE_CONNECTED;
|
||||
openlrs_dev->beacon_armed = false; // when receiving packets make sure beacon cannot emit
|
||||
|
||||
// When telemetry is enabled we ack packets and send info about FC back
|
||||
@ -914,7 +915,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] = openlrs_status.LastRSSI;
|
||||
tx_buf[1] = oplink_status.RSSI;
|
||||
if (FlightBatteryStateHandle()) {
|
||||
FlightBatteryStateData bat;
|
||||
FlightBatteryStateGet(&bat);
|
||||
@ -928,7 +929,7 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
|
||||
}
|
||||
tx_buf[4] = (openlrs_dev->lastAFCCvalue >> 8);
|
||||
tx_buf[5] = openlrs_dev->lastAFCCvalue & 0xff;
|
||||
tx_buf[6] = countSetBits(openlrs_status.LinkQuality & 0x7fff);
|
||||
tx_buf[6] = countSetBits(oplink_status.LinkQuality & 0x7fff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -949,7 +950,7 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
|
||||
if ((openlrs_dev->numberOfLostPackets < openlrs_dev->hopcount) && (PIOS_DELAY_GetuSSince(openlrs_dev->lastPacketTimeUs) > (getInterval(&openlrs_dev->bind_data) + packet_timeout_us))) {
|
||||
DEBUG_PRINTF(2, "OLRS WARN: Lost packet: %d\r\n", openlrs_dev->numberOfLostPackets);
|
||||
// we lost packet, hop to next channel
|
||||
openlrs_status.LinkQuality <<= 1;
|
||||
oplink_status.LinkQuality <<= 1;
|
||||
openlrs_dev->willhop = 1;
|
||||
if (openlrs_dev->numberOfLostPackets == 0) {
|
||||
openlrs_dev->linkLossTimeMs = timeMs;
|
||||
@ -961,7 +962,7 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
|
||||
} else if ((openlrs_dev->numberOfLostPackets >= openlrs_dev->hopcount) && (PIOS_DELAY_GetuSSince(openlrs_dev->lastPacketTimeUs) > (getInterval(&openlrs_dev->bind_data) * openlrs_dev->hopcount))) {
|
||||
DEBUG_PRINTF(2, "ORLS WARN: Trying to resync\r\n");
|
||||
// hop slowly to allow resync with TX
|
||||
openlrs_status.LinkQuality = 0;
|
||||
oplink_status.LinkQuality = 0;
|
||||
openlrs_dev->willhop = 1;
|
||||
openlrs_dev->lastPacketTimeUs = timeUs;
|
||||
}
|
||||
@ -972,10 +973,10 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
|
||||
#endif /* PIOS_LED_LINK */
|
||||
|
||||
if (openlrs_dev->failsafeDelay &&
|
||||
(openlrs_status.FailsafeActive == OPENLRSSTATUS_FAILSAFEACTIVE_INACTIVE) &&
|
||||
(oplink_status.LinkState == OPLINKSTATUS_LINKSTATE_CONNECTED) &&
|
||||
((timeMs - openlrs_dev->linkLossTimeMs) > ((uint32_t)openlrs_dev->failsafeDelay))) {
|
||||
DEBUG_PRINTF(2, "Failsafe activated: %d %d\r\n", timeMs, openlrs_dev->linkLossTimeMs);
|
||||
openlrs_status.FailsafeActive = OPENLRSSTATUS_FAILSAFEACTIVE_ACTIVE;
|
||||
oplink_status.LinkState = OPLINKSTATUS_LINKSTATE_DISCONNECTED;
|
||||
// failsafeApply();
|
||||
openlrs_dev->nextBeaconTimeMs = (timeMs + 1000UL * openlrs_dev->beacon_period) | 1; // beacon activating...
|
||||
}
|
||||
@ -1030,18 +1031,18 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
|
||||
}
|
||||
|
||||
// Update UAVO
|
||||
OpenLRSStatusSet(&openlrs_status);
|
||||
OPLinkStatusSet(&oplink_status);
|
||||
}
|
||||
|
||||
uint8_t PIOS_OpenLRS_RSSI_Get(void)
|
||||
{
|
||||
if (openlrs_status.FailsafeActive == OPENLRSSTATUS_FAILSAFEACTIVE_ACTIVE) {
|
||||
if (oplink_status.LinkState != OPLINKSTATUS_LINKSTATE_CONNECTED) {
|
||||
return 0;
|
||||
} else {
|
||||
OpenLRSData openlrs_data;
|
||||
OpenLRSGet(&openlrs_data);
|
||||
|
||||
uint16_t LQ = openlrs_status.LinkQuality & 0x7fff;
|
||||
uint16_t LQ = oplink_status.LinkQuality & 0x7fff;
|
||||
// count number of 1s in LinkQuality
|
||||
LQ = LQ - ((LQ >> 1) & 0x5555);
|
||||
LQ = (LQ & 0x3333) + ((LQ >> 2) & 0x3333);
|
||||
@ -1052,12 +1053,12 @@ uint8_t PIOS_OpenLRS_RSSI_Get(void)
|
||||
switch (openlrs_data.RSSI_Type) {
|
||||
case OPENLRS_RSSI_TYPE_COMBINED:
|
||||
if ((uint8_t)LQ == 15) {
|
||||
return (uint8_t)((openlrs_status.LastRSSI >> 1) + 128);
|
||||
return (uint8_t)((oplink_status.RSSI >> 1) + 128);
|
||||
} else {
|
||||
return LQ * 9;
|
||||
}
|
||||
case OPENLRS_RSSI_TYPE_RSSI:
|
||||
return openlrs_status.LastRSSI;
|
||||
return oplink_status.RSSI;
|
||||
|
||||
case OPENLRS_RSSI_TYPE_LINKQUALITY:
|
||||
return (uint8_t)(LQ << 4);
|
||||
@ -1143,7 +1144,7 @@ int32_t PIOS_OpenLRS_Init(uint32_t *openlrs_id, uint32_t spi_id,
|
||||
openlrs_dev->openlrs_rcvr_id = 0;
|
||||
|
||||
OpenLRSInitialize();
|
||||
OpenLRSStatusInitialize();
|
||||
OPLinkStatusInitialize();
|
||||
DEBUG_PRINTF(2, "OpenLRS UAVOs Initialized\r\n");
|
||||
OpenLRSData binding;
|
||||
OpenLRSGet(&binding);
|
||||
@ -1257,9 +1258,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;
|
||||
openlrs_status.LastRSSI = rfmGetRSSI(openlrs_dev); // Read the RSSI value
|
||||
oplink_status.RSSI = rfmGetRSSI(openlrs_dev); // Read the RSSI value
|
||||
|
||||
// DEBUG_PRINTF(3, "Sampled RSSI: %d %d\r\n", openlrs_status.LastRSSI, delay);
|
||||
// DEBUG_PRINTF(3, "Sampled RSSI: %d %d\r\n", oplink_status.RSSI, delay);
|
||||
}
|
||||
} else {
|
||||
// We timed out because packet was missed
|
||||
|
@ -191,7 +191,7 @@ static void PIOS_oplinkrcvr_Supervisor(uint32_t oplinkrcvr_id)
|
||||
|
||||
static uint8_t PIOS_OPLinkRCVR_Quality_Get(__attribute__((unused)) uint32_t oplinkrcvr_id)
|
||||
{
|
||||
uint8_t oplink_quality;
|
||||
uint16_t oplink_quality;
|
||||
|
||||
OPLinkStatusLinkQualityGet(&oplink_quality);
|
||||
|
||||
|
@ -129,7 +129,6 @@ UAVOBJSRCFILENAMES += perfcounter
|
||||
UAVOBJSRCFILENAMES += systemidentsettings
|
||||
UAVOBJSRCFILENAMES += systemidentstate
|
||||
UAVOBJSRCFILENAMES += openlrs
|
||||
UAVOBJSRCFILENAMES += openlrsstatus
|
||||
UAVOBJSRCFILENAMES += rfm22breceiver
|
||||
|
||||
UAVOBJSRC = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),$(FLIGHT_UAVOBJ_DIR)/$(UAVOBJSRCFILE).c )
|
||||
|
@ -812,8 +812,9 @@ void PIOS_Board_Init(void)
|
||||
break;
|
||||
case HWSETTINGS_RM_MAINPORT_DEBUGCONSOLE:
|
||||
#if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
|
||||
PIOS_Board_configure_com(&pios_usart_main_cfg, 0, PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_debug_id);
|
||||
PIOS_COM_ChangeBaud(pios_com_debug_id, 28800);
|
||||
{
|
||||
PIOS_Board_configure_com(&pios_usart_main_cfg, 0, PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_debug_id);
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_DEBUG_CONSOLE */
|
||||
break;
|
||||
case HWSETTINGS_RM_MAINPORT_COMBRIDGE:
|
||||
|
@ -431,7 +431,7 @@ static const struct pios_exti_cfg pios_exti_rfm22b_cfg __exti_config = {
|
||||
},
|
||||
};
|
||||
|
||||
const struct pios_rfm22b_cfg pios_rfm22b_rm2_cfg = {
|
||||
const struct pios_rfm22b_cfg pios_rfm22b_cfg = {
|
||||
.spi_cfg = &pios_spi_telem_flash_cfg,
|
||||
.exti_cfg = &pios_exti_rfm22b_cfg,
|
||||
.RFXtalCap = 0x7f,
|
||||
@ -441,7 +441,7 @@ const struct pios_rfm22b_cfg pios_rfm22b_rm2_cfg = {
|
||||
|
||||
const struct pios_rfm22b_cfg *PIOS_BOARD_HW_DEFS_GetRfm22Cfg(__attribute__((unused)) uint32_t board_revision)
|
||||
{
|
||||
return &pios_rfm22b_rm2_cfg;
|
||||
return &pios_rfm22b_cfg;
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_RFM22B */
|
||||
@ -483,7 +483,7 @@ static const struct pios_exti_cfg pios_exti_openlrs_cfg __exti_config = {
|
||||
|
||||
const struct pios_openlrs_cfg pios_openlrs_cfg = {
|
||||
.spi_cfg = &pios_spi_telem_flash_cfg,
|
||||
.exti_cfg = &pios_exti_rfm22b_cfg,
|
||||
.exti_cfg = &pios_exti_openlrs_cfg,
|
||||
.gpio_direction = GPIO0_TX_GPIO1_RX,
|
||||
};
|
||||
|
||||
|
@ -129,7 +129,6 @@ UAVOBJSRCFILENAMES += perfcounter
|
||||
UAVOBJSRCFILENAMES += systemidentsettings
|
||||
UAVOBJSRCFILENAMES += systemidentstate
|
||||
UAVOBJSRCFILENAMES += openlrs
|
||||
UAVOBJSRCFILENAMES += openlrsstatus
|
||||
UAVOBJSRCFILENAMES += rfm22breceiver
|
||||
|
||||
UAVOBJSRC = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),$(FLIGHT_UAVOBJ_DIR)/$(UAVOBJSRCFILE).c )
|
||||
|
@ -797,7 +797,7 @@ void PIOS_Board_Init(void)
|
||||
if (oplinkSettings.MaxRFPower != OPLINKSETTINGS_MAXRFPOWER_0) {
|
||||
if (openlrs) {
|
||||
#if defined(PIOS_INCLUDE_OPENLRS_RCVR)
|
||||
const struct pios_openlrs_cfg *openlrs_cfg = PIOS_BOARD_HW_DEFS_GetOpenLRSCfg(bdinfo->board_rev);
|
||||
const struct pios_openlrs_cfg *openlrs_cfg = PIOS_BOARD_HW_DEFS_GetOpenLRSCfg();
|
||||
uint32_t openlrs_id;
|
||||
|
||||
PIOS_OpenLRS_Init(&openlrs_id, PIOS_RFM22_SPI_PORT, 0, openlrs_cfg);
|
||||
|
@ -104,7 +104,6 @@ UAVOBJS = \
|
||||
$${UAVOBJ_XML_DIR}/nedaccel.xml \
|
||||
$${UAVOBJ_XML_DIR}/objectpersistence.xml \
|
||||
$${UAVOBJ_XML_DIR}/openlrs.xml \
|
||||
$${UAVOBJ_XML_DIR}/openlrsstatus.xml \
|
||||
$${UAVOBJ_XML_DIR}/oplinkreceiver.xml \
|
||||
$${UAVOBJ_XML_DIR}/oplinksettings.xml \
|
||||
$${UAVOBJ_XML_DIR}/oplinkstatus.xml \
|
||||
|
@ -1,13 +0,0 @@
|
||||
<xml>
|
||||
<object name="OpenLRSStatus" singleinstance="true" settings="false" category="System">
|
||||
<description>OpenLRS link status.</description>
|
||||
<field name="LastRSSI" units="" type="uint8" elements="1"/>
|
||||
<field name="LinkQuality" units="" type="uint16" elements="1"/>
|
||||
<field name="FailsafeActive" units="function" type="enum" elements="1" options="Inactive,Active" defaultvalue="Inactive"/>
|
||||
|
||||
<access gcs="readonly" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="throttled" period="500"/>
|
||||
<logging updatemode="manual" period="0"/>
|
||||
</object>
|
||||
</xml>
|
@ -18,7 +18,7 @@
|
||||
<field name="Resets" units="" type="uint8" elements="1" defaultvalue="0"/>
|
||||
<field name="Timeouts" units="" type="uint8" elements="1" defaultvalue="0"/>
|
||||
<field name="RSSI" units="dBm" type="int8" elements="1" defaultvalue="0"/>
|
||||
<field name="LinkQuality" units="" type="uint8" elements="1" defaultvalue="0"/>
|
||||
<field name="LinkQuality" units="" type="uint16" elements="1" defaultvalue="0"/>
|
||||
<field name="TXRate" units="Bps" type="uint16" elements="1" defaultvalue="0"/>
|
||||
<field name="RXRate" units="Bps" type="uint16" elements="1" defaultvalue="0"/>
|
||||
<field name="TXSeq" units="" type="uint16" elements="1" defaultvalue="0"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user