mirror of
https://github.com/peterantypas/maiana.git
synced 2025-05-19 00:40:08 -07:00
Resetting MCU every hour
This commit is contained in:
parent
4613466268
commit
529f6f05ca
@ -459,7 +459,7 @@
|
|||||||
|
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.target.other.1597884643" name="Other target flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.target.other" useByScannerDiscovery="true"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.target.other.1597884643" name="Other target flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.target.other" useByScannerDiscovery="true"/>
|
||||||
|
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.364488473" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.more" valueType="enumerated"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.364488473" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.size" valueType="enumerated"/>
|
||||||
|
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.751072022" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.751072022" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ public:
|
|||||||
virtual ~RFIC();
|
virtual ~RFIC();
|
||||||
|
|
||||||
void setRSSIAdjustment(short rssiAdj);
|
void setRSSIAdjustment(short rssiAdj);
|
||||||
|
uint16_t partNumber();
|
||||||
protected:
|
protected:
|
||||||
virtual void configure();
|
virtual void configure();
|
||||||
bool sendCmd(uint8_t cmd, void* params, uint8_t paramLen, void* result, uint8_t resultLen);
|
bool sendCmd(uint8_t cmd, void* params, uint8_t paramLen, void* result, uint8_t resultLen);
|
||||||
|
@ -58,7 +58,8 @@ private:
|
|||||||
Transceiver *mTransceiverIC;
|
Transceiver *mTransceiverIC;
|
||||||
Receiver *mReceiverIC;
|
Receiver *mReceiverIC;
|
||||||
bool mInitializing;
|
bool mInitializing;
|
||||||
time_t mUTC;
|
time_t mUTC = 0;
|
||||||
|
time_t mStartTime = 0;
|
||||||
|
|
||||||
CircularQueue<TXPacket*> mTXQueue;
|
CircularQueue<TXPacket*> mTXQueue;
|
||||||
};
|
};
|
||||||
|
@ -225,6 +225,16 @@ def boot(address):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def enter_dfu(portname):
|
||||||
|
p = serial.Serial(portname, 38400, timeout=2, parity=serial.PARITY_NONE, stopbits=1)
|
||||||
|
if not p.is_open:
|
||||||
|
return False
|
||||||
|
|
||||||
|
p.write('dfu\r\n')
|
||||||
|
time.sleep(1)
|
||||||
|
s = p.readline()
|
||||||
|
p.close()
|
||||||
|
return len(s) == 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) < 4:
|
if len(sys.argv) < 4:
|
||||||
@ -246,8 +256,12 @@ if __name__ == '__main__':
|
|||||||
print "Image file too large"
|
print "Image file too large"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if not enter_dfu(sys.argv[1]):
|
||||||
|
print "Could not enter DFU mode"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
port = serial.Serial(sys.argv[1], BAUD_RATE, timeout=2, parity=serial.PARITY_EVEN, stopbits=1)
|
port = serial.Serial(sys.argv[1], BAUD_RATE, timeout=2, parity=serial.PARITY_EVEN, stopbits=1)
|
||||||
if not port.is_open:
|
if not port.is_open:
|
||||||
print "Failed to open port"
|
print "Failed to open port"
|
||||||
|
@ -39,6 +39,7 @@ RFIC::RFIC(GPIO_TypeDef *sdnPort,
|
|||||||
mCSPort = csPort;
|
mCSPort = csPort;
|
||||||
mDataPort = dataPort;
|
mDataPort = dataPort;
|
||||||
mClockGPIO = clockPort;
|
mClockGPIO = clockPort;
|
||||||
|
mPartNumber = 0;
|
||||||
|
|
||||||
mSDNPin = sdnPin;
|
mSDNPin = sdnPin;
|
||||||
mCSPin = csPin;
|
mCSPin = csPin;
|
||||||
@ -178,6 +179,11 @@ void RFIC::configure()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t RFIC::partNumber()
|
||||||
|
{
|
||||||
|
return mPartNumber;
|
||||||
|
}
|
||||||
|
|
||||||
bool RFIC::isInitialized()
|
bool RFIC::isInitialized()
|
||||||
{
|
{
|
||||||
HAL_GPIO_WritePin(mSDNP, mSDNPin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(mSDNP, mSDNPin, GPIO_PIN_SET);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>
|
along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "RadioManager.hpp"
|
#include "RadioManager.hpp"
|
||||||
@ -34,7 +34,7 @@ RadioManager &RadioManager::instance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
RadioManager::RadioManager()
|
RadioManager::RadioManager()
|
||||||
: mTXQueue(4)
|
: mTXQueue(4)
|
||||||
{
|
{
|
||||||
mTransceiverIC = NULL;
|
mTransceiverIC = NULL;
|
||||||
mReceiverIC = NULL;
|
mReceiverIC = NULL;
|
||||||
@ -107,34 +107,45 @@ void RadioManager::processEvent(const Event &e)
|
|||||||
{
|
{
|
||||||
mUTC = e.clock.utc;
|
mUTC = e.clock.utc;
|
||||||
|
|
||||||
// Evaluate the state of the transceiver IC and our queue ...
|
if ( mStartTime == 0 )
|
||||||
if ( mTransceiverIC->assignedTXPacket() == NULL )
|
|
||||||
{
|
{
|
||||||
if ( !mTXQueue.empty() )
|
mStartTime = mUTC;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !mTXQueue.empty() && mTransceiverIC->assignedTXPacket() == NULL )
|
||||||
|
{
|
||||||
|
// There is no current TX operation pending, so we assign one
|
||||||
|
TXPacket *packet = NULL;
|
||||||
|
mTXQueue.pop(packet);
|
||||||
|
ASSERT(packet);
|
||||||
|
|
||||||
|
VHFChannel txChannel = packet->channel();
|
||||||
|
|
||||||
|
// Do we need to swap channels?
|
||||||
|
if ( txChannel != mTransceiverIC->channel() )
|
||||||
{
|
{
|
||||||
// There is no current TX operation pending, so we assign one
|
//DBG("RadioManager swapping channels for ICs\r\n");
|
||||||
TXPacket *packet = NULL;
|
// The receiver needs to be explicitly told to switch channels
|
||||||
mTXQueue.pop(packet);
|
if ( mReceiverIC )
|
||||||
ASSERT(packet);
|
mReceiverIC->switchToChannel(alternateChannel(txChannel));
|
||||||
|
|
||||||
VHFChannel txChannel = packet->channel();
|
|
||||||
|
|
||||||
// Do we need to swap channels?
|
|
||||||
if ( txChannel != mTransceiverIC->channel() )
|
|
||||||
{
|
|
||||||
//DBG("RadioManager swapping channels for ICs\r\n");
|
|
||||||
// The receiver needs to be explicitly told to switch channels
|
|
||||||
if ( mReceiverIC )
|
|
||||||
mReceiverIC->switchToChannel(alternateChannel(txChannel));
|
|
||||||
}
|
|
||||||
|
|
||||||
//DBG("RadioManager assigned TX packet\r\n");
|
|
||||||
|
|
||||||
// The transceiver will switch channel if the packet channel is different
|
|
||||||
mTransceiverIC->assignTXPacket(packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//DBG("RadioManager assigned TX packet\r\n");
|
||||||
|
|
||||||
|
// The transceiver will switch channel if the packet channel is different
|
||||||
|
mTransceiverIC->assignTXPacket(packet);
|
||||||
}
|
}
|
||||||
|
else if ( mUTC - mStartTime >= 3600 )
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* For some reason, RX performance seems to go downhill after many hours
|
||||||
|
* of continuous operation, so the easiest remedy is to reboot every hour.
|
||||||
|
* The impact of this is pretty small.
|
||||||
|
*/
|
||||||
|
|
||||||
|
bsp_reboot();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VHFChannel RadioManager::alternateChannel(VHFChannel channel)
|
VHFChannel RadioManager::alternateChannel(VHFChannel channel)
|
||||||
|
@ -126,7 +126,7 @@ void bsp_hw_init()
|
|||||||
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||||
HAL_UART_Init(&huart1);
|
HAL_UART_Init(&huart1);
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(USART1_IRQn, 7, 0);
|
HAL_NVIC_SetPriority(USART1_IRQn, 1, 0);
|
||||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||||
__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
|
__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ void bsp_hw_init()
|
|||||||
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||||
HAL_UART_Init(&huart1);
|
HAL_UART_Init(&huart1);
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(USART1_IRQn, 7, 0);
|
HAL_NVIC_SetPriority(USART1_IRQn, 1, 0);
|
||||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||||
__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
|
__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@ void mainLoop()
|
|||||||
EventPool::instance().init();
|
EventPool::instance().init();
|
||||||
EventQueue::instance().init();
|
EventQueue::instance().init();
|
||||||
Configuration::instance().init();
|
Configuration::instance().init();
|
||||||
CommandProcessor::instance().init();
|
|
||||||
DataTerminal::instance().init();
|
DataTerminal::instance().init();
|
||||||
|
CommandProcessor::instance().init();
|
||||||
|
|
||||||
RXPacketProcessor packetProcessor;
|
RXPacketProcessor packetProcessor;
|
||||||
GPS::instance().init();
|
GPS::instance().init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user