Skip to content
Snippets Groups Projects
Commit 60da2213 authored by Alberto Nidasio's avatar Alberto Nidasio
Browse files

[CLI] Implemented commands logging

parent 6673c8a9
Branches
No related tags found
No related merge requests found
Pipeline #3705 failed
......@@ -31,6 +31,8 @@
#include <iostream>
#include "CLIData.h"
using namespace miosix;
using namespace Boardcore;
......@@ -96,6 +98,8 @@ void CLI::run()
std::string line;
std::getline(std::cin, line);
Logger::getInstance().log(CommandData{line});
commandRate = 1000.0 / (miosix::getTick() - lastCommandTick);
lastCommandTick = miosix::getTick();
......
/* Copyright (c) 2022 Skyward Experimental Rocketry
* Author: Alberto Nidasio
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#include <drivers/timer/TimestampTimer.h>
#include <stdint.h>
#include <cstring>
#include <string>
namespace HRETestStand
{
struct CommandData
{
uint64_t timestamp;
char command[100];
CommandData(std::string command)
: timestamp(Boardcore::TimestampTimer::getTimestamp())
{
memcpy(this->command, command.c_str(),
command.size() < 99 ? command.size() + 1 : 100);
}
static std::string header() { return "timestamp,command\n"; }
void print(std::ostream& os) const
{
os << timestamp << "," << command << "\n";
}
};
} // namespace HRETestStand
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment