mirror of
https://github.com/peterantypas/maiana.git
synced 2025-05-27 21:00:24 -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:
|
||||
void processCommand(const char *);
|
||||
void jumpToBootloader();
|
||||
void enterCLIMode();
|
||||
CommandProcessor();
|
||||
};
|
||||
|
||||
|
@ -43,11 +43,11 @@ public:
|
||||
bool writeStationData(const StationData &data);
|
||||
bool readStationData(StationData &data);
|
||||
void resetToDefaults();
|
||||
void reportStationData();
|
||||
private:
|
||||
Configuration();
|
||||
bool erasePage();
|
||||
bool writePage();
|
||||
void reportStationData();
|
||||
};
|
||||
|
||||
#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
|
||||
//#define DEV_MODE 1
|
||||
|
||||
#define DFU_FLAG_ADDRESS 0x20009C00
|
||||
#define BOOTMODE_ADDRESS 0x20009C00
|
||||
#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, 0x2D
|
||||
//#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x2A
|
||||
//#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x2D
|
||||
#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x2C
|
||||
|
||||
/*
|
||||
// Set properties: RF_GLOBAL_CONFIG_1
|
||||
|
@ -120,6 +120,10 @@ void CommandProcessor::processCommand(const char *buff)
|
||||
|
||||
Configuration::instance().writeStationData(station);
|
||||
}
|
||||
else if ( s.find("station?") == 0 )
|
||||
{
|
||||
Configuration::instance().reportStationData();
|
||||
}
|
||||
else if ( s.find("dfu") == 0 )
|
||||
{
|
||||
jumpToBootloader();
|
||||
@ -137,6 +141,16 @@ void CommandProcessor::processCommand(const char *buff)
|
||||
{
|
||||
bsp_reboot();
|
||||
}
|
||||
else if ( s.find("cli") == 0 )
|
||||
{
|
||||
enterCLIMode();
|
||||
}
|
||||
}
|
||||
|
||||
void CommandProcessor::enterCLIMode()
|
||||
{
|
||||
*(uint32_t*)BOOTMODE_ADDRESS = CLI_FLAG_MAGIC;
|
||||
bsp_reboot();
|
||||
}
|
||||
|
||||
void CommandProcessor::jumpToBootloader()
|
||||
|
@ -59,7 +59,9 @@ Configuration::Configuration()
|
||||
|
||||
void Configuration::init()
|
||||
{
|
||||
reportStationData();
|
||||
bool cliBootMode = *(uint32_t*)BOOTMODE_ADDRESS == CLI_FLAG_MAGIC;
|
||||
if ( !cliBootMode )
|
||||
reportStationData();
|
||||
}
|
||||
|
||||
void Configuration::reportStationData()
|
||||
@ -89,14 +91,14 @@ void Configuration::reportStationData()
|
||||
void Configuration::resetToDefaults()
|
||||
{
|
||||
if ( bsp_erase_station_data() )
|
||||
bsp_reboot();
|
||||
reportStationData();
|
||||
}
|
||||
|
||||
bool Configuration::writeStationData(const StationData &data)
|
||||
{
|
||||
if ( bsp_save_station_data(data) )
|
||||
{
|
||||
bsp_reboot();
|
||||
reportStationData();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "EventQueue.hpp"
|
||||
#include "NoiseFloorDetector.hpp"
|
||||
#include "bsp.hpp"
|
||||
#include "Stats.hpp"
|
||||
|
||||
|
||||
Receiver::Receiver(GPIO_TypeDef *sdnPort, uint32_t sdnPin, GPIO_TypeDef *csPort, uint32_t csPin,
|
||||
@ -310,21 +309,19 @@ void Receiver::pushPacket()
|
||||
p->rxPacket = mRXPacket;
|
||||
if ( !EventQueue::instance().push(p) )
|
||||
{
|
||||
// Count this
|
||||
++Stats::instance().eventQueuePushFailures;
|
||||
// This has never happened
|
||||
}
|
||||
//bsp_signal_low();
|
||||
mRXPacket = EventPool::instance().newRXPacket();
|
||||
if ( !mRXPacket )
|
||||
{
|
||||
// TODO: Count this
|
||||
++Stats::instance().rxPacketPoolPopFailures;
|
||||
// This has never happened
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Count this
|
||||
++Stats::instance().eventQueuePopFailures;
|
||||
// This has never happened
|
||||
|
||||
/**
|
||||
* We're out of resources so just keep using the existing packet.
|
||||
* 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);
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ void bsp_enter_dfu()
|
||||
HAL_Delay(1000);
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
@ -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 "stm32l4xx_hal.h"
|
||||
#include "config.h"
|
||||
@ -28,7 +28,6 @@
|
||||
#include "CommandProcessor.hpp"
|
||||
#include "bsp.hpp"
|
||||
#include "printf_serial.h"
|
||||
#include "Stats.hpp"
|
||||
|
||||
|
||||
#ifdef RTOS
|
||||
@ -57,28 +56,32 @@ void jump_to_bootloader()
|
||||
|
||||
void mainTask(void *params)
|
||||
{
|
||||
bool cliBootMode = *(uint32_t*)BOOTMODE_ADDRESS == CLI_FLAG_MAGIC;
|
||||
|
||||
EventPool::instance().init();
|
||||
EventQueue::instance().init();
|
||||
Configuration::instance().init();
|
||||
CommandProcessor::instance().init();
|
||||
DataTerminal::instance().init();
|
||||
Stats::instance().init();
|
||||
|
||||
RXPacketProcessor packetProcessor;
|
||||
|
||||
#if not defined CALIBRATION_MODE && not defined TX_TEST_MODE
|
||||
GPS::instance().init();
|
||||
GPS::instance().enable();
|
||||
#endif
|
||||
if ( !cliBootMode )
|
||||
{
|
||||
GPS::instance().enable();
|
||||
|
||||
TXPacketPool::instance().init();
|
||||
TXScheduler::instance().init();
|
||||
|
||||
#ifdef ENABLE_TX
|
||||
TXPacketPool::instance().init();
|
||||
TXScheduler::instance().init();
|
||||
#endif
|
||||
RadioManager::instance().init();
|
||||
RadioManager::instance().start();
|
||||
}
|
||||
else
|
||||
{
|
||||
DataTerminal::instance().write("\r\n\r\nCLI mode. Send the 'reboot' command or cycle power to exit.\r\n");
|
||||
}
|
||||
|
||||
RadioManager::instance().init();
|
||||
RadioManager::instance().start();
|
||||
*(uint32_t*)BOOTMODE_ADDRESS = 0;
|
||||
|
||||
bsp_start_wdt();
|
||||
while (1)
|
||||
@ -97,9 +100,9 @@ void mainTask(void *params)
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user