1
0
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:
Peter Antypas 2021-02-26 09:10:55 -08:00
parent 4613466268
commit 529f6f05ca
9 changed files with 65 additions and 32 deletions

View File

@ -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.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"/>

View File

@ -47,6 +47,7 @@ public:
virtual ~RFIC();
void setRSSIAdjustment(short rssiAdj);
uint16_t partNumber();
protected:
virtual void configure();
bool sendCmd(uint8_t cmd, void* params, uint8_t paramLen, void* result, uint8_t resultLen);

View File

@ -58,7 +58,8 @@ private:
Transceiver *mTransceiverIC;
Receiver *mReceiverIC;
bool mInitializing;
time_t mUTC;
time_t mUTC = 0;
time_t mStartTime = 0;
CircularQueue<TXPacket*> mTXQueue;
};

View File

@ -225,6 +225,16 @@ def boot(address):
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 len(sys.argv) < 4:
@ -246,8 +256,12 @@ if __name__ == '__main__':
print "Image file too large"
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)
if not port.is_open:
print "Failed to open port"

View File

@ -39,6 +39,7 @@ RFIC::RFIC(GPIO_TypeDef *sdnPort,
mCSPort = csPort;
mDataPort = dataPort;
mClockGPIO = clockPort;
mPartNumber = 0;
mSDNPin = sdnPin;
mCSPin = csPin;
@ -178,6 +179,11 @@ void RFIC::configure()
}
}
uint16_t RFIC::partNumber()
{
return mPartNumber;
}
bool RFIC::isInitialized()
{
HAL_GPIO_WritePin(mSDNP, mSDNPin, GPIO_PIN_SET);

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
*/
*/
#include "RadioManager.hpp"
@ -34,7 +34,7 @@ RadioManager &RadioManager::instance()
}
RadioManager::RadioManager()
: mTXQueue(4)
: mTXQueue(4)
{
mTransceiverIC = NULL;
mReceiverIC = NULL;
@ -107,34 +107,45 @@ void RadioManager::processEvent(const Event &e)
{
mUTC = e.clock.utc;
// Evaluate the state of the transceiver IC and our queue ...
if ( mTransceiverIC->assignedTXPacket() == NULL )
if ( mStartTime == 0 )
{
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
TXPacket *packet = NULL;
mTXQueue.pop(packet);
ASSERT(packet);
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 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);
}
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)

View File

@ -126,7 +126,7 @@ void bsp_hw_init()
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
HAL_UART_Init(&huart1);
HAL_NVIC_SetPriority(USART1_IRQn, 7, 0);
HAL_NVIC_SetPriority(USART1_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);

View File

@ -123,7 +123,7 @@ void bsp_hw_init()
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
HAL_UART_Init(&huart1);
HAL_NVIC_SetPriority(USART1_IRQn, 7, 0);
HAL_NVIC_SetPriority(USART1_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);

View File

@ -56,8 +56,8 @@ void mainLoop()
EventPool::instance().init();
EventQueue::instance().init();
Configuration::instance().init();
CommandProcessor::instance().init();
DataTerminal::instance().init();
CommandProcessor::instance().init();
RXPacketProcessor packetProcessor;
GPS::instance().init();