mirror of
https://github.com/peterantypas/maiana.git
synced 2025-06-07 02:00:12 -07:00
Introduced 'quiet' CLI mode for programming station data
This commit is contained in:
parent
e5e2830353
commit
1c8719ae8d
@ -36,6 +36,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void processCommand(const char *);
|
void processCommand(const char *);
|
||||||
void jumpToBootloader();
|
void jumpToBootloader();
|
||||||
|
void enterCLIMode();
|
||||||
CommandProcessor();
|
CommandProcessor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ public:
|
|||||||
bool writeStationData(const StationData &data);
|
bool writeStationData(const StationData &data);
|
||||||
bool readStationData(StationData &data);
|
bool readStationData(StationData &data);
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
void reportStationData();
|
||||||
private:
|
private:
|
||||||
Configuration();
|
Configuration();
|
||||||
bool erasePage();
|
bool erasePage();
|
||||||
bool writePage();
|
bool writePage();
|
||||||
void reportStationData();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CONFIGURATION_HPP_ */
|
#endif /* CONFIGURATION_HPP_ */
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Stats.hpp
|
|
||||||
*
|
|
||||||
* Created on: Nov 4, 2020
|
|
||||||
* Author: peter
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INC_STATS_HPP_
|
|
||||||
#define INC_STATS_HPP_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "EventQueue.hpp"
|
|
||||||
|
|
||||||
class Stats : public EventConsumer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Stats &instance();
|
|
||||||
void init();
|
|
||||||
|
|
||||||
void processEvent(const Event &e);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Stats();
|
|
||||||
public:
|
|
||||||
int eventQueuePopFailures = 0;
|
|
||||||
int eventQueuePushFailures = 0;
|
|
||||||
int rxPacketPoolPopFailures = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* INC_STATS_HPP_ */
|
|
@ -101,9 +101,9 @@
|
|||||||
// Extra debugging using halting assertions
|
// Extra debugging using halting assertions
|
||||||
//#define DEV_MODE 1
|
//#define DEV_MODE 1
|
||||||
|
|
||||||
#define DFU_FLAG_ADDRESS 0x20009C00
|
#define BOOTMODE_ADDRESS 0x20009C00
|
||||||
#define DFU_FLAG_MAGIC 0xa191feed
|
#define DFU_FLAG_MAGIC 0xa191feed
|
||||||
|
#define CLI_FLAG_MAGIC 0x209a388d
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@
|
|||||||
*/
|
*/
|
||||||
//#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x30
|
//#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x30
|
||||||
|
|
||||||
#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x2D
|
//#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x2D
|
||||||
//#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x2A
|
#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x2C
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Set properties: RF_GLOBAL_CONFIG_1
|
// Set properties: RF_GLOBAL_CONFIG_1
|
||||||
|
@ -120,6 +120,10 @@ void CommandProcessor::processCommand(const char *buff)
|
|||||||
|
|
||||||
Configuration::instance().writeStationData(station);
|
Configuration::instance().writeStationData(station);
|
||||||
}
|
}
|
||||||
|
else if ( s.find("station?") == 0 )
|
||||||
|
{
|
||||||
|
Configuration::instance().reportStationData();
|
||||||
|
}
|
||||||
else if ( s.find("dfu") == 0 )
|
else if ( s.find("dfu") == 0 )
|
||||||
{
|
{
|
||||||
jumpToBootloader();
|
jumpToBootloader();
|
||||||
@ -137,6 +141,16 @@ void CommandProcessor::processCommand(const char *buff)
|
|||||||
{
|
{
|
||||||
bsp_reboot();
|
bsp_reboot();
|
||||||
}
|
}
|
||||||
|
else if ( s.find("cli") == 0 )
|
||||||
|
{
|
||||||
|
enterCLIMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandProcessor::enterCLIMode()
|
||||||
|
{
|
||||||
|
*(uint32_t*)BOOTMODE_ADDRESS = CLI_FLAG_MAGIC;
|
||||||
|
bsp_reboot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandProcessor::jumpToBootloader()
|
void CommandProcessor::jumpToBootloader()
|
||||||
|
@ -59,7 +59,9 @@ Configuration::Configuration()
|
|||||||
|
|
||||||
void Configuration::init()
|
void Configuration::init()
|
||||||
{
|
{
|
||||||
reportStationData();
|
bool cliBootMode = *(uint32_t*)BOOTMODE_ADDRESS == CLI_FLAG_MAGIC;
|
||||||
|
if ( !cliBootMode )
|
||||||
|
reportStationData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::reportStationData()
|
void Configuration::reportStationData()
|
||||||
@ -89,14 +91,14 @@ void Configuration::reportStationData()
|
|||||||
void Configuration::resetToDefaults()
|
void Configuration::resetToDefaults()
|
||||||
{
|
{
|
||||||
if ( bsp_erase_station_data() )
|
if ( bsp_erase_station_data() )
|
||||||
bsp_reboot();
|
reportStationData();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configuration::writeStationData(const StationData &data)
|
bool Configuration::writeStationData(const StationData &data)
|
||||||
{
|
{
|
||||||
if ( bsp_save_station_data(data) )
|
if ( bsp_save_station_data(data) )
|
||||||
{
|
{
|
||||||
bsp_reboot();
|
reportStationData();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "EventQueue.hpp"
|
#include "EventQueue.hpp"
|
||||||
#include "NoiseFloorDetector.hpp"
|
#include "NoiseFloorDetector.hpp"
|
||||||
#include "bsp.hpp"
|
#include "bsp.hpp"
|
||||||
#include "Stats.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
Receiver::Receiver(GPIO_TypeDef *sdnPort, uint32_t sdnPin, GPIO_TypeDef *csPort, uint32_t csPin,
|
Receiver::Receiver(GPIO_TypeDef *sdnPort, uint32_t sdnPin, GPIO_TypeDef *csPort, uint32_t csPin,
|
||||||
@ -310,21 +309,19 @@ void Receiver::pushPacket()
|
|||||||
p->rxPacket = mRXPacket;
|
p->rxPacket = mRXPacket;
|
||||||
if ( !EventQueue::instance().push(p) )
|
if ( !EventQueue::instance().push(p) )
|
||||||
{
|
{
|
||||||
// Count this
|
// This has never happened
|
||||||
++Stats::instance().eventQueuePushFailures;
|
|
||||||
}
|
}
|
||||||
//bsp_signal_low();
|
//bsp_signal_low();
|
||||||
mRXPacket = EventPool::instance().newRXPacket();
|
mRXPacket = EventPool::instance().newRXPacket();
|
||||||
if ( !mRXPacket )
|
if ( !mRXPacket )
|
||||||
{
|
{
|
||||||
// TODO: Count this
|
// This has never happened
|
||||||
++Stats::instance().rxPacketPoolPopFailures;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: Count this
|
// This has never happened
|
||||||
++Stats::instance().eventQueuePopFailures;
|
|
||||||
/**
|
/**
|
||||||
* We're out of resources so just keep using the existing packet.
|
* We're out of resources so just keep using the existing packet.
|
||||||
* If this happens, the most logical outcome is a watchdog reset
|
* If this happens, the most logical outcome is a watchdog reset
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Stats.cpp
|
|
||||||
*
|
|
||||||
* Created on: Nov 4, 2020
|
|
||||||
* Author: peter
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "Stats.hpp"
|
|
||||||
#include "Utils.hpp"
|
|
||||||
#include "EventQueue.hpp"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
static int count = 0;
|
|
||||||
|
|
||||||
Stats &Stats::instance()
|
|
||||||
{
|
|
||||||
static Stats __instance;
|
|
||||||
return __instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
Stats::Stats()
|
|
||||||
{
|
|
||||||
EventQueue::instance().addObserver(this, CLOCK_EVENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stats::init()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stats::processEvent(const Event &e)
|
|
||||||
{
|
|
||||||
++count;
|
|
||||||
if ( count % 60 == 0 )
|
|
||||||
{
|
|
||||||
char buff[32];
|
|
||||||
sprintf(buff, "$PAISTC,%d,%d,%d*", eventQueuePopFailures, eventQueuePushFailures, rxPacketPoolPopFailures);
|
|
||||||
Utils::completeNMEA(buff);
|
|
||||||
|
|
||||||
printf_serial(buff);
|
|
||||||
count = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -543,7 +543,7 @@ void bsp_enter_dfu()
|
|||||||
HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
|
|
||||||
// This flag simply tells main() to jump to the ROM bootloader immediately upon reset, before initializing anything
|
// This flag simply tells main() to jump to the ROM bootloader immediately upon reset, before initializing anything
|
||||||
*(uint32_t*)DFU_FLAG_ADDRESS = DFU_FLAG_MAGIC;
|
*(uint32_t*)BOOTMODE_ADDRESS = DFU_FLAG_MAGIC;
|
||||||
|
|
||||||
bsp_reboot();
|
bsp_reboot();
|
||||||
}
|
}
|
||||||
|
@ -543,7 +543,7 @@ void bsp_enter_dfu()
|
|||||||
HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
|
|
||||||
// This flag simply tells main() to jump to the ROM bootloader immediately upon reset, before initializing anything
|
// This flag simply tells main() to jump to the ROM bootloader immediately upon reset, before initializing anything
|
||||||
*(uint32_t*)DFU_FLAG_ADDRESS = DFU_FLAG_MAGIC;
|
*(uint32_t*)BOOTMODE_ADDRESS = DFU_FLAG_MAGIC;
|
||||||
|
|
||||||
bsp_reboot();
|
bsp_reboot();
|
||||||
}
|
}
|
||||||
|
@ -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 "stm32l4xx_hal.h"
|
#include "stm32l4xx_hal.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -28,7 +28,6 @@
|
|||||||
#include "CommandProcessor.hpp"
|
#include "CommandProcessor.hpp"
|
||||||
#include "bsp.hpp"
|
#include "bsp.hpp"
|
||||||
#include "printf_serial.h"
|
#include "printf_serial.h"
|
||||||
#include "Stats.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef RTOS
|
#ifdef RTOS
|
||||||
@ -57,28 +56,32 @@ void jump_to_bootloader()
|
|||||||
|
|
||||||
void mainTask(void *params)
|
void mainTask(void *params)
|
||||||
{
|
{
|
||||||
|
bool cliBootMode = *(uint32_t*)BOOTMODE_ADDRESS == CLI_FLAG_MAGIC;
|
||||||
|
|
||||||
EventPool::instance().init();
|
EventPool::instance().init();
|
||||||
EventQueue::instance().init();
|
EventQueue::instance().init();
|
||||||
Configuration::instance().init();
|
Configuration::instance().init();
|
||||||
CommandProcessor::instance().init();
|
CommandProcessor::instance().init();
|
||||||
DataTerminal::instance().init();
|
DataTerminal::instance().init();
|
||||||
Stats::instance().init();
|
|
||||||
|
|
||||||
RXPacketProcessor packetProcessor;
|
RXPacketProcessor packetProcessor;
|
||||||
|
|
||||||
#if not defined CALIBRATION_MODE && not defined TX_TEST_MODE
|
|
||||||
GPS::instance().init();
|
GPS::instance().init();
|
||||||
GPS::instance().enable();
|
if ( !cliBootMode )
|
||||||
#endif
|
{
|
||||||
|
GPS::instance().enable();
|
||||||
|
|
||||||
|
TXPacketPool::instance().init();
|
||||||
|
TXScheduler::instance().init();
|
||||||
|
|
||||||
#ifdef ENABLE_TX
|
RadioManager::instance().init();
|
||||||
TXPacketPool::instance().init();
|
RadioManager::instance().start();
|
||||||
TXScheduler::instance().init();
|
}
|
||||||
#endif
|
else
|
||||||
|
{
|
||||||
|
DataTerminal::instance().write("\r\n\r\nCLI mode. Send the 'reboot' command or cycle power to exit.\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
RadioManager::instance().init();
|
*(uint32_t*)BOOTMODE_ADDRESS = 0;
|
||||||
RadioManager::instance().start();
|
|
||||||
|
|
||||||
bsp_start_wdt();
|
bsp_start_wdt();
|
||||||
while (1)
|
while (1)
|
||||||
@ -97,9 +100,9 @@ void mainTask(void *params)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
if ( *(uint32_t*)DFU_FLAG_ADDRESS == DFU_FLAG_MAGIC )
|
if ( *(uint32_t*)BOOTMODE_ADDRESS == DFU_FLAG_MAGIC )
|
||||||
{
|
{
|
||||||
*(uint32_t*)DFU_FLAG_ADDRESS = 0;
|
*(uint32_t*)BOOTMODE_ADDRESS = 0;
|
||||||
jump_to_bootloader();
|
jump_to_bootloader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user