From cf7c92903036eeb8ed602002f3a6f6f8121efef5 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Mon, 18 Feb 2013 01:49:13 +0000 Subject: [PATCH] Added the ability to store bindings and configuration paramaters for multiple (up to 8) modems from an OPLink controller modem. --- flight/Libraries/inc/packet_handler.h | 5 +- flight/Modules/PipXtreme/pipxtrememod.c | 2 +- .../Modules/RadioComBridge/RadioComBridge.c | 392 ++- .../PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h | 8 +- flight/PiOS/Common/pios_rfm22b.c | 75 +- flight/PiOS/Common/pios_rfm22b_com.c | 5 +- flight/PiOS/inc/pios_rfm22b.h | 8 +- flight/PiOS/inc/pios_rfm22b_priv.h | 10 +- flight/PipXtreme/System/pios_board.c | 189 +- .../plugins/config/configpipxtremewidget.cpp | 259 +- .../plugins/config/configpipxtremewidget.h | 17 +- .../src/plugins/config/pipxtreme.ui | 2900 +++++++++++------ .../src/plugins/uavobjects/uavobjectfield.cpp | 7 +- .../uavobjectwidgetutils/configtaskwidget.cpp | 66 +- .../uavobjectwidgetutils/configtaskwidget.h | 12 +- shared/uavobjectdefinition/oplinksettings.xml | 16 +- shared/uavobjectdefinition/oplinkstatus.xml | 8 +- 17 files changed, 2412 insertions(+), 1567 deletions(-) diff --git a/flight/Libraries/inc/packet_handler.h b/flight/Libraries/inc/packet_handler.h index 8bdfb4eb0..659cdac9e 100644 --- a/flight/Libraries/inc/packet_handler.h +++ b/flight/Libraries/inc/packet_handler.h @@ -91,12 +91,13 @@ typedef struct { #define PH_CONNECTION_DATA_SIZE(p) ((uint8_t*)((p)->ecc) - (uint8_t*)(((PHPacketHandle)(p))->data)) typedef struct { PHPacketHeader header; - uint8_t datarate; uint32_t frequency_hz; uint32_t min_frequency; uint32_t max_frequency; uint8_t max_tx_power; - OPLinkSettingsOutputConnectionOptions port; + OPLinkSettingsMainPortOptions main_port; + OPLinkSettingsFlexiPortOptions flexi_port; + OPLinkSettingsVCPPortOptions vcp_port; OPLinkSettingsComSpeedOptions com_speed; uint8_t ecc[RS_ECC_NPARITY]; } PHConnectionPacket, *PHConnectionPacketHandle; diff --git a/flight/Modules/PipXtreme/pipxtrememod.c b/flight/Modules/PipXtreme/pipxtrememod.c index 269b46156..5aaed3831 100644 --- a/flight/Modules/PipXtreme/pipxtrememod.c +++ b/flight/Modules/PipXtreme/pipxtrememod.c @@ -165,6 +165,7 @@ static void systemTask(void *parameters) PIOS_RFM22B_GetStats(pios_rfm22b_id, &radio_stats); // Update the status + oplinkStatus.HeapRemaining = xPortGetFreeHeapSize(); oplinkStatus.DeviceID = PIOS_RFM22B_DeviceID(pios_rfm22b_id); oplinkStatus.RxGood = radio_stats.rx_good; oplinkStatus.RxCorrected = radio_stats.rx_corrected; @@ -177,7 +178,6 @@ static void systemTask(void *parameters) oplinkStatus.Resets = radio_stats.resets; oplinkStatus.Timeouts = radio_stats.timeouts; oplinkStatus.RSSI = radio_stats.rssi; - oplinkStatus.AFCCorrection = radio_stats.afc_correction; oplinkStatus.LinkQuality = radio_stats.link_quality; if (first_time) first_time = false; diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index 905d08888..0e48df851 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -46,6 +46,12 @@ #include +// External functions +void PIOS_InitUartMainPort(); +void PIOS_InitUartFlexiPort(); +void PIOS_InitPPMMainPort(bool input); +void PIOS_InitPPMFlexiPort(bool input); + // **************** // Private constants @@ -82,6 +88,12 @@ typedef struct { uint32_t UAVTalkErrors; uint32_t droppedPackets; + // Should we parse UAVTalk? + bool parseUAVTalk; + + // The current configured uart speed + OPLinkSettingsComSpeedOptions comSpeed; + } RadioComBridgeData; // **************** @@ -94,7 +106,8 @@ static int32_t UAVTalkSendHandler(uint8_t *buf, int32_t length); static int32_t RadioSendHandler(uint8_t *buf, int32_t length); static void ProcessInputStream(UAVTalkConnection connectionHandle, uint8_t rxbyte); static void queueEvent(xQueueHandle queue, void *obj, uint16_t instId, UAVObjEventType type); -static void configureComCallback(OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed); +static void configureComCallback(OPLinkSettingsRemoteMainPortOptions main_port, OPLinkSettingsRemoteFlexiPortOptions flexi_port, + OPLinkSettingsRemoteVCPPortOptions vcp_port, OPLinkSettingsComSpeedOptions com_speed); static void updateSettings(); // **************** @@ -109,30 +122,71 @@ static RadioComBridgeData *data; */ static int32_t RadioComBridgeStart(void) { - if(data) { + if(data) { - // Configure the com port configuration callback - PIOS_RFM22B_SetComConfigCallback(pios_rfm22b_id, &configureComCallback); + // Configure the com port configuration callback + PIOS_RFM22B_SetComConfigCallback(pios_rfm22b_id, &configureComCallback); - // Set the baudrates, etc. - updateSettings(); + // Set the baudrates, etc. + bool is_coordinator = PIOS_RFM22B_IsCoordinator(pios_rfm22b_id); + if (is_coordinator) { - // Start the primary tasks for receiving/sending UAVTalk packets from the GCS. - xTaskCreate(telemetryTxTask, (signed char *)"telemTxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->telemetryTxTaskHandle)); - xTaskCreate(radioRxTask, (signed char *)"radioRxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->radioRxTaskHandle)); - xTaskCreate(radioTxTask, (signed char *)"radioTxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->radioTxTaskHandle)); + // Get the settings. + OPLinkSettingsData oplinkSettings; + OPLinkSettingsGet(&oplinkSettings); - // Register the watchdog timers. + // Set the frequencies. + PIOS_RFM22B_SetFrequencyRange(pios_rfm22b_id, oplinkSettings.MinFrequency, oplinkSettings.MaxFrequency); + + // Set the maximum radio RF power. + switch (oplinkSettings.MaxRFPower) + { + case OPLINKSETTINGS_MAXRFPOWER_125: + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_0); + break; + case OPLINKSETTINGS_MAXRFPOWER_16: + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_1); + break; + case OPLINKSETTINGS_MAXRFPOWER_316: + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_2); + break; + case OPLINKSETTINGS_MAXRFPOWER_63: + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_3); + break; + case OPLINKSETTINGS_MAXRFPOWER_126: + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_4); + break; + case OPLINKSETTINGS_MAXRFPOWER_25: + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_5); + break; + case OPLINKSETTINGS_MAXRFPOWER_50: + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_6); + break; + case OPLINKSETTINGS_MAXRFPOWER_100: + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_7); + break; + } + + // Reinitilize the modem. + PIOS_RFM22B_Reinit(pios_rfm22b_id); + } + + // Start the primary tasks for receiving/sending UAVTalk packets from the GCS. + xTaskCreate(telemetryTxTask, (signed char *)"telemTxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->telemetryTxTaskHandle)); + xTaskCreate(radioRxTask, (signed char *)"radioRxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->radioRxTaskHandle)); + xTaskCreate(radioTxTask, (signed char *)"radioTxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->radioTxTaskHandle)); + + // Register the watchdog timers. #ifdef PIOS_INCLUDE_WDG - PIOS_WDG_RegisterFlag(PIOS_WDG_TELEMETRY); - PIOS_WDG_RegisterFlag(PIOS_WDG_RADIORX); - PIOS_WDG_RegisterFlag(PIOS_WDG_RADIOTX); + PIOS_WDG_RegisterFlag(PIOS_WDG_TELEMETRY); + PIOS_WDG_RegisterFlag(PIOS_WDG_RADIORX); + PIOS_WDG_RegisterFlag(PIOS_WDG_RADIOTX); #endif - return 0; - } + return 0; + } - return -1; + return -1; } /** @@ -168,6 +222,9 @@ static int32_t RadioComBridgeInitialize(void) data->comTxErrors = 0; data->comTxRetries = 0; data->UAVTalkErrors = 0; + data->parseUAVTalk = false; + data->comSpeed = OPLINKSETTINGS_COMSPEED_9600; + PIOS_COM_RADIO = PIOS_COM_RFM22B; return 0; } @@ -235,7 +292,7 @@ static void radioRxTask(void *parameters) // Task loop while (1) { #ifdef PIOS_INCLUDE_WDG - PIOS_WDG_UpdateFlag(PIOS_WDG_RADIORX); + PIOS_WDG_UpdateFlag(PIOS_WDG_RADIORX); #endif uint8_t serial_data[1]; uint16_t bytes_to_process = PIOS_COM_ReceiveBuffer(PIOS_COM_RADIO, serial_data, sizeof(serial_data), MAX_PORT_DELAY); @@ -259,17 +316,18 @@ static void radioTxTask(void *parameters) #endif #if defined(PIOS_INCLUDE_USB) // Determine output port (USB takes priority over telemetry port) - if (PIOS_USB_CheckAvailable(0) && PIOS_COM_TELEM_USB) - inputPort = PIOS_COM_TELEM_USB; + if (PIOS_USB_CheckAvailable(0) && PIOS_COM_TELEM_USB_HID) + inputPort = PIOS_COM_TELEM_USB_HID; #endif /* PIOS_INCLUDE_USB */ - if(inputPort) - { + if(inputPort) { uint8_t serial_data[1]; uint16_t bytes_to_process = PIOS_COM_ReceiveBuffer(inputPort, serial_data, sizeof(serial_data), MAX_PORT_DELAY); - if (bytes_to_process > 0) - for (uint8_t i = 0; i < bytes_to_process; i++) - ProcessInputStream(data->inUAVTalkCon, serial_data[i]); - } + if (bytes_to_process > 0) { + for (uint8_t i = 0; i < bytes_to_process; i++) + ProcessInputStream(data->inUAVTalkCon, serial_data[i]); + } + } else + vTaskDelay(5); } } @@ -285,8 +343,8 @@ static int32_t UAVTalkSendHandler(uint8_t *buf, int32_t length) uint32_t outputPort = PIOS_COM_TELEMETRY; #if defined(PIOS_INCLUDE_USB) // Determine output port (USB takes priority over telemetry port) - if (PIOS_COM_TELEM_USB && PIOS_COM_Available(PIOS_COM_TELEM_USB)) - outputPort = PIOS_COM_TELEM_USB; + if (PIOS_COM_TELEM_USB_HID && PIOS_COM_Available(PIOS_COM_TELEM_USB_HID)) + outputPort = PIOS_COM_TELEM_USB_HID; #endif /* PIOS_INCLUDE_USB */ if(outputPort) return PIOS_COM_SendBufferNonBlocking(outputPort, buf, length); @@ -303,13 +361,14 @@ static int32_t UAVTalkSendHandler(uint8_t *buf, int32_t length) */ static int32_t RadioSendHandler(uint8_t *buf, int32_t length) { - uint32_t outputPort = PIOS_COM_RADIO; - // Don't send any data unless the radio port is available. - if(outputPort && PIOS_COM_Available(outputPort)) - return PIOS_COM_SendBuffer(outputPort, buf, length); - else - // For some reason, if this function returns failure, it prevents saving settings. - return length; + uint32_t outputPort = PIOS_COM_RADIO; + // Don't send any data unless the radio port is available. + if(outputPort && PIOS_COM_Available(outputPort)) { + return PIOS_COM_SendBuffer(outputPort, buf, length); + } else { + // For some reason, if this function returns failure, it prevents saving settings. + return length; + } } static void ProcessInputStream(UAVTalkConnection connectionHandle, uint8_t rxbyte) @@ -443,45 +502,60 @@ static void queueEvent(xQueueHandle queue, void *obj, uint16_t instId, UAVObjEve * \param[in] com_port The com port to configure * \param[in] com_speed The com port speed */ -static void configureComCallback(OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed) +static void configureComCallback(OPLinkSettingsRemoteMainPortOptions main_port, OPLinkSettingsRemoteFlexiPortOptions flexi_port, + OPLinkSettingsRemoteVCPPortOptions vcp_port, OPLinkSettingsComSpeedOptions com_speed) { - // Get the settings. - OPLinkSettingsData oplinkSettings; - OPLinkSettingsGet(&oplinkSettings); + // Update the com baud rate + data->comSpeed = com_speed; - // Set the output telemetry port and speed. - switch (com_port) - { - case OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEHID: - oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_HID; - break; - case OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEVCP: - oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_VCP; - break; - case OPLINKSETTINGS_OUTPUTCONNECTION_REMOTETELEMETRY: - oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_TELEMETRY; - break; - case OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEFLEXI: - oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_FLEXI; - break; - case OPLINKSETTINGS_OUTPUTCONNECTION_TELEMETRY: - oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_HID; - break; - case OPLINKSETTINGS_OUTPUTCONNECTION_FLEXI: - oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_HID; - break; + // Set the output main/flexi/vcp port and speed. + bool is_coordinator = PIOS_RFM22B_IsCoordinator(pios_rfm22b_id); + if (!is_coordinator) { + + // Get the settings. + OPLinkSettingsData oplinkSettings; + OPLinkSettingsGet(&oplinkSettings); + + switch (main_port) { + case OPLINKSETTINGS_REMOTEMAINPORT_DISABLED: + oplinkSettings.MainPort = OPLINKSETTINGS_MAINPORT_DISABLED; + break; + case OPLINKSETTINGS_REMOTEMAINPORT_SERIAL: + oplinkSettings.MainPort = OPLINKSETTINGS_MAINPORT_SERIAL; + break; + case OPLINKSETTINGS_REMOTEMAINPORT_PPM: + oplinkSettings.MainPort = OPLINKSETTINGS_MAINPORT_PPM; + break; } - oplinkSettings.ComSpeed = com_speed; - // A non-coordinator modem should not set a remote telemetry connection. - oplinkSettings.OutputConnection = OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEHID; + switch (flexi_port) { + case OPLINKSETTINGS_REMOTEFLEXIPORT_DISABLED: + oplinkSettings.FlexiPort = OPLINKSETTINGS_FLEXIPORT_DISABLED; + break; + case OPLINKSETTINGS_REMOTEFLEXIPORT_SERIAL: + oplinkSettings.FlexiPort = OPLINKSETTINGS_FLEXIPORT_SERIAL; + break; + case OPLINKSETTINGS_REMOTEFLEXIPORT_PPM: + oplinkSettings.FlexiPort = OPLINKSETTINGS_FLEXIPORT_PPM; + break; + } - // Update the OPLinkSettings object. - OPLinkSettingsSet(&oplinkSettings); + switch (vcp_port) { + case OPLINKSETTINGS_REMOTEVCPPORT_DISABLED: + oplinkSettings.VCPPort = OPLINKSETTINGS_VCPPORT_DISABLED; + break; + case OPLINKSETTINGS_REMOTEVCPPORT_SERIAL: + oplinkSettings.VCPPort = OPLINKSETTINGS_VCPPORT_SERIAL; + break; + } - // Perform the update. - updateSettings(); + // Update the OPLinkSettings object. + OPLinkSettingsSet(&oplinkSettings); + } + + // Perform the update. + updateSettings(); } /** @@ -489,116 +563,84 @@ static void configureComCallback(OPLinkSettingsOutputConnectionOptions com_port, */ static void updateSettings() { - // Get the settings. - OPLinkSettingsData oplinkSettings; - OPLinkSettingsGet(&oplinkSettings); + // Get the settings. + OPLinkSettingsData oplinkSettings; + OPLinkSettingsGet(&oplinkSettings); - // Set the bindings. - PIOS_RFM22B_SetBindings(pios_rfm22b_id, oplinkSettings.Bindings); + // Configure the main port + bool is_coordinator = PIOS_RFM22B_IsCoordinator(pios_rfm22b_id); + switch (oplinkSettings.MainPort) + { + case OPLINKSETTINGS_MAINPORT_TELEMETRY: + data->parseUAVTalk = true; + case OPLINKSETTINGS_MAINPORT_SERIAL: + /* Configure the main port for uart serial */ + PIOS_InitUartMainPort(); + PIOS_COM_TELEMETRY = PIOS_COM_TELEM_UART_MAIN; + break; + case OPLINKSETTINGS_MAINPORT_PPM: + PIOS_InitPPMMainPort(is_coordinator); + break; + case OPLINKSETTINGS_MAINPORT_DISABLED: + break; + } - //bool is_coordinator = (oplinkSettings.PairID != 0); - bool is_coordinator = PIOS_RFM22B_IsCoordinator(pios_rfm22b_id); - if (is_coordinator) - { - // Set the remote com configuration parameters - PIOS_RFM22B_SetRemoteComConfig(pios_rfm22b_id, oplinkSettings.OutputConnection, oplinkSettings.ComSpeed); + // Configure the flexi port + switch (oplinkSettings.FlexiPort) + { + case OPLINKSETTINGS_FLEXIPORT_TELEMETRY: + data->parseUAVTalk = true; + case OPLINKSETTINGS_FLEXIPORT_SERIAL: + /* Configure the flexi port as uart serial */ + PIOS_InitUartFlexiPort(); + PIOS_COM_TELEMETRY = PIOS_COM_TELEM_UART_FLEXI; + break; + case OPLINKSETTINGS_FLEXIPORT_PPM: + PIOS_InitPPMFlexiPort(is_coordinator); + break; + case OPLINKSETTINGS_FLEXIPORT_DISABLED: + break; + } - // Set the frequencies. - PIOS_RFM22B_SetFrequencyRange(pios_rfm22b_id, oplinkSettings.MinFrequency, oplinkSettings.MaxFrequency); + // Configure the USB VCP port + switch (oplinkSettings.VCPPort) + { + case OPLINKSETTINGS_VCPPORT_SERIAL: + PIOS_COM_TELEMETRY = PIOS_COM_TELEM_USB_VCP; + break; + case OPLINKSETTINGS_VCPPORT_DISABLED: + break; + } - // Set the maximum radio RF power. - switch (oplinkSettings.MaxRFPower) - { - case OPLINKSETTINGS_MAXRFPOWER_125: - PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_0); - break; - case OPLINKSETTINGS_MAXRFPOWER_16: - PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_1); - break; - case OPLINKSETTINGS_MAXRFPOWER_316: - PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_2); - break; - case OPLINKSETTINGS_MAXRFPOWER_63: - PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_3); - break; - case OPLINKSETTINGS_MAXRFPOWER_126: - PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_4); - break; - case OPLINKSETTINGS_MAXRFPOWER_25: - PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_5); - break; - case OPLINKSETTINGS_MAXRFPOWER_50: - PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_6); - break; - case OPLINKSETTINGS_MAXRFPOWER_100: - PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_7); - break; - } - } - - // Determine what com ports we're using. - switch (oplinkSettings.InputConnection) - { - case OPLINKSETTINGS_INPUTCONNECTION_VCP: - PIOS_COM_TELEMETRY = PIOS_COM_TELEM_VCP; - break; - case OPLINKSETTINGS_INPUTCONNECTION_TELEMETRY: - PIOS_COM_TELEMETRY = PIOS_COM_TELEM_UART_TELEM; - break; - case OPLINKSETTINGS_INPUTCONNECTION_FLEXI: - PIOS_COM_TELEMETRY = PIOS_COM_TELEM_UART_FLEXI; - break; - default: - PIOS_COM_TELEMETRY = 0; - break; - } - - switch (oplinkSettings.OutputConnection) - { - case OPLINKSETTINGS_OUTPUTCONNECTION_FLEXI: - PIOS_COM_RADIO = PIOS_COM_TELEM_UART_FLEXI; - break; - case OPLINKSETTINGS_OUTPUTCONNECTION_TELEMETRY: - PIOS_COM_RADIO = PIOS_COM_TELEM_UART_TELEM; - break; - default: - PIOS_COM_RADIO = PIOS_COM_RFM22B; - break; - } - - // Configure the com port speeds. - switch (oplinkSettings.ComSpeed) { - case OPLINKSETTINGS_COMSPEED_2400: - if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 2400); - if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 2400); - break; - case OPLINKSETTINGS_COMSPEED_4800: - if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 4800); - if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 4800); - break; - case OPLINKSETTINGS_COMSPEED_9600: - if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 9600); - if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 9600); - break; - case OPLINKSETTINGS_COMSPEED_19200: - if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 19200); - if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 19200); - break; - case OPLINKSETTINGS_COMSPEED_38400: - if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 38400); - if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 38400); - break; - case OPLINKSETTINGS_COMSPEED_57600: - if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 57600); - if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 57600); - break; - case OPLINKSETTINGS_COMSPEED_115200: - if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 115200); - if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 115200); - break; - } - - // Reinitilize the modem. - if (is_coordinator) - PIOS_RFM22B_Reinit(pios_rfm22b_id); + // Update the com baud rate. + uint32_t comBaud = 9600; + switch (data->comSpeed) { + case OPLINKSETTINGS_COMSPEED_2400: + comBaud = 2400; + break; + case OPLINKSETTINGS_COMSPEED_4800: + comBaud = 4800; + break; + case OPLINKSETTINGS_COMSPEED_9600: + comBaud = 9600; + break; + case OPLINKSETTINGS_COMSPEED_19200: + comBaud = 19200; + break; + case OPLINKSETTINGS_COMSPEED_38400: + comBaud = 38400; + break; + case OPLINKSETTINGS_COMSPEED_57600: + comBaud = 57600; + break; + case OPLINKSETTINGS_COMSPEED_115200: + comBaud = 115200; + break; + } + if (PIOS_COM_RADIO) { + PIOS_COM_ChangeBaud(PIOS_COM_RADIO, comBaud); + } + if (PIOS_COM_TELEMETRY) { + PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, comBaud); + } } diff --git a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h index 05b757e9c..be0ea2f9c 100755 --- a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h @@ -174,17 +174,17 @@ extern uint32_t pios_i2c_flexi_adapter_id; extern uint32_t pios_com_telem_usb_id; extern uint32_t pios_com_telem_vcp_id; -extern uint32_t pios_com_telem_uart_telem_id; +extern uint32_t pios_com_telem_uart_main_id; extern uint32_t pios_com_telem_uart_flexi_id; extern uint32_t pios_com_telemetry_id; extern uint32_t pios_com_rfm22b_id; extern uint32_t pios_com_radio_id; extern uint32_t pios_ppm_rcvr_id; extern uint32_t pios_ppm_out_id; -#define PIOS_COM_TELEM_USB (pios_com_telem_usb_id) -#define PIOS_COM_TELEM_VCP (pios_com_telem_vcp_id) +#define PIOS_COM_TELEM_USB_HID (pios_com_telem_usb_id) +#define PIOS_COM_TELEM_USB_VCP (pios_com_telem_vcp_id) +#define PIOS_COM_TELEM_UART_MAIN (pios_com_telem_uart_main_id) #define PIOS_COM_TELEM_UART_FLEXI (pios_com_telem_uart_flexi_id) -#define PIOS_COM_TELEM_UART_TELEM (pios_com_telem_uart_telem_id) #define PIOS_COM_TELEMETRY (pios_com_telemetry_id) #define PIOS_COM_RFM22B (pios_com_rfm22b_id) #define PIOS_COM_RADIO (pios_com_radio_id) diff --git a/flight/PiOS/Common/pios_rfm22b.c b/flight/PiOS/Common/pios_rfm22b.c index bb2301515..672f9332c 100644 --- a/flight/PiOS/Common/pios_rfm22b.c +++ b/flight/PiOS/Common/pios_rfm22b.c @@ -587,7 +587,7 @@ int32_t PIOS_RFM22B_Init(uint32_t *rfm22b_id, uint32_t spi_id, uint32_t slave_nu // Initialize the bindings. for (uint32_t i = 0; i < OPLINKSETTINGS_BINDINGS_NUMELEM; ++i) - rfm22b_dev->bindings[i] = 0; + rfm22b_dev->bindings[i].pairID = 0; rfm22b_dev->coordinator = false; // Create the event queue @@ -745,21 +745,6 @@ void PIOS_RFM22B_SetFrequencyRange(uint32_t rfm22b_id, uint32_t min_frequency, u rfm22_setNominalCarrierFrequency(rfm22b_dev, (max_frequency - min_frequency) / 2); } -/** - * Set the remote com port configuration parameters. - * \param[in] rfm22b_id The rfm22b device. - * \param[in] com_port The remote com port - * \param[in] com_speed The remote com port speed - */ -void PIOS_RFM22B_SetRemoteComConfig(uint32_t rfm22b_id, OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; - if(!PIOS_RFM22B_validate(rfm22b_dev)) - return; - rfm22b_dev->con_packet.port = com_port; - rfm22b_dev->con_packet.com_speed = com_speed; -} - /** * Set the com port configuration callback (to receive com configuration over the air) * \param[in] rfm22b_id The rfm22b device. @@ -778,17 +763,21 @@ void PIOS_RFM22B_SetComConfigCallback(uint32_t rfm22b_id, PIOS_RFM22B_ComConfigC * \param[in] rfm22b_id The rfm22b device. * \param[in] bindings The array of bindings. */ -void PIOS_RFM22B_SetBindings(uint32_t rfm22b_id, const uint32_t bindings[]) +void PIOS_RFM22B_SetBindings(uint32_t rfm22b_id, const uint32_t bindingPairIDs[], const uint8_t mainPortSettings[], + const uint8_t flexiPortSettings[], const uint8_t vcpPortSettings[], const uint8_t comSpeeds[]) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if(!PIOS_RFM22B_validate(rfm22b_dev)) return; // This modem will be considered a coordinator if any bindings have been set. rfm22b_dev->coordinator = false; - for (uint32_t i = 0; i < OPLINKSETTINGS_BINDINGS_NUMELEM; ++i) - { - rfm22b_dev->bindings[i] = bindings[i]; - rfm22b_dev->coordinator |= (rfm22b_dev->bindings[i] != 0); + for (uint32_t i = 0; i < OPLINKSETTINGS_BINDINGS_NUMELEM; ++i) { + rfm22b_dev->bindings[i].pairID = bindingPairIDs[i]; + rfm22b_dev->bindings[i].main_port = mainPortSettings[i]; + rfm22b_dev->bindings[i].flexi_port = flexiPortSettings[i]; + rfm22b_dev->bindings[i].vcp_port = vcpPortSettings[i]; + rfm22b_dev->bindings[i].com_speed = comSpeeds[i]; + rfm22b_dev->coordinator |= (rfm22b_dev->bindings[i].pairID != 0); } } @@ -1036,14 +1025,6 @@ static void rfm22_setDatarate(struct pios_rfm22b_dev * rfm22b_dev, enum rfm22b_d rfm22_write(rfm22b_dev, RFM22_ook_counter_value2, 0x00); } -void PIOS_RFM22B_SetDatarate(uint32_t rfm22b_id, enum rfm22b_datarate datarate, bool data_whitening) -{ - struct pios_rfm22b_dev * rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; - if(!PIOS_RFM22B_validate(rfm22b_dev)) - return; - rfm22b_dev->datarate = datarate; -} - // ************************************ // SPI read/write @@ -2005,11 +1986,20 @@ static enum pios_rfm22b_event rfm22_receiveNack(struct pios_rfm22b_dev *rfm22b_d // Go to the next binding, if the previous tx packet was a connection request if (rfm22b_dev->tx_packet->header.type == PACKET_TYPE_CON_REQUEST) { - // Increment the current binding index, and make sure that we didn't run off the end of the buffer, or past the last nonzero ID - if ((++(rfm22b_dev->cur_binding) >= OPLINKSETTINGS_BINDINGS_NUMELEM) || (rfm22b_dev->bindings[rfm22b_dev->cur_binding] == 0)) - rfm22b_dev->cur_binding = 0; - rfm22b_dev->destination_id = rfm22b_dev->bindings[rfm22b_dev->cur_binding]; - rfm22b_dev->tx_packet->header.destination_id = rfm22b_dev->destination_id; + PHConnectionPacketHandle cph = &(rfm22b_dev->con_packet); + // Increment the current binding index to the next non-zero binding. + for (uint8_t i = 0; OPLINKSETTINGS_BINDINGS_NUMELEM; ++i) { + if (++(rfm22b_dev->cur_binding) >= OPLINKSETTINGS_BINDINGS_NUMELEM) + rfm22b_dev->cur_binding = 0; + if (rfm22b_dev->bindings[rfm22b_dev->cur_binding].pairID != 0) + break; + } + rfm22b_dev->destination_id = rfm22b_dev->bindings[rfm22b_dev->cur_binding].pairID; + cph->header.destination_id = rfm22b_dev->destination_id; + cph->main_port = rfm22b_dev->bindings[rfm22b_dev->cur_binding].main_port; + cph->flexi_port = rfm22b_dev->bindings[rfm22b_dev->cur_binding].flexi_port; + cph->vcp_port = rfm22b_dev->bindings[rfm22b_dev->cur_binding].vcp_port; + cph->com_speed = rfm22b_dev->bindings[rfm22b_dev->cur_binding].com_speed; } // Increment the reset packet counter if we're connected. @@ -2086,11 +2076,14 @@ static enum pios_rfm22b_event rfm22_requestConnection(struct pios_rfm22b_dev *rf rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_CONNECTING; // Fill in the connection request - rfm22b_dev->destination_id = rfm22b_dev->bindings[rfm22b_dev->cur_binding]; + rfm22b_dev->destination_id = rfm22b_dev->bindings[rfm22b_dev->cur_binding].pairID; cph->header.destination_id = rfm22b_dev->destination_id; cph->header.type = PACKET_TYPE_CON_REQUEST; cph->header.data_size = PH_CONNECTION_DATA_SIZE(&(rfm22b_dev->con_packet)); - cph->datarate = rfm22b_dev->datarate; + cph->main_port = rfm22b_dev->bindings[rfm22b_dev->cur_binding].main_port; + cph->flexi_port = rfm22b_dev->bindings[rfm22b_dev->cur_binding].flexi_port; + cph->vcp_port = rfm22b_dev->bindings[rfm22b_dev->cur_binding].vcp_port; + cph->com_speed = rfm22b_dev->bindings[rfm22b_dev->cur_binding].com_speed; cph->frequency_hz = rfm22b_dev->frequency_hz; cph->min_frequency = rfm22b_dev->min_frequency; cph->max_frequency = rfm22b_dev->max_frequency; @@ -2107,17 +2100,17 @@ static void rfm22_setConnectionParameters(struct pios_rfm22b_dev *rfm22b_dev) // Set our connection state to connected rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_CONNECTED; + + // Call the com port configuration function + if (rfm22b_dev->com_config_cb) + rfm22b_dev->com_config_cb(cph->main_port, cph->flexi_port, cph->vcp_port, cph->com_speed); // Configure this modem from the connection request message. - rfm22_setDatarate(rfm22b_dev, cph->datarate, true); + rfm22_setDatarate(rfm22b_dev, rfm22b_dev->datarate, true); PIOS_RFM22B_SetTxPower((uint32_t)rfm22b_dev, cph->max_tx_power); rfm22b_dev->min_frequency = cph->min_frequency; rfm22b_dev->max_frequency = cph->max_frequency; rfm22_setNominalCarrierFrequency(rfm22b_dev, cph->frequency_hz); - - // Call the com port configuration function - if (rfm22b_dev->com_config_cb && !rfm22b_dev->coordinator) - rfm22b_dev->com_config_cb(cph->port, cph->com_speed); } static enum pios_rfm22b_event rfm22_acceptConnection(struct pios_rfm22b_dev *rfm22b_dev) diff --git a/flight/PiOS/Common/pios_rfm22b_com.c b/flight/PiOS/Common/pios_rfm22b_com.c index e8fb4a6db..7b0b62369 100644 --- a/flight/PiOS/Common/pios_rfm22b_com.c +++ b/flight/PiOS/Common/pios_rfm22b_com.c @@ -61,9 +61,6 @@ static void PIOS_RFM22B_COM_ChangeBaud(uint32_t rfm22b_id, uint32_t baud) struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if (!PIOS_RFM22B_validate(rfm22b_dev)) return; - // This is only allowed for coordinators. - if (!rfm22b_dev->coordinator) - return; // Set the RF data rate on the modem to ~2X the selected buad rate because the modem is half duplex. enum rfm22b_datarate datarate = RFM22_datarate_64000; if (baud <= 1024) @@ -82,7 +79,7 @@ static void PIOS_RFM22B_COM_ChangeBaud(uint32_t rfm22b_id, uint32_t baud) datarate = RFM22_datarate_128000; else if (baud <= 115200) datarate = RFM22_datarate_192000; - PIOS_RFM22B_SetDatarate(rfm22b_id, datarate, true); + rfm22b_dev->datarate = datarate; } static void PIOS_RFM22B_COM_RxStart(uint32_t rfm22b_id, uint16_t rx_bytes_avail) diff --git a/flight/PiOS/inc/pios_rfm22b.h b/flight/PiOS/inc/pios_rfm22b.h index 5a2c96bca..a67f5c253 100644 --- a/flight/PiOS/inc/pios_rfm22b.h +++ b/flight/PiOS/inc/pios_rfm22b.h @@ -96,18 +96,18 @@ struct rfm22b_stats { }; /* Callback function prototypes */ -typedef void (*PIOS_RFM22B_ComConfigCallback)(OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed); +typedef void (*PIOS_RFM22B_ComConfigCallback)(OPLinkSettingsRemoteMainPortOptions main_port, OPLinkSettingsRemoteFlexiPortOptions flexi_port, + OPLinkSettingsRemoteVCPPortOptions vcp_port, OPLinkSettingsComSpeedOptions com_speed); /* Public Functions */ extern int32_t PIOS_RFM22B_Init(uint32_t *rfb22b_id, uint32_t spi_id, uint32_t slave_num, const struct pios_rfm22b_cfg *cfg); extern void PIOS_RFM22B_Reinit(uint32_t rfb22b_id); extern void PIOS_RFM22B_SetFrequencyRange(uint32_t rfm22b_id, uint32_t min_frequency, uint32_t max_frequency); extern void PIOS_RFM22B_SetTxPower(uint32_t rfm22b_id, enum rfm22b_tx_power tx_pwr); -extern void PIOS_RFM22B_SetDatarate(uint32_t rfm22b_id, enum rfm22b_datarate datarate, bool data_whitening); extern void PIOS_RFM22B_SetDestinationId(uint32_t rfm22b_id, uint32_t dest_id); -extern void PIOS_RFM22B_SetRemoteComConfig(uint32_t rfm22b_id, OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed); extern void PIOS_RFM22B_SetComConfigCallback(uint32_t rfm22b_id, PIOS_RFM22B_ComConfigCallback cb); -extern void PIOS_RFM22B_SetBindings(uint32_t rfm22b_id, const uint32_t bindings[]); +extern void PIOS_RFM22B_SetBindings(uint32_t rfm22b_id, const uint32_t bindingPairIDs[], const uint8_t mainPortSettings[], + const uint8_t flexiPortSettings[], const uint8_t vcpPortSettings[], const uint8_t comSpeeds[]); extern uint32_t PIOS_RFM22B_DeviceID(uint32_t rfb22b_id); extern bool PIOS_RFM22B_IsCoordinator(uint32_t rfb22b_id); extern void PIOS_RFM22B_GetStats(uint32_t rfm22b_id, struct rfm22b_stats *stats); diff --git a/flight/PiOS/inc/pios_rfm22b_priv.h b/flight/PiOS/inc/pios_rfm22b_priv.h index e771bf6d3..1ac46b345 100644 --- a/flight/PiOS/inc/pios_rfm22b_priv.h +++ b/flight/PiOS/inc/pios_rfm22b_priv.h @@ -645,6 +645,14 @@ typedef struct { uint8_t lastContact; } rfm22b_pair_stats; +typedef struct { + uint32_t pairID; + OPLinkSettingsRemoteMainPortOptions main_port; + OPLinkSettingsRemoteFlexiPortOptions flexi_port; + OPLinkSettingsRemoteVCPPortOptions vcp_port; + OPLinkSettingsComSpeedOptions com_speed; +} rfm22b_binding; + struct pios_rfm22b_dev { enum pios_rfm22b_dev_magic magic; struct pios_rfm22b_cfg cfg; @@ -660,7 +668,7 @@ struct pios_rfm22b_dev { uint32_t destination_id; // The list of bound radios. - uint32_t bindings[OPLINKSETTINGS_BINDINGS_NUMELEM]; + rfm22b_binding bindings[OPLINKSETTINGS_BINDINGS_NUMELEM]; uint8_t cur_binding; // Is this device a coordinator? diff --git a/flight/PipXtreme/System/pios_board.c b/flight/PipXtreme/System/pios_board.c index 80bc8fb61..0f598e84e 100644 --- a/flight/PipXtreme/System/pios_board.c +++ b/flight/PipXtreme/System/pios_board.c @@ -1,17 +1,16 @@ -/* -*- Mode: c; c-basic-offset: 2; tab-width: 2; indent-tabs-mode: t -*- */ /** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file pios_board.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Defines board specific static initializers for hardware for the OpenPilot board. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ +****************************************************************************** +* @addtogroup OpenPilotSystem OpenPilot System +* @{ +* @addtogroup OpenPilotCore OpenPilot Core +* @{ +* +* @file pios_board.c +* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. +* @brief Defines board specific static initializers for hardware for the OpenPilot board. +* @see The GNU Public License (GPL) Version 3 +* +*****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,9 +32,6 @@ #include #include -#define PIOS_COM_TELEM_RX_BUF_LEN 256 -#define PIOS_COM_TELEM_TX_BUF_LEN 256 - #define PIOS_COM_TELEM_USB_RX_BUF_LEN 256 #define PIOS_COM_TELEM_USB_TX_BUF_LEN 256 @@ -45,9 +41,12 @@ #define PIOS_COM_RFM22B_RF_RX_BUF_LEN 256 #define PIOS_COM_RFM22B_RF_TX_BUF_LEN 256 +#define PIOS_COM_TELEM_RX_BUF_LEN 256 +#define PIOS_COM_TELEM_TX_BUF_LEN 256 + uint32_t pios_com_telem_usb_id = 0; uint32_t pios_com_telem_vcp_id = 0; -uint32_t pios_com_telem_uart_telem_id = 0; +uint32_t pios_com_telem_uart_main_id = 0; uint32_t pios_com_telem_uart_flexi_id = 0; uint32_t pios_com_telemetry_id = 0; #if defined(PIOS_INCLUDE_PPM) @@ -61,6 +60,8 @@ uint32_t pios_rfm22b_id = 0; uint32_t pios_com_rfm22b_id = 0; uint32_t pios_com_radio_id = 0; #endif +uint8_t *pios_uart_rx_buffer; +uint8_t *pios_uart_tx_buffer; /** * PIOS_Board_Init() @@ -154,8 +155,8 @@ void PIOS_Board_Init(void) { PIOS_Assert(rx_buffer); PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id, - rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN, - tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) { + rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN, + tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) { PIOS_Assert(0); } } @@ -173,31 +174,13 @@ void PIOS_Board_Init(void) { PIOS_Assert(rx_buffer); PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_telem_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id, - rx_buffer, PIOS_COM_TELEM_VCP_RX_BUF_LEN, - tx_buffer, PIOS_COM_TELEM_VCP_TX_BUF_LEN)) { + rx_buffer, PIOS_COM_TELEM_VCP_RX_BUF_LEN, + tx_buffer, PIOS_COM_TELEM_VCP_TX_BUF_LEN)) { PIOS_Assert(0); } } #endif - /* Configure the telemetry serial port */ -#ifndef PIOS_RFM22B_DEBUG_ON_TELEM - { - uint32_t pios_usart1_id; - if (PIOS_USART_Init(&pios_usart1_id, &pios_usart_serial_cfg)) { - PIOS_Assert(0); - } - uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RX_BUF_LEN); - uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN); - PIOS_Assert(rx_buffer); - PIOS_Assert(tx_buffer); - if (PIOS_COM_Init(&pios_com_telem_uart_telem_id, &pios_usart_com_driver, pios_usart1_id, - rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN, - tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) { - PIOS_Assert(0); - } - } -#endif /* Initalize the RFM22B radio COM device. */ #if defined(PIOS_INCLUDE_RFM22B) @@ -214,60 +197,20 @@ void PIOS_Board_Init(void) { PIOS_Assert(rx_buffer); PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_rfm22b_id, &pios_rfm22b_com_driver, pios_rfm22b_id, - rx_buffer, PIOS_COM_RFM22B_RF_RX_BUF_LEN, - tx_buffer, PIOS_COM_RFM22B_RF_TX_BUF_LEN)) { + rx_buffer, PIOS_COM_RFM22B_RF_RX_BUF_LEN, + tx_buffer, PIOS_COM_RFM22B_RF_TX_BUF_LEN)) { PIOS_Assert(0); } /* Set the RFM22B bindings. */ - PIOS_RFM22B_SetBindings(pios_rfm22b_id, oplinkSettings.Bindings); + PIOS_RFM22B_SetBindings(pios_rfm22b_id, oplinkSettings.Bindings, oplinkSettings.RemoteMainPort, + oplinkSettings.RemoteFlexiPort, oplinkSettings.RemoteVCPPort, oplinkSettings.ComSpeed); } #endif /* PIOS_INCLUDE_RFM22B */ - /* Configure PPM input */ - bool is_coordinator = PIOS_RFM22B_IsCoordinator(pios_rfm22b_id); - switch (oplinkSettings.PPM) { -#if defined(PIOS_INCLUDE_PPM) - case OPLINKSETTINGS_PPM_PPM: - case OPLINKSETTINGS_PPM_PPMTELEMETRY: - { - /* PPM input is configured on the coordinator modem and output on the remote modem. */ - if (is_coordinator) - { - uint32_t pios_ppm_id; - PIOS_PPM_Init(&pios_ppm_id, &pios_ppm_cfg); - - if (PIOS_RCVR_Init(&pios_ppm_rcvr_id, &pios_ppm_rcvr_driver, pios_ppm_id)) - PIOS_Assert(0); - } -#if defined(PIOS_INCLUDE_PPM_OUT) - else - { - PIOS_PPM_Out_Init(&pios_ppm_out_id, &pios_ppm_out_cfg); - } -#endif /* PIOS_INCLUDE_PPM_OUT */ - break; - } -#endif /* PIOS_INCLUDE_PPM */ - - default: - { - /* Configure the flexi serial port if PPM not selected */ - uint32_t pios_usart3_id; - if (PIOS_USART_Init(&pios_usart3_id, &pios_usart_telem_flexi_cfg)) { - PIOS_Assert(0); - } - uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RX_BUF_LEN); - uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN); - PIOS_Assert(rx_buffer); - PIOS_Assert(tx_buffer); - if (PIOS_COM_Init(&pios_com_telem_uart_flexi_id, &pios_usart_com_driver, pios_usart3_id, - rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN, - tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) { - PIOS_Assert(0); - } - } - } + /* Allocate the uart buffers. */ + pios_uart_rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RX_BUF_LEN); + pios_uart_tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN); /* Remap AFIO pin */ GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE); @@ -278,6 +221,80 @@ void PIOS_Board_Init(void) { PIOS_GPIO_Init(); } +void PIOS_InitUartMainPort() +{ +#ifndef PIOS_RFM22B_DEBUG_ON_TELEM + uint32_t pios_usart1_id; + if (PIOS_USART_Init(&pios_usart1_id, &pios_usart_serial_cfg)) { + PIOS_Assert(0); + } + PIOS_Assert(pios_uart_rx_buffer); + PIOS_Assert(pios_uart_tx_buffer); + if (PIOS_COM_Init(&pios_com_telem_uart_main_id, &pios_usart_com_driver, pios_usart1_id, + pios_uart_rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN, + pios_uart_tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) { + PIOS_Assert(0); + } +#endif +} + +void PIOS_InitUartFlexiPort() +{ + uint32_t pios_usart3_id; + if (PIOS_USART_Init(&pios_usart3_id, &pios_usart_telem_flexi_cfg)) { + PIOS_Assert(0); + } + PIOS_Assert(pios_uart_rx_buffer); + PIOS_Assert(pios_uart_tx_buffer); + if (PIOS_COM_Init(&pios_com_telem_uart_flexi_id, &pios_usart_com_driver, pios_usart3_id, + pios_uart_rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN, + pios_uart_tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) { + PIOS_Assert(0); + } +} + +void PIOS_InitPPMMainPort(bool input) +{ +#if defined(PIOS_INCLUDE_PPM) + /* PPM input is configured on the coordinator modem and output on the remote modem. */ + if (input) + { + uint32_t pios_ppm_id; + PIOS_PPM_Init(&pios_ppm_id, &pios_ppm_cfg); + + if (PIOS_RCVR_Init(&pios_ppm_rcvr_id, &pios_ppm_rcvr_driver, pios_ppm_id)) + PIOS_Assert(0); + } +#if defined(PIOS_INCLUDE_PPM_OUT) + else + { + PIOS_PPM_Out_Init(&pios_ppm_out_id, &pios_ppm_out_cfg); + } +#endif /* PIOS_INCLUDE_PPM_OUT */ +#endif /* PIOS_INCLUDE_PPM */ +} + +void PIOS_InitPPMFlexiPort(bool input) +{ +#if defined(PIOS_INCLUDE_PPM) + /* PPM input is configured on the coordinator modem and output on the remote modem. */ + if (input) + { + uint32_t pios_ppm_id; + PIOS_PPM_Init(&pios_ppm_id, &pios_ppm_cfg); + + if (PIOS_RCVR_Init(&pios_ppm_rcvr_id, &pios_ppm_rcvr_driver, pios_ppm_id)) + PIOS_Assert(0); + } +#if defined(PIOS_INCLUDE_PPM_OUT) + else + { + PIOS_PPM_Out_Init(&pios_ppm_out_id, &pios_ppm_out_cfg); + } +#endif /* PIOS_INCLUDE_PPM_OUT */ +#endif /* PIOS_INCLUDE_PPM */ +} + /** * @} */ diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp index f6e457690..772f5b05c 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp @@ -27,6 +27,7 @@ #include "configpipxtremewidget.h" +#include #include #include @@ -53,20 +54,20 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget qDebug() << "Error: Object is unknown (OPLinkSettings)."; } autoLoadWidgets(); + Core::Internal::GeneralSettings *settings = pm->getObject(); + if(!settings->useExpertMode()) + m_oplink->Apply->setVisible(false); addApplySaveButtons(m_oplink->Apply, m_oplink->Save); - addUAVObjectToWidgetRelation("OPLinkSettings", "UAVTalk", m_oplink->UAVTalk); - addUAVObjectToWidgetRelation("OPLinkSettings", "PPM", m_oplink->PPM); - addUAVObjectToWidgetRelation("OPLinkSettings", "InputConnection", m_oplink->InputConnection); - addUAVObjectToWidgetRelation("OPLinkSettings", "OutputConnection", m_oplink->OutputConnection); - addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed); + addUAVObjectToWidgetRelation("OPLinkSettings", "MainPort", m_oplink->MainPort); + addUAVObjectToWidgetRelation("OPLinkSettings", "FlexiPort", m_oplink->FlexiPort); + addUAVObjectToWidgetRelation("OPLinkSettings", "VCPPort", m_oplink->VCPPort); addUAVObjectToWidgetRelation("OPLinkSettings", "MaxRFPower", m_oplink->MaxRFTxPower); - addUAVObjectToWidgetRelation("OPLinkSettings", "SendTimeout", m_oplink->SendTimeout); - addUAVObjectToWidgetRelation("OPLinkSettings", "MinPacketSize", m_oplink->MinPacketSize); addUAVObjectToWidgetRelation("OPLinkSettings", "FrequencyCalibration", m_oplink->FrequencyCalibration); addUAVObjectToWidgetRelation("OPLinkSettings", "MinFrequency", m_oplink->MinFrequency); addUAVObjectToWidgetRelation("OPLinkSettings", "MaxFrequency", m_oplink->MaxFrequency); + addUAVObjectToWidgetRelation("OPLinkStatus", "DeviceID", m_oplink->DeviceID); addUAVObjectToWidgetRelation("OPLinkStatus", "RxGood", m_oplink->Good); addUAVObjectToWidgetRelation("OPLinkStatus", "RxCorrected", m_oplink->Corrected); addUAVObjectToWidgetRelation("OPLinkStatus", "RxErrors", m_oplink->Errors); @@ -79,27 +80,89 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget addUAVObjectToWidgetRelation("OPLinkStatus", "Resets", m_oplink->Resets); addUAVObjectToWidgetRelation("OPLinkStatus", "Timeouts", m_oplink->Timeouts); addUAVObjectToWidgetRelation("OPLinkStatus", "RSSI", m_oplink->RSSI); - addUAVObjectToWidgetRelation("OPLinkStatus", "AFCCorrection", m_oplink->AFCCorrection); + addUAVObjectToWidgetRelation("OPLinkStatus", "HeapRemaining", m_oplink->FreeHeap); addUAVObjectToWidgetRelation("OPLinkStatus", "LinkQuality", m_oplink->LinkQuality); addUAVObjectToWidgetRelation("OPLinkStatus", "RXSeq", m_oplink->RXSeq); addUAVObjectToWidgetRelation("OPLinkStatus", "TXSeq", m_oplink->TXSeq); addUAVObjectToWidgetRelation("OPLinkStatus", "RXRate", m_oplink->RXRate); addUAVObjectToWidgetRelation("OPLinkStatus", "TXRate", m_oplink->TXRate); - // Connect to the pair ID radio buttons. - connect(m_oplink->PairSelect1, SIGNAL(toggled(bool)), this, SLOT(pairIDToggled(bool))); - connect(m_oplink->PairSelect2, SIGNAL(toggled(bool)), this, SLOT(pairIDToggled(bool))); - connect(m_oplink->PairSelect3, SIGNAL(toggled(bool)), this, SLOT(pairIDToggled(bool))); - connect(m_oplink->PairSelect4, SIGNAL(toggled(bool)), this, SLOT(pairIDToggled(bool))); - - // Connect to the binding buttons. - connect(m_oplink->BindingAdd, SIGNAL(pressed()), this, SLOT(addBinding())); - connect(m_oplink->BindingRemove, SIGNAL(pressed()), this, SLOT(removeBinding())); - m_oplink->BindingAdd->setEnabled(false); - m_oplink->BindingRemove->setEnabled(false); - - // Connect to changes to the bindings widgets. - connect(m_oplink->Bindings, SIGNAL(itemSelectionChanged()), this, SLOT(bindingsSelectionChanged())); + signalMapperAddBinding = new QSignalMapper(this); + signalMapperRemBinding = new QSignalMapper(this); + connect(m_oplink->BindingAdd_1, SIGNAL(clicked()), signalMapperAddBinding, SLOT(map())); + signalMapperAddBinding->setMapping(m_oplink->BindingAdd_1, (QWidget*)(m_oplink->BindingID_1)); + connect(m_oplink->BindingRemove_1, SIGNAL(clicked()), signalMapperRemBinding, SLOT(map())); + signalMapperRemBinding->setMapping(m_oplink->BindingRemove_1, (QWidget*)(m_oplink->BindingID_1)); + addUAVObjectToWidgetRelation("OPLinkSettings", "Bindings", m_oplink->BindingID_1, "0"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteMainPort", m_oplink->RemoteMainPort_1, "0"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteFlexiPort", m_oplink->RemoteFlexiPort_1, "0"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteVCPPort", m_oplink->RemoteVCPPort_1, "0"); + addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed_1, "0"); + connect(m_oplink->BindingAdd_2, SIGNAL(clicked()), signalMapperAddBinding, SLOT(map())); + signalMapperAddBinding->setMapping(m_oplink->BindingAdd_2, (QWidget*)(m_oplink->BindingID_2)); + connect(m_oplink->BindingRemove_2, SIGNAL(clicked()), signalMapperRemBinding, SLOT(map())); + signalMapperRemBinding->setMapping(m_oplink->BindingRemove_2, (QWidget*)(m_oplink->BindingID_2)); + addUAVObjectToWidgetRelation("OPLinkSettings", "Bindings", m_oplink->BindingID_2, "1"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteMainPort", m_oplink->RemoteMainPort_2, "1"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteFlexiPort", m_oplink->RemoteFlexiPort_2, "1"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteVCPPort", m_oplink->RemoteVCPPort_2, "1"); + addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed_2, "1"); + connect(m_oplink->BindingAdd_3, SIGNAL(clicked()), signalMapperAddBinding, SLOT(map())); + signalMapperAddBinding->setMapping(m_oplink->BindingAdd_3, (QWidget*)(m_oplink->BindingID_3)); + connect(m_oplink->BindingRemove_3, SIGNAL(clicked()), signalMapperRemBinding, SLOT(map())); + signalMapperRemBinding->setMapping(m_oplink->BindingRemove_3, (QWidget*)(m_oplink->BindingID_3)); + addUAVObjectToWidgetRelation("OPLinkSettings", "Bindings", m_oplink->BindingID_3, "2"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteMainPort", m_oplink->RemoteMainPort_3, "2"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteFlexiPort", m_oplink->RemoteFlexiPort_3, "2"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteVCPPort", m_oplink->RemoteVCPPort_3, "2"); + addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed_3, "2"); + connect(m_oplink->BindingAdd_4, SIGNAL(clicked()), signalMapperAddBinding, SLOT(map())); + signalMapperAddBinding->setMapping(m_oplink->BindingAdd_4, (QWidget*)(m_oplink->BindingID_4)); + connect(m_oplink->BindingRemove_4, SIGNAL(clicked()), signalMapperRemBinding, SLOT(map())); + signalMapperRemBinding->setMapping(m_oplink->BindingRemove_4, (QWidget*)(m_oplink->BindingID_4)); + addUAVObjectToWidgetRelation("OPLinkSettings", "Bindings", m_oplink->BindingID_4, "3"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteMainPort", m_oplink->RemoteMainPort_4, "3"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteFlexiPort", m_oplink->RemoteFlexiPort_4, "3"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteVCPPort", m_oplink->RemoteVCPPort_4, "3"); + addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed_4, "3"); + connect(m_oplink->BindingAdd_5, SIGNAL(clicked()), signalMapperAddBinding, SLOT(map())); + signalMapperAddBinding->setMapping(m_oplink->BindingAdd_5, (QWidget*)(m_oplink->BindingID_5)); + connect(m_oplink->BindingRemove_5, SIGNAL(clicked()), signalMapperRemBinding, SLOT(map())); + signalMapperRemBinding->setMapping(m_oplink->BindingRemove_5, (QWidget*)(m_oplink->BindingID_5)); + addUAVObjectToWidgetRelation("OPLinkSettings", "Bindings", m_oplink->BindingID_5, "4"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteMainPort", m_oplink->RemoteMainPort_5, "4"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteFlexiPort", m_oplink->RemoteFlexiPort_5, "4"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteVCPPort", m_oplink->RemoteVCPPort_5, "4"); + addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed_5, "4"); + connect(m_oplink->BindingAdd_6, SIGNAL(clicked()), signalMapperAddBinding, SLOT(map())); + signalMapperAddBinding->setMapping(m_oplink->BindingAdd_6, (QWidget*)(m_oplink->BindingID_6)); + connect(m_oplink->BindingRemove_6, SIGNAL(clicked()), signalMapperRemBinding, SLOT(map())); + signalMapperRemBinding->setMapping(m_oplink->BindingRemove_6, (QWidget*)(m_oplink->BindingID_6)); + addUAVObjectToWidgetRelation("OPLinkSettings", "Bindings", m_oplink->BindingID_6, "5"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteMainPort", m_oplink->RemoteMainPort_6, "5"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteFlexiPort", m_oplink->RemoteFlexiPort_6, "5"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteVCPPort", m_oplink->RemoteVCPPort_6, "5"); + addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed_6, "5"); + connect(m_oplink->BindingAdd_7, SIGNAL(clicked()), signalMapperAddBinding, SLOT(map())); + signalMapperAddBinding->setMapping(m_oplink->BindingAdd_7, (QWidget*)(m_oplink->BindingID_7)); + connect(m_oplink->BindingRemove_7, SIGNAL(clicked()), signalMapperRemBinding, SLOT(map())); + signalMapperRemBinding->setMapping(m_oplink->BindingRemove_7, (QWidget*)(m_oplink->BindingID_7)); + addUAVObjectToWidgetRelation("OPLinkSettings", "Bindings", m_oplink->BindingID_7, "6"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteMainPort", m_oplink->RemoteMainPort_7, "6"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteFlexiPort", m_oplink->RemoteFlexiPort_7, "6"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteVCPPort", m_oplink->RemoteVCPPort_7, "6"); + addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed_7, "6"); + connect(m_oplink->BindingAdd_8, SIGNAL(clicked()), signalMapperAddBinding, SLOT(map())); + signalMapperAddBinding->setMapping(m_oplink->BindingAdd_8, (QWidget*)(m_oplink->BindingID_8)); + connect(m_oplink->BindingRemove_8, SIGNAL(clicked()), signalMapperRemBinding, SLOT(map())); + signalMapperRemBinding->setMapping(m_oplink->BindingRemove_8, (QWidget*)(m_oplink->BindingID_8)); + addUAVObjectToWidgetRelation("OPLinkSettings", "Bindings", m_oplink->BindingID_8, "7"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteMainPort", m_oplink->RemoteMainPort_8, "7"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteFlexiPort", m_oplink->RemoteFlexiPort_8, "7"); + addUAVObjectToWidgetRelation("OPLinkSettings", "RemoteVCPPort", m_oplink->RemoteVCPPort_8, "7"); + addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed_8, "7"); + connect(signalMapperAddBinding, SIGNAL(mapped(QWidget *)), this, SLOT(addBinding(QWidget *))); + connect(signalMapperRemBinding, SIGNAL(mapped(QWidget *)), this, SLOT(removeBinding(QWidget *))); //Add scroll bar when necessary QScrollArea *scroll = new QScrollArea; @@ -115,37 +178,8 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget ConfigPipXtremeWidget::~ConfigPipXtremeWidget() { - // Do nothing -} - -void ConfigPipXtremeWidget::refreshValues() -{ -} - -void ConfigPipXtremeWidget::applySettings() -{ - OPLinkSettings *oplinkSettings = OPLinkSettings::GetInstance(getObjectManager()); - OPLinkSettings::DataFields oplinkSettingsData = oplinkSettings->getData(); - - // Get the pair ID. - quint32 pairID = 0; - bool okay; - if (m_oplink->PairSelect1->isChecked()) - pairID = m_oplink->PairID1->text().toUInt(&okay, 16); - else if (m_oplink->PairSelect2->isChecked()) - pairID = m_oplink->PairID2->text().toUInt(&okay, 16); - else if (m_oplink->PairSelect3->isChecked()) - pairID = m_oplink->PairID3->text().toUInt(&okay, 16); - else if (m_oplink->PairSelect4->isChecked()) - pairID = m_oplink->PairID4->text().toUInt(&okay, 16); - oplinkSettings->setData(oplinkSettingsData); -} - -void ConfigPipXtremeWidget::saveSettings() -{ - //applySettings(); - UAVObject *obj = OPLinkSettings::GetInstance(getObjectManager()); - saveObjectToSD(obj); + delete signalMapperAddBinding; + delete signalMapperRemBinding; } /*! @@ -158,32 +192,24 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object) if (!settingsUpdated) oplinkSettingsObj->requestUpdate(); - // Get the current pairID - //OPLinkSettings *oplinkSettings = OPLinkSettings::GetInstance(getObjectManager()); - quint32 pairID = 0; - // Update the detected devices. UAVObjectField* pairIdField = object->getField("PairIDs"); if (pairIdField) { quint32 pairid1 = pairIdField->getValue(0).toUInt(); m_oplink->PairID1->setText(QString::number(pairid1, 16).toUpper()); m_oplink->PairID1->setEnabled(false); - m_oplink->PairSelect1->setChecked(pairID && (pairID == pairid1)); m_oplink->PairSelect1->setEnabled(pairid1); quint32 pairid2 = pairIdField->getValue(1).toUInt(); m_oplink->PairID2->setText(QString::number(pairIdField->getValue(1).toUInt(), 16).toUpper()); m_oplink->PairID2->setEnabled(false); - m_oplink->PairSelect2->setChecked(pairID && (pairID == pairid2)); m_oplink->PairSelect2->setEnabled(pairid2); quint32 pairid3 = pairIdField->getValue(2).toUInt(); m_oplink->PairID3->setText(QString::number(pairIdField->getValue(2).toUInt(), 16).toUpper()); m_oplink->PairID3->setEnabled(false); - m_oplink->PairSelect3->setChecked(pairID && (pairID == pairid3)); m_oplink->PairSelect3->setEnabled(pairid3); quint32 pairid4 = pairIdField->getValue(3).toUInt(); m_oplink->PairID4->setText(QString::number(pairIdField->getValue(3).toUInt(), 16).toUpper()); m_oplink->PairID4->setEnabled(false); - m_oplink->PairSelect4->setChecked(pairID && (pairID == pairid4)); m_oplink->PairSelect4->setEnabled(pairid4); } else { qDebug() << "PipXtremeGadgetWidget: Count not read PairID field."; @@ -249,14 +275,6 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object) qDebug() << "PipXtremeGadgetWidget: Count not read Description field."; } - // Update the DeviceID field - UAVObjectField* idField = object->getField("DeviceID"); - if (idField) { - m_oplink->DeviceID->setText(QString::number(idField->getValue().toUInt(), 16).toUpper()); - } else { - qDebug() << "PipXtremeGadgetWidget: Count not read DeviceID field."; - } - // Update the link state UAVObjectField* linkField = object->getField("LinkState"); if (linkField) { @@ -277,9 +295,6 @@ void ConfigPipXtremeWidget::updateSettings(UAVObject *object) { settingsUpdated = true; enableControls(true); - - // Refresh the list widget. - refreshBindingsList(); } } @@ -292,88 +307,32 @@ void ConfigPipXtremeWidget::disconnected() } } -void ConfigPipXtremeWidget::pairIDToggled(bool checked) +void ConfigPipXtremeWidget::addBinding(QWidget *w) { - bool enabled = (m_oplink->PairSelect1->isChecked() || m_oplink->PairSelect2->isChecked() || m_oplink->PairSelect3->isChecked() || m_oplink->PairSelect4->isChecked()); - m_oplink->BindingAdd->setEnabled(enabled); + if(QLineEdit *le = qobject_cast(w)) { + + // Get the pair ID out of the selection widget + quint32 pairID = 0; + bool okay; + if (m_oplink->PairSelect1->isChecked()) + pairID = m_oplink->PairID1->text().toUInt(&okay, 16); + else if (m_oplink->PairSelect2->isChecked()) + pairID = m_oplink->PairID2->text().toUInt(&okay, 16); + else if (m_oplink->PairSelect3->isChecked()) + pairID = m_oplink->PairID3->text().toUInt(&okay, 16); + else if (m_oplink->PairSelect4->isChecked()) + pairID = m_oplink->PairID4->text().toUInt(&okay, 16); + + // Store the ID in the first open slot (or the last slot if all are full). + le->setText(QString::number(pairID, 16).toUpper()); + } } -void ConfigPipXtremeWidget::bindingsSelectionChanged() +void ConfigPipXtremeWidget::removeBinding(QWidget *w) { - bool enabled = (m_oplink->Bindings->selectedItems().size() > 0); - m_oplink->BindingRemove->setEnabled(enabled); -} - -void ConfigPipXtremeWidget::refreshBindingsList() -{ - m_oplink->Bindings->clear(); - for (quint32 slot = 0; slot < OPLinkSettings::BINDINGS_NUMELEM; ++slot) - { - quint32 id = oplinkSettingsObj->getBindings(slot); - if (id != 0) - m_oplink->Bindings->addItem(QString::number(id, 16).toUpper()); - } -} - -void ConfigPipXtremeWidget::addBinding() -{ - - // Get the pair ID out of the selection widget - quint32 pairID = 0; - bool okay; - if (m_oplink->PairSelect1->isChecked()) - pairID = m_oplink->PairID1->text().toUInt(&okay, 16); - else if (m_oplink->PairSelect2->isChecked()) - pairID = m_oplink->PairID2->text().toUInt(&okay, 16); - else if (m_oplink->PairSelect3->isChecked()) - pairID = m_oplink->PairID3->text().toUInt(&okay, 16); - else if (m_oplink->PairSelect4->isChecked()) - pairID = m_oplink->PairID4->text().toUInt(&okay, 16); - - // Find a slot for this pair ID in the binding list. - quint32 slot = 0; - for ( ; slot < OPLinkSettings::BINDINGS_NUMELEM - 1; ++slot) - { - quint32 id = oplinkSettingsObj->getBindings(slot); - - // Is this ID already in the list? - if (id == pairID) - return; - - // Is this slot empty? - if (id == 0) - break; - } - - // Store the ID in the first open slot (or the last slot if all are full). - oplinkSettingsObj->setBindings(slot, pairID); - - // Refresh the list widget. - refreshBindingsList(); -} - -void ConfigPipXtremeWidget::removeBinding() -{ - // Get the selected rows from the bindings list widget. - QList selected = m_oplink->Bindings->selectedItems(); - - // Zero out the selected rows in the bindings list. - for (int i = 0; i < selected.size(); ++i) - oplinkSettingsObj->setBindings(m_oplink->Bindings->row(selected[i]), 0); - - // Refresh the list widget and compact the bindings list. - m_oplink->Bindings->clear(); - quint32 outSlot = 0; - for (quint32 slot = 0; slot < OPLinkSettings::BINDINGS_NUMELEM; ++slot) - { - quint32 id = oplinkSettingsObj->getBindings(slot); - if (id != 0) { - oplinkSettingsObj->setBindings(outSlot++, id); - m_oplink->Bindings->addItem(QString::number(id, 16).toUpper()); - } - } - for ( ; outSlot < OPLinkSettings::BINDINGS_NUMELEM; ++outSlot) - oplinkSettingsObj->setBindings(outSlot, 0); + if(QLineEdit *le = qobject_cast(w)) { + le->setText(QString::number(0, 16).toUpper()); + } } /** diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h index 29e67ccba..9a612bf94 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h @@ -43,28 +43,27 @@ public: public slots: void updateStatus(UAVObject *object1); void updateSettings(UAVObject *object1); - void refreshBindingsList(); private: Ui_PipXtremeWidget *m_oplink; // The OPLink status UAVObject - UAVDataObject* oplinkStatusObj; + UAVDataObject *oplinkStatusObj; // The OPLink ssettins UAVObject OPLinkSettings* oplinkSettingsObj; + // Are the settings current? bool settingsUpdated; + // Signal mappers to add arguments to signals. + QSignalMapper *signalMapperAddBinding; + QSignalMapper *signalMapperRemBinding; + private slots: - void refreshValues(); - void applySettings(); - void saveSettings(); void disconnected(); - void pairIDToggled(bool checked); - void addBinding(); - void removeBinding(); - void bindingsSelectionChanged(); + void addBinding(QWidget *w); + void removeBinding(QWidget *w); }; #endif // CONFIGTXPIDWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui index 6d7f36b8f..0636e5fcf 100644 --- a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui +++ b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui @@ -23,36 +23,10 @@ QFrame::Raised - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - true - - - - + + - + @@ -139,7 +113,7 @@ - + QFrame::StyledPanel @@ -278,7 +252,7 @@ - + Device ID @@ -288,7 +262,7 @@ - + @@ -332,64 +306,7 @@ - - - - RX Good - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 101 - 16777215 - - - - - 75 - true - - - - The percentage of packets that were corrected with error correction - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - + Link State @@ -399,7 +316,7 @@ - + @@ -449,7 +366,337 @@ - + + + + Link Quality + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + RSSI + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + true + + + + + + + TX Seq. No. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + TX Rate (B/s) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + RX Seq. No. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + RX Rate (B/s) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + RX Good + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + The percentage of packets that were corrected with error correction + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + RX Corrected @@ -459,7 +706,7 @@ - + @@ -506,49 +753,7 @@ - - - - Link Quality - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - + RX Errors @@ -558,7 +763,7 @@ - + @@ -599,52 +804,7 @@ - - - - RSSI - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - true - - - - + RX Missed @@ -654,7 +814,7 @@ - + @@ -701,18 +861,162 @@ - - + + - AFC Corr. + TX Dropped Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + The number of packets that were unable to be transmitted + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + TX Resent + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + The number of packets that were unable to be transmitted + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + Tx Failure + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + Free Heap + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + 101 @@ -740,6 +1044,138 @@ + + + + UAVTalk Errors + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + Resets + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + true + + + + + + + Timeouts + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -797,816 +1233,10 @@ - - - - TX Seq. No. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - - - - TX Dropped - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 101 - 16777215 - - - - - 75 - true - - - - The number of packets that were unable to be transmitted - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - TX Rate (B/s) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - - - - TX Resent - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 101 - 16777215 - - - - - 75 - true - - - - The number of packets that were unable to be transmitted - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - RX Seq. No. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - - - - Tx Failure - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - - - - RX Rate (B/s) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - - - - UAVTalk Errors - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - - - - Timeouts - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - - - - Resets - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 101 - 16777215 - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 4px; - background: rgba(0, 0, 0, 16); - /* background: transparent; */ - /* selection-background-color: darkgray;*/ - } - - - false - - - true - - - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Configuration - - - - - - UAVTalk - - - - - - - PPM - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 16777215 - 16777215 - - - - Choose the PPM function - - - - - - - Input Connection - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 16777215 - 16777215 - - - - Choose which port to communicate over on this modem - - - - - - - Output Connection - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 16777215 - 16777215 - - - - Choose which port to communicate over on the remote modem - - - - - - - COM Speed - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 16777215 - 16777215 - - - - Set the telemetry port speed - - - - - - - Max RF Tx Power(mW) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 16777215 - 16777215 - - - - Set the maximum TX output power the modem will use - - - Qt::LeftToRight - - - 0 - - - - - - - Send Timeout (ms) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Set the send timeout - - - true - - - 255 - - - - - - - Min Packet Size - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Set the minimum packet size - - - true - - - 255 - - - - - - - Frequency Calibration - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Calibrate the modems RF carrier frequency - - - true - - - 255 - - - - - - - Min. Frequency (Hz) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Set the modems minimum RF carrier frequency - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - 400000000 - - - 1000000000 - - - 100000 - - - - - - - Max. Frequency (Hz) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Set the modems maximum RF carrier frequency - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - 400000000 - - - 1000000000 - - - 100000 - - - - groupBox - groupBox_3 @@ -1618,7 +1248,7 @@ - Bindings + Remote Modems @@ -1815,70 +1445,1248 @@ - - - - - 0 - 0 - + + + + + + + + 75 + true + + + + Bindings + + + + + + Add - - QFrame::StyledPanel + + Qt::AlignCenter - - QFrame::Raised - - - - - - Add >> - - - - - - - Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - + + + + Clear + + + Qt::AlignCenter + + + + + + + Device ID + + + Qt::AlignCenter + + + + + + + Main Port + + + Qt::AlignCenter + + + + + + + Flexi Port + + + Qt::AlignCenter + + + + + + + VCP Port + + + Qt::AlignCenter + + + + + + + COM Speed + + + Qt::AlignCenter + + + + + + + true + + + + + 0 + 0 + 757 + 244 + + + + + + + Add >> + + + + + + + Clear + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 12345678 + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote main port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote flexi port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote USB virtual com port + + + + + + + + 16777215 + 16777215 + + + + Set the telemetry port speed + + + + + + + Add >> + + + + + + + Clear + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 12345678 + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote main port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote flexi port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote USB virtual com port + + + + + + + + 16777215 + 16777215 + + + + Set the telemetry port speed + + + + + + + Add >> + + + + + + + Clear + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 12345678 + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote main port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote flexi port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote USB virtual com port + + + + + + + + 16777215 + 16777215 + + + + Set the telemetry port speed + + + + + + + Add >> + + + + + + + Clear + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 12345678 + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote main port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote flexi port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote USB virtual com port + + + + + + + + 16777215 + 16777215 + + + + Set the telemetry port speed + + + + + + + Add >> + + + + + + + Clear + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 12345678 + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote main port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote flexi port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote USB virtual com port + + + + + + + + 16777215 + 16777215 + + + + Set the telemetry port speed + + + + + + + Add >> + + + + + + + Clear + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 12345678 + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote main port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote flexi port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote USB virtual com port + + + + + + + + 16777215 + 16777215 + + + + Set the telemetry port speed + + + + + + + Add >> + + + + + + + Clear + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 12345678 + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote main port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote flexi port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote USB virtual com port + + + + + + + + 16777215 + 16777215 + + + + Set the telemetry port speed + + + + + + + Add >> + + + + + + + Clear + + + + + + + + 0 + 0 + + + + + 101 + 16777215 + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 4px; + background: rgba(0, 0, 0, 16); + /* background: transparent; */ + /* selection-background-color: darkgray;*/ + } + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 12345678 + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote main port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote flexi port + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the remote USB virtual com port + + + + + + + + 16777215 + 16777215 + + + + Set the telemetry port speed + + + + + + + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Configuration + + + + + + Main Port + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the main port + + + + + + + Flexi Port + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the flexi port + + + + + + + VCP Port + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 16777215 + 16777215 + + + + Choose the function for the USB virtual com port + + + + + + + Max RF Tx Power(mW) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 16777215 + 16777215 + + + + Set the maximum TX output power the modem will use + + + Qt::LeftToRight + + + 0 + + + + + + + Frequency Calibration + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + - + 0 0 - 200 + 16777215 16777215 + + Calibrate the modems RF carrier frequency + + + true + + + 255 + + + + + + + Min. Frequency (Hz) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Set the modems minimum RF carrier frequency + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 400000000 + + + 1000000000 + + + 100000 + + + + + + + Max. Frequency (Hz) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Set the modems maximum RF carrier frequency + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 400000000 + + + 1000000000 + + + 100000 + + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -1895,18 +2703,8 @@ PairID4 FirmwareVersion SerialNumber - DeviceID - LinkState - Errors - UAVTalkErrors - Resets - TXRate - RXRate MaxRFTxPower - SendTimeout - MinPacketSize FrequencyCalibration - graphicsView_Spectrum Apply Save diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp index 85b0f721f..89260ff30 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp @@ -886,10 +886,9 @@ QVariant UAVObjectField::getValue(quint32 index) { quint8 tmpenum; memcpy(&tmpenum, &data[offset + numBytesPerElement*index], numBytesPerElement); - // Q_ASSERT((tmpenum < options.length()) && (tmpenum >= 0)); // catch bad enum settings if(tmpenum >= options.length()) { qDebug() << "Invalid value for" << name; - return QVariant( QString("Bad Value") ); + tmpenum = 0; } return QVariant( options[tmpenum] ); break; @@ -1015,7 +1014,9 @@ void UAVObjectField::setValue(const QVariant& value, quint32 index) case ENUM: { qint8 tmpenum = options.indexOf( value.toString() ); - Q_ASSERT(tmpenum >= 0); // To catch any programming errors where we set invalid values + // Default to 0 on invalid values. + if(tmpenum < 0) + tmpenum = 0; memcpy(&data[offset + numBytesPerElement*index], &tmpenum, numBytesPerElement); break; } diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index b6fcabecf..08f6cde02 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -457,11 +457,11 @@ void ConfigTaskWidget::forceShadowUpdates() { foreach (shadow * sh, oTw->shadowsList) { - disconnectWidgetUpdatesToSlot((QWidget*)sh->widget,SLOT(widgetsContentsChanged())); - checkWidgetsLimits(sh->widget,oTw->field,oTw->index,sh->isLimited,getVariantFromWidget(oTw->widget,oTw->scale),sh->scale); - setWidgetFromVariant(sh->widget,getVariantFromWidget(oTw->widget,oTw->scale),sh->scale); + disconnectWidgetUpdatesToSlot((QWidget*)sh->widget, SLOT(widgetsContentsChanged())); + checkWidgetsLimits(sh->widget, oTw->field, oTw->index, sh->isLimited, getVariantFromWidget(oTw->widget, oTw->scale, oTw->getUnits()), sh->scale); + setWidgetFromVariant(sh->widget, getVariantFromWidget(oTw->widget, oTw->scale, oTw->getUnits()), sh->scale); emit widgetContentsChanged((QWidget*)sh->widget); - connectWidgetUpdatesToSlot((QWidget*)sh->widget,SLOT(widgetsContentsChanged())); + connectWidgetUpdatesToSlot((QWidget*)sh->widget, SLOT(widgetsContentsChanged())); } } @@ -480,7 +480,7 @@ void ConfigTaskWidget::widgetsContentsChanged() if(oTw->widget==(QWidget*)sender()) { scale=oTw->scale; - checkWidgetsLimits((QWidget*)sender(),oTw->field,oTw->index,oTw->isLimited,getVariantFromWidget((QWidget*)sender(),oTw->scale),oTw->scale); + checkWidgetsLimits((QWidget*)sender(), oTw->field, oTw->index, oTw->isLimited, getVariantFromWidget((QWidget*)sender(), oTw->scale, oTw->getUnits()), oTw->scale); } else { @@ -489,25 +489,25 @@ void ConfigTaskWidget::widgetsContentsChanged() if(sh->widget==(QWidget*)sender()) { scale=sh->scale; - checkWidgetsLimits((QWidget*)sender(),oTw->field,oTw->index,sh->isLimited,getVariantFromWidget((QWidget*)sender(),scale),scale); + checkWidgetsLimits((QWidget*)sender(), oTw->field, oTw->index, sh->isLimited, getVariantFromWidget((QWidget*)sender(), scale, oTw->getUnits()), scale); } } } if(oTw->widget!=(QWidget *)sender()) { - disconnectWidgetUpdatesToSlot((QWidget*)oTw->widget,SLOT(widgetsContentsChanged())); - checkWidgetsLimits(oTw->widget,oTw->field,oTw->index,oTw->isLimited,getVariantFromWidget((QWidget*)sender(),scale),oTw->scale); - setWidgetFromVariant(oTw->widget,getVariantFromWidget((QWidget*)sender(),scale),oTw->scale); + disconnectWidgetUpdatesToSlot((QWidget*)oTw->widget, SLOT(widgetsContentsChanged())); + checkWidgetsLimits(oTw->widget, oTw->field, oTw->index, oTw->isLimited, getVariantFromWidget((QWidget*)sender(), scale, oTw->getUnits()), oTw->scale); + setWidgetFromVariant(oTw->widget, getVariantFromWidget((QWidget*)sender(), scale, oTw->getUnits()), oTw->scale); emit widgetContentsChanged((QWidget*)oTw->widget); - connectWidgetUpdatesToSlot((QWidget*)oTw->widget,SLOT(widgetsContentsChanged())); + connectWidgetUpdatesToSlot((QWidget*)oTw->widget, SLOT(widgetsContentsChanged())); } foreach (shadow * sh, oTw->shadowsList) { if(sh->widget!=(QWidget*)sender()) { disconnectWidgetUpdatesToSlot((QWidget*)sh->widget,SLOT(widgetsContentsChanged())); - checkWidgetsLimits(sh->widget,oTw->field,oTw->index,sh->isLimited,getVariantFromWidget((QWidget*)sender(),scale),sh->scale); - setWidgetFromVariant(sh->widget,getVariantFromWidget((QWidget*)sender(),scale),sh->scale); + checkWidgetsLimits(sh->widget, oTw->field, oTw->index, sh->isLimited, getVariantFromWidget((QWidget*)sender(), scale, oTw->getUnits()), sh->scale); + setWidgetFromVariant(sh->widget, getVariantFromWidget((QWidget*)sender(), scale, oTw->getUnits()), sh->scale); emit widgetContentsChanged((QWidget*)sh->widget); connectWidgetUpdatesToSlot((QWidget*)sh->widget,SLOT(widgetsContentsChanged())); } @@ -1034,7 +1034,7 @@ bool ConfigTaskWidget::setFieldFromWidget(QWidget * widget,UAVObjectField * fiel { if(!widget || !field) return false; - QVariant ret=getVariantFromWidget(widget,scale); + QVariant ret = getVariantFromWidget(widget, scale, field->getUnits()); if(ret.isValid()) { field->setValue(ret,index); @@ -1051,7 +1051,7 @@ bool ConfigTaskWidget::setFieldFromWidget(QWidget * widget,UAVObjectField * fiel * @param scale scale to be used on the assignement * @return returns the value of the widget times the scale */ -QVariant ConfigTaskWidget::getVariantFromWidget(QWidget * widget,double scale) +QVariant ConfigTaskWidget::getVariantFromWidget(QWidget *widget, double scale, QString units) { if(QComboBox * cb=qobject_cast(widget)) { @@ -1075,7 +1075,13 @@ QVariant ConfigTaskWidget::getVariantFromWidget(QWidget * widget,double scale) } else if(QLineEdit * cb=qobject_cast(widget)) { - return (QString)cb->displayText(); + QString value = (QString)cb->displayText(); + if(units == "hex") { + bool ok; + return value.toUInt(&ok, 16); + } else { + return value; + } } else return QVariant(); @@ -1083,13 +1089,14 @@ QVariant ConfigTaskWidget::getVariantFromWidget(QWidget * widget,double scale) /** * Sets a widget from a variant * @param widget pointer for the widget to set - * @param scale scale to be used on the assignement * @param value value to be used on the assignement + * @param scale scale to be used on the assignement + * @param units the units for the value * @return returns true if the assignement was successfull */ -bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, double scale) +bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, double scale, QString units) { - if(QComboBox * cb=qobject_cast(widget)) + if(QComboBox * cb=qobject_cast(widget)) { cb->setCurrentIndex(cb->findText(value.toString())); return true; @@ -1125,15 +1132,30 @@ bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, dou } else if(QLineEdit * cb=qobject_cast(widget)) { - if(scale==0) - cb->setText(value.toString()); - else + if((scale== 0) || (scale == 1)) { + if(units == "hex") { + cb->setText(QString::number(value.toUInt(), 16).toUpper()); + } else { + cb->setText(value.toString()); + } + } else cb->setText(QString::number((value.toDouble()/scale))); return true; } else return false; } +/** + * Sets a widget from a variant + * @param widget pointer for the widget to set + * @param value value to be used on the assignement + * @param scale scale to be used on the assignement + * @return returns true if the assignement was successfull + */ +bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, double scale) +{ + return setWidgetFromVariant(widget, value, scale, QString("")); +} /** * Sets a widget from a UAVObject field * @param widget pointer to the widget to set @@ -1154,7 +1176,7 @@ bool ConfigTaskWidget::setWidgetFromField(QWidget * widget,UAVObjectField * fiel } QVariant var=field->getValue(index); checkWidgetsLimits(widget,field,index,hasLimits,var,scale); - bool ret=setWidgetFromVariant(widget,var,scale); + bool ret = setWidgetFromVariant(widget, var, scale, field->getUnits()); if(ret) return true; else diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index f25292143..d3c5c21cf 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -68,6 +68,13 @@ public: double scale; bool isLimited; QList shadowsList; + QString getUnits() const { + if (field) { + return field->getUnits(); + } else { + return QString(""); + } + } }; struct temphelper @@ -181,8 +188,9 @@ private: bool dirty; bool setFieldFromWidget(QWidget *widget, UAVObjectField *field, int index, double scale); bool setWidgetFromField(QWidget *widget, UAVObjectField *field, int index, double scale, bool hasLimits); - QVariant getVariantFromWidget(QWidget *widget, double scale); - bool setWidgetFromVariant(QWidget *widget,QVariant value,double scale); + QVariant getVariantFromWidget(QWidget *widget, double scale, QString units); + bool setWidgetFromVariant(QWidget *widget, QVariant value, double scale, QString units); + bool setWidgetFromVariant(QWidget *widget, QVariant value, double scale); void connectWidgetUpdatesToSlot(QWidget *widget, const char *function); void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function); void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale); diff --git a/shared/uavobjectdefinition/oplinksettings.xml b/shared/uavobjectdefinition/oplinksettings.xml index f24bba648..7c7403c87 100644 --- a/shared/uavobjectdefinition/oplinksettings.xml +++ b/shared/uavobjectdefinition/oplinksettings.xml @@ -1,15 +1,15 @@ OPLink configurations options. - - - - - - + + + + + + + + - - diff --git a/shared/uavobjectdefinition/oplinkstatus.xml b/shared/uavobjectdefinition/oplinkstatus.xml index 619ab1e81..1e79630fe 100755 --- a/shared/uavobjectdefinition/oplinkstatus.xml +++ b/shared/uavobjectdefinition/oplinkstatus.xml @@ -2,10 +2,11 @@ OPLink device status. - + - + + @@ -18,14 +19,13 @@ - - +