added vrpmdv-rtservice, vrpmdv-mon-datafile,
vrpmdv-monitoring-controler, vrpmdv-mon-tty
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
#set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
#SET(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
#SET(CMAKE_CROSSCOMPILING 1)
|
||||
|
||||
project(RTService)
|
||||
|
||||
# set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
# set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||
# set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
||||
# set(CMAKE_C_COMPILER_WORKS 1)
|
||||
|
||||
|
||||
# set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# SET(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
# SET(CMAKE_CROSSCOMPILING 1)
|
||||
|
||||
|
||||
# set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
# set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
|
||||
|
||||
set(GCC_COMPILE_FLAGS "-Wall -Wextra -Werror -Wsuggest-override -Wno-register -Wno-missing-braces -Wno-unknown-pragmas -fdiagnostics-show-option")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COMPILE_FLAGS}")
|
||||
|
||||
# Find python and Boost - both are required dependencies
|
||||
find_package(Boost)
|
||||
|
||||
set(source_files
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/RTService.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/monitoringTask/RTSMonitoringTask.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/utilities/RTSCoproHelper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/RTSMonFrame.h
|
||||
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${source_files})
|
||||
|
||||
|
||||
#file( GLOB LIB_SOURCES .src/*.cpp )
|
||||
#file( GLOB LIB_HEADERS lib/*.h )
|
||||
|
||||
# target_link_libraries(RTService
|
||||
# PRIVATE
|
||||
# Boost
|
||||
#)cd
|
||||
#target_include_directories(${PROJECT_NAME} PRIVATE ${RTSERVICEINCLUDE})
|
||||
|
||||
install(TARGETS RTService DESTINATION bin)
|
||||
4
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/_build/.gitignore
vendored
Normal file
4
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/_build/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/CMakeCache.txt
|
||||
/Makefile
|
||||
/RTService
|
||||
/cmake_install.cmake
|
||||
7
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/_build/CMakeFiles/.gitignore
vendored
Normal file
7
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/_build/CMakeFiles/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/CMakeDirectoryInformation.cmake
|
||||
/CMakeOutput.log
|
||||
/Makefile.cmake
|
||||
/Makefile2
|
||||
/TargetDirectories.txt
|
||||
/cmake.check_cache
|
||||
/progress.marks
|
||||
5
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/_build/CMakeFiles/3.25.2/.gitignore
vendored
Normal file
5
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/_build/CMakeFiles/3.25.2/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/CMakeCCompiler.cmake
|
||||
/CMakeCXXCompiler.cmake
|
||||
/CMakeDetermineCompilerABI_C.bin
|
||||
/CMakeDetermineCompilerABI_CXX.bin
|
||||
/CMakeSystem.cmake
|
||||
@@ -0,0 +1,2 @@
|
||||
/CMakeCCompilerId.c
|
||||
/a.out
|
||||
@@ -0,0 +1,2 @@
|
||||
/CMakeCXXCompilerId.cpp
|
||||
/a.out
|
||||
10
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/_build/CMakeFiles/RTService.dir/.gitignore
vendored
Normal file
10
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/_build/CMakeFiles/RTService.dir/.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/DependInfo.cmake
|
||||
/build.make
|
||||
/cmake_clean.cmake
|
||||
/compiler_depend.internal
|
||||
/compiler_depend.make
|
||||
/compiler_depend.ts
|
||||
/depend.make
|
||||
/flags.make
|
||||
/link.txt
|
||||
/progress.make
|
||||
@@ -0,0 +1,2 @@
|
||||
/RTService.cpp.o
|
||||
/RTService.cpp.o.d
|
||||
@@ -0,0 +1,2 @@
|
||||
/RTSMonitoringTask.cpp.o
|
||||
/RTSMonitoringTask.cpp.o.d
|
||||
@@ -0,0 +1,2 @@
|
||||
/RTSCoproHelper.cpp.o
|
||||
/RTSCoproHelper.cpp.o.d
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
class RTSCoproHelper
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
//lock Element
|
||||
int mFdRpmsg[2] = {-1, -1};
|
||||
|
||||
public:
|
||||
|
||||
RTSCoproHelper(/* args */);
|
||||
~RTSCoproHelper();
|
||||
|
||||
int Init(std::string fwPath, std::string fwName);
|
||||
|
||||
int Copro_isFwRunning(void);
|
||||
|
||||
int Copro_openTtyRpmsg(int ttyNb, int modeRaw);
|
||||
int Copro_closeTtyRpmsg(int ttyNb);
|
||||
int Copro_writeTtyRpmsg(int ttyNb, int len, char* pData);
|
||||
int Copro_readTtyRpmsg(int ttyNb, int len, char* pData);
|
||||
int Copro_stopFw(void);
|
||||
int Copro_startFw(void);
|
||||
|
||||
private:
|
||||
|
||||
int Copro_getFwPath(char* pathStr);
|
||||
int Copro_setFwPath(const char* pathStr);
|
||||
int Copro_getFwName(char* pathStr);
|
||||
int Copro_setFwName(const char* nameStr);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
|
||||
class RTSMonFrame
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
int id;
|
||||
std::string name;
|
||||
int samplerate;
|
||||
int sampleperiod;
|
||||
int downtime;
|
||||
std::string status;
|
||||
std::list<std::string> items;
|
||||
|
||||
public:
|
||||
|
||||
RTSMonFrame(int id, std::string name, int samplerate, int sampleperiod, int downtime, std::string status) {
|
||||
this->id = id;
|
||||
this->name = name;
|
||||
this->samplerate = samplerate;
|
||||
this->sampleperiod = sampleperiod;
|
||||
this->downtime = downtime;
|
||||
this->status = status;
|
||||
}
|
||||
|
||||
RTSMonFrame(int id) {
|
||||
this->id = id;
|
||||
}
|
||||
|
||||
RTSMonFrame(RTSMonFrame& rtsMonFrameCopy) {
|
||||
this->id = rtsMonFrameCopy.GetId();
|
||||
}
|
||||
|
||||
~RTSMonFrame();
|
||||
|
||||
void Add(std::string item){
|
||||
this->items.push_back(item);
|
||||
}
|
||||
int GetId() {
|
||||
return this->id;
|
||||
}
|
||||
|
||||
std::string GetName() {
|
||||
return this->name;
|
||||
}
|
||||
|
||||
int GetSampleRate() {
|
||||
return this->samplerate;
|
||||
}
|
||||
|
||||
int GetSamplePeriod(){
|
||||
return this->sampleperiod;
|
||||
}
|
||||
|
||||
int GetDownTime(){
|
||||
return this->downtime;
|
||||
}
|
||||
|
||||
std::string Gettatus() {
|
||||
return this->status;
|
||||
}
|
||||
|
||||
std::list<std::string>& GetItems() {
|
||||
return this->items;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
*/
|
||||
#include "RTSCoproHelper.h"
|
||||
#include "RTSMonFrame.h"
|
||||
#include <pthread.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
|
||||
class RTSMonitoringTask
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
//lock Element
|
||||
|
||||
/* The file descriptor used to manage our TTY over RPMSG */
|
||||
int mFdRpmsg[2] = {-1, -1};
|
||||
RTSCoproHelper coproHelper;
|
||||
|
||||
std::map<int, RTSMonFrame*> rtsMonFrames;
|
||||
|
||||
pthread_t monThread;
|
||||
|
||||
public:
|
||||
|
||||
RTSMonitoringTask(/* args */);
|
||||
~RTSMonitoringTask();
|
||||
|
||||
//static RTSMonitoringTask& Instance();
|
||||
bool Init();
|
||||
bool CreateMonitoring(int id, std::string name, int samplerate, int sampleperiod, int downtime, std::string status);
|
||||
bool LoadFW();
|
||||
bool Start();
|
||||
bool Stop();
|
||||
|
||||
private:
|
||||
static void* Run(void *obj);
|
||||
bool Load();
|
||||
|
||||
};
|
||||
24766
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/include/json.hpp
Normal file
24766
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/include/json.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,176 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.3
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||
|
||||
#include <cstdint> // int64_t, uint64_t
|
||||
#include <map> // map
|
||||
#include <memory> // allocator
|
||||
#include <string> // string
|
||||
#include <vector> // vector
|
||||
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.3
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// This file contains all macro definitions affecting or depending on the ABI
|
||||
|
||||
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
|
||||
#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
|
||||
#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3
|
||||
#warning "Already included a different version of the library!"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
|
||||
#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum)
|
||||
#define NLOHMANN_JSON_VERSION_PATCH 3 // NOLINT(modernize-macro-to-enum)
|
||||
|
||||
#ifndef JSON_DIAGNOSTICS
|
||||
#define JSON_DIAGNOSTICS 0
|
||||
#endif
|
||||
|
||||
#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
|
||||
#endif
|
||||
|
||||
#if JSON_DIAGNOSTICS
|
||||
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
|
||||
#else
|
||||
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
|
||||
#endif
|
||||
|
||||
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
|
||||
#else
|
||||
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||
#endif
|
||||
|
||||
#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
|
||||
#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
|
||||
#endif
|
||||
|
||||
// Construct the namespace ABI tags component
|
||||
#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
|
||||
#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
|
||||
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
|
||||
|
||||
#define NLOHMANN_JSON_ABI_TAGS \
|
||||
NLOHMANN_JSON_ABI_TAGS_CONCAT( \
|
||||
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
|
||||
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
|
||||
|
||||
// Construct the namespace version component
|
||||
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
|
||||
_v ## major ## _ ## minor ## _ ## patch
|
||||
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
|
||||
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
|
||||
|
||||
#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
|
||||
#define NLOHMANN_JSON_NAMESPACE_VERSION
|
||||
#else
|
||||
#define NLOHMANN_JSON_NAMESPACE_VERSION \
|
||||
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
|
||||
NLOHMANN_JSON_VERSION_MINOR, \
|
||||
NLOHMANN_JSON_VERSION_PATCH)
|
||||
#endif
|
||||
|
||||
// Combine namespace components
|
||||
#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
|
||||
#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
|
||||
NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
|
||||
|
||||
#ifndef NLOHMANN_JSON_NAMESPACE
|
||||
#define NLOHMANN_JSON_NAMESPACE \
|
||||
nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
|
||||
NLOHMANN_JSON_ABI_TAGS, \
|
||||
NLOHMANN_JSON_NAMESPACE_VERSION)
|
||||
#endif
|
||||
|
||||
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
|
||||
namespace nlohmann \
|
||||
{ \
|
||||
inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
|
||||
NLOHMANN_JSON_ABI_TAGS, \
|
||||
NLOHMANN_JSON_NAMESPACE_VERSION) \
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifndef NLOHMANN_JSON_NAMESPACE_END
|
||||
#define NLOHMANN_JSON_NAMESPACE_END \
|
||||
} /* namespace (inline namespace) NOLINT(readability/namespace) */ \
|
||||
} // namespace nlohmann
|
||||
#endif
|
||||
|
||||
|
||||
/*!
|
||||
@brief namespace for Niels Lohmann
|
||||
@see https://github.com/nlohmann
|
||||
@since version 1.0.0
|
||||
*/
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
|
||||
/*!
|
||||
@brief default JSONSerializer template argument
|
||||
|
||||
This serializer ignores the template arguments and uses ADL
|
||||
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
|
||||
for serialization.
|
||||
*/
|
||||
template<typename T = void, typename SFINAE = void>
|
||||
struct adl_serializer;
|
||||
|
||||
/// a class to store JSON values
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/
|
||||
template<template<typename U, typename V, typename... Args> class ObjectType =
|
||||
std::map,
|
||||
template<typename U, typename... Args> class ArrayType = std::vector,
|
||||
class StringType = std::string, class BooleanType = bool,
|
||||
class NumberIntegerType = std::int64_t,
|
||||
class NumberUnsignedType = std::uint64_t,
|
||||
class NumberFloatType = double,
|
||||
template<typename U> class AllocatorType = std::allocator,
|
||||
template<typename T, typename SFINAE = void> class JSONSerializer =
|
||||
adl_serializer,
|
||||
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
|
||||
class CustomBaseClass = void>
|
||||
class basic_json;
|
||||
|
||||
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
|
||||
/// @sa https://json.nlohmann.me/api/json_pointer/
|
||||
template<typename RefStringType>
|
||||
class json_pointer;
|
||||
|
||||
/*!
|
||||
@brief default specialization
|
||||
@sa https://json.nlohmann.me/api/json/
|
||||
*/
|
||||
using json = basic_json<>;
|
||||
|
||||
/// @brief a minimal map-like container that preserves insertion order
|
||||
/// @sa https://json.nlohmann.me/api/ordered_map/
|
||||
template<class Key, class T, class IgnoredLess, class Allocator>
|
||||
struct ordered_map;
|
||||
|
||||
/// @brief specialization that maintains the insertion order of object keys
|
||||
/// @sa https://json.nlohmann.me/api/ordered_json/
|
||||
using ordered_json = basic_json<nlohmann::ordered_map>;
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "../include/RTSMonitoringTask.h"
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
|
||||
|
||||
int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) {
|
||||
|
||||
RTSMonitoringTask rtMon;
|
||||
|
||||
if (rtMon.Init()) {
|
||||
// idle
|
||||
while(1)
|
||||
{
|
||||
rtMon.CreateMonitoring(1, "Test1", 3750, 2, 10, "stopped");
|
||||
// sleep 100 ms
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "../../include/RTSMonitoringTask.h"
|
||||
//#include "../../include/json.hpp"//((
|
||||
//#include "../../include/json_fwd.hpp"
|
||||
#include <string>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
|
||||
|
||||
|
||||
|
||||
RTSMonitoringTask::RTSMonitoringTask(/* args */)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RTSMonitoringTask::~RTSMonitoringTask()
|
||||
{
|
||||
}
|
||||
|
||||
bool RTSMonitoringTask::Load() {
|
||||
//later load the file
|
||||
int id = 1;
|
||||
RTSMonFrame* rtsMonFrame = new RTSMonFrame(id, "Monitoring1", 3750, 1, 4, "started");
|
||||
rtsMonFrames[id]= rtsMonFrame;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTSMonitoringTask::Init() {
|
||||
|
||||
//load the Monitorings
|
||||
if (this->Load()) {
|
||||
printf("CA7 : Monitorings loaded\n");
|
||||
}
|
||||
const std::string fwPath = "home/root/elffile";
|
||||
const std::string fwName = "zephyr_openamp_rsc_table.elf";
|
||||
|
||||
//check if the FWIsRunning
|
||||
if (coproHelper.Init(fwPath, fwName) >= 0) {
|
||||
printf("CA7 : Init success \n");
|
||||
|
||||
// if (pthread_create( &monThread, NULL, &RTSMonitoringTask::Run, this) == 0) {
|
||||
// printf("CA7 : virtual_tty_thread creation fails\n");
|
||||
// return true;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
printf("CA7 : starting of Zephyr.elf fails\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool RTSMonitoringTask::CreateMonitoring(int id, std::string name, int samplerate, int sampleperiod, int downtime, std::string status){
|
||||
this->rtsMonFrames[id] = new RTSMonFrame(id, name, samplerate, sampleperiod, downtime, status);
|
||||
char * ch = new char[name.length() + 1];
|
||||
|
||||
// Copying the value of the string into the character array.
|
||||
strcpy(ch, name.c_str());
|
||||
|
||||
this->coproHelper.Copro_writeTtyRpmsg(0,name.length()+1, ch);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void* RTSMonitoringTask::Run(void *obj) {
|
||||
|
||||
RTSMonitoringTask* rtsMonTask = static_cast<RTSMonitoringTask*>(obj);
|
||||
std::string newItem;
|
||||
while (1) {
|
||||
// genrate data
|
||||
int i = 1;
|
||||
newItem = "New Item"; //new std::string("New Item: ").concat(new std::string(i));
|
||||
i++;
|
||||
std::map<int, RTSMonFrame*> rtsMonFrame = rtsMonTask->rtsMonFrames;
|
||||
if (rtsMonFrame.size() > 0) {
|
||||
RTSMonFrame* prtsMonFrame = rtsMonFrame.begin()->second;
|
||||
|
||||
prtsMonFrame->Add(newItem);
|
||||
if (i == 200) {
|
||||
//make a dictonary for the rtsMonFrame id, samplerate, sampleperiod, downtime
|
||||
// boost::python::dict rtsMonFrameDict;
|
||||
// rtsMonFrameDict["id"] = prtsMonFrame->GetId();
|
||||
// rtsMonFrameDict["samplerate"] = prtsMonFrame->GetSampleRate();
|
||||
// rtsMonFrameDict["sampleperiod"] = prtsMonFrame->GetSamplePeriod();
|
||||
// rtsMonFrameDict["downtime"] = prtsMonFrame->GetDownTime();
|
||||
// //make a dictonary for the sampleItems
|
||||
// boost::python::list rtsMonItemsList;
|
||||
// auto items = prtsMonFrame->GetItems();
|
||||
// for (auto iter = items.begin(); iter!= items.end(); ++iter)
|
||||
// {
|
||||
// rtsMonItemsList.append(*iter);
|
||||
// }
|
||||
// rtsMonFrameDict["items"]= rtsMonItemsList;
|
||||
// rtsMonTask->callback();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "../../include/RTSCoproHelper.h"
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h> // for usleep
|
||||
#include <math.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <sys/poll.h>
|
||||
#include <regex.h>
|
||||
#include <sched.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <error.h>
|
||||
|
||||
|
||||
|
||||
#define MAX_BUF 80
|
||||
|
||||
#define TTY_CTRL_OPTS (CS8 | CLOCAL | CREAD)
|
||||
#define TTY_INPUT_OPTS IGNPAR
|
||||
#define TTY_OUTPUT_OPTS 0
|
||||
#define TTY_LOCAL_OPTS 0
|
||||
|
||||
#define CMDCHANNEL 0
|
||||
#define DATACHANNEL 1
|
||||
|
||||
RTSCoproHelper::RTSCoproHelper(/* args */)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RTSCoproHelper::~RTSCoproHelper()
|
||||
{
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Init(std::string fwPath, std::string fwName) {
|
||||
int res = -1;
|
||||
|
||||
if (this->Copro_isFwRunning() != 0){
|
||||
//copro is already Runnibng nothing TODO
|
||||
//res = this->Copro_openTtyRpmsg(CMDCHANNEL, 0);
|
||||
this->Copro_stopFw();
|
||||
//return res;
|
||||
//return 0;
|
||||
}
|
||||
|
||||
//load Firmware
|
||||
//set firmware path
|
||||
res = this->Copro_setFwPath(fwPath.c_str());
|
||||
if (res >= 0) {
|
||||
printf("CA7 : Success setting the fwpath, res=%d\n", res);
|
||||
res = this->Copro_setFwName(fwName.c_str());
|
||||
if (res >= 0) {
|
||||
printf("CA7 : Success setting the fwname, res=%d\n", res);
|
||||
res = this->Copro_startFw();
|
||||
if (res >= 0) {
|
||||
printf("CA7 : Success starting Copro, err=%d\n", res);
|
||||
res = this->Copro_openTtyRpmsg(CMDCHANNEL, 1);
|
||||
if (res >= 0 ){
|
||||
printf("CA7 : Success opening Cmdchannel, err=%d\n", res);
|
||||
|
||||
}
|
||||
else {
|
||||
printf("CA7 : Error opening Cmdchannel, err=%d\n", res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("CA7 : Error could not start the firmware, res=-%d\n", res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("CA7 : Error setting the fwName, err=-%d\n", res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("CA7 : Error setting the fwpath, err=-%d\n", res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
Copro functions allowing to manage a virtual TTY over RPMSG
|
||||
*********************************************************************************/
|
||||
int RTSCoproHelper::Copro_isFwRunning(void)
|
||||
{
|
||||
int fd;
|
||||
size_t byte_read;
|
||||
bool result = 0;
|
||||
unsigned char bufRead[MAX_BUF];
|
||||
// char *user = getenv("USER");
|
||||
// if (user && strncmp(user, "root", 4)) {
|
||||
// system("XTERM=xterm su root -c 'cat /sys/class/remoteproc/remoteproc0/state' > /tmp/remoteproc0_state");
|
||||
// fd = open("/tmp/remoteproc0_state", O_RDONLY);
|
||||
// } else {
|
||||
fd = open("/sys/class/remoteproc/remoteproc0/state", O_RDONLY);
|
||||
// }
|
||||
if (fd < 0) {
|
||||
printf("CA7 : Error opening remoteproc0/state, err=-%d\n", errno);
|
||||
return (errno * -1);
|
||||
}
|
||||
byte_read = (size_t) read (fd, bufRead, MAX_BUF);
|
||||
if (byte_read >= strlen("running")) {
|
||||
char* pos = strstr((char*)bufRead, "running");
|
||||
if(pos) {
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_stopFw(void)
|
||||
{
|
||||
int fd;
|
||||
// char *user = getenv("USER");
|
||||
// if (user && strncmp(user, "root",4)) {
|
||||
// system("su root -c 'echo stop > /sys/class/remoteproc/remoteproc0/state'");
|
||||
// return 0;
|
||||
// }
|
||||
fd = open("/sys/class/remoteproc/remoteproc0/state", O_RDWR);
|
||||
if (fd < 0) {
|
||||
printf("CA7 : Error opening remoteproc0/state, err=-%d\n", errno);
|
||||
return (errno * -1);
|
||||
}
|
||||
write(fd, "stop", strlen("stop"));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_startFw(void)
|
||||
{
|
||||
int fd;
|
||||
// char *user = getenv("USER");
|
||||
// if (user && strncmp(user, "root",4)) {
|
||||
// system("su root -c 'echo start > /sys/class/remoteproc/remoteproc0/state'");
|
||||
// return 0;
|
||||
// }
|
||||
fd = open("/sys/class/remoteproc/remoteproc0/state", O_RDWR);
|
||||
if (fd < 0) {
|
||||
printf("CA7 : Error opening remoteproc0/state, err=-%d\n", errno);
|
||||
return (errno * -1);
|
||||
}
|
||||
write(fd, "start", strlen("start"));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_getFwPath(char* pathStr)
|
||||
{
|
||||
int fd;
|
||||
int byte_read;
|
||||
// char *user = getenv("USER");
|
||||
// if (user && strncmp(user, "root",4)) {
|
||||
// system("XTERM=xterm su root -c 'cat /sys/module/firmware_class/parameters/path' > /tmp/parameters_path");
|
||||
// fd = open("/tmp/parameters_path", O_RDONLY);
|
||||
// } else {
|
||||
fd = open("/sys/module/firmware_class/parameters/path", O_RDONLY);
|
||||
// }
|
||||
if (fd < 0) {
|
||||
printf("CA7 : Error opening firmware_class/parameters/path, err=-%d\n", errno);
|
||||
return (errno * -1);
|
||||
}
|
||||
byte_read = read (fd, pathStr, MAX_BUF);
|
||||
close(fd);
|
||||
return byte_read;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_setFwPath(const char* pathStr)
|
||||
{
|
||||
int fd;
|
||||
int result = 0;
|
||||
// char *user = getenv("USER");
|
||||
// if (user && strncmp(user, "root",4)) {
|
||||
// char cmd[1024];
|
||||
// snprintf(cmd, 1024, "echo %s > /sys/module/firmware_class/parameters/path", pathStr);
|
||||
// //snprintf(cmd, 1024, "su root -c 'echo %s > /sys/module/firmware_class/parameters/path'", pathStr);
|
||||
// system(cmd);
|
||||
// return strlen(pathStr);
|
||||
// }
|
||||
fd = open("/sys/module/firmware_class/parameters/path", O_RDWR);
|
||||
if (fd < 0) {
|
||||
printf("CA7 : Error opening firmware_class/parameters/path, err=-%d\n", errno);
|
||||
return (errno * -1);
|
||||
}
|
||||
result = write(fd, pathStr, strlen(pathStr));
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_getFwName(char* pathStr)
|
||||
{
|
||||
int fd;
|
||||
int byte_read;
|
||||
// char *user = getenv("USER");
|
||||
// if (user && strncmp(user, "root",4)) {
|
||||
// system("XTERM=xterm su root -c 'cat /sys/class/remoteproc/remoteproc0/firmware' > /tmp/remoteproc0_firmware");
|
||||
// fd = open("/tmp/remoteproc0_firmware", O_RDONLY);
|
||||
// } else {
|
||||
fd = open("/sys/class/remoteproc/remoteproc0/firmware", O_RDWR);
|
||||
// }
|
||||
if (fd < 0) {
|
||||
printf("CA7 : Error opening remoteproc0/firmware, err=-%d\n", errno);
|
||||
return (errno * -1);
|
||||
}
|
||||
byte_read = read (fd, pathStr, MAX_BUF);
|
||||
close(fd);
|
||||
return byte_read;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_setFwName(const char* nameStr)
|
||||
{
|
||||
int fd;
|
||||
int result = 0;
|
||||
// char *user = getenv("USER");
|
||||
// if (user && strncmp(user, "root",4)) {
|
||||
// char cmd[1024];
|
||||
// snprintf(cmd, 1024, "su root -c 'echo %s > /sys/class/remoteproc/remoteproc0/firmware'", nameStr);
|
||||
// system(cmd);
|
||||
// return strlen(nameStr);
|
||||
// }
|
||||
fd = open("/sys/class/remoteproc/remoteproc0/firmware", O_RDWR);
|
||||
if (fd < 0) {
|
||||
printf("CA7 : Error opening remoteproc0/firmware, err=-%d\n", errno);
|
||||
return (errno * -1);
|
||||
}
|
||||
result = write(fd, nameStr, strlen(nameStr));
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_openTtyRpmsg(int ttyNb, [[maybe_unused]]int modeRaw)
|
||||
{
|
||||
|
||||
//struct termios tiorpmsg;
|
||||
char devName[50];
|
||||
sprintf(devName, "/dev/ttyRPMSG%d", ttyNb%2);
|
||||
mFdRpmsg[ttyNb%2] = open(devName, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
// mFdRpmsg[ttyNb%2] = open("rpmsg-client-sample", O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
if (mFdRpmsg[ttyNb%2] < 0) {
|
||||
printf("CA7 : Error opening ttyRPMSG%d, err=-%d\n", ttyNb%2, errno);
|
||||
return (errno * -1);
|
||||
}
|
||||
printf("CA7 : Success opening ttyRPMSG%d \n", ttyNb%2);
|
||||
// #if 1
|
||||
// /* get current port settings */
|
||||
// tcgetattr(mFdRpmsg[ttyNb%2],&tiorpmsg);
|
||||
// if (modeRaw) {
|
||||
// #if 0
|
||||
// tiorpmsg.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
|
||||
// | INLCR | IGNCR | ICRNL | IXON);
|
||||
// tiorpmsg.c_oflag &= ~OPOST;
|
||||
// tiorpmsg.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
|
||||
// tiorpmsg.c_cflag &= ~(CSIZE | PARENB);
|
||||
// tiorpmsg.c_cflag |= CS8;
|
||||
// #else
|
||||
// memset(&tiorpmsg, 0, sizeof(tiorpmsg));
|
||||
// tiorpmsg.c_cflag = TTY_CTRL_OPTS;
|
||||
// tiorpmsg.c_iflag = TTY_INPUT_OPTS;
|
||||
// tiorpmsg.c_oflag = TTY_OUTPUT_OPTS;
|
||||
// tiorpmsg.c_lflag = TTY_LOCAL_OPTS;
|
||||
// tiorpmsg.c_cc[VTIME] = 0;
|
||||
// tiorpmsg.c_cc[VMIN] = 1;
|
||||
// cfmakeraw(&tiorpmsg);
|
||||
// #endif
|
||||
// } else {
|
||||
// /* ECHO off, other bits unchanged */
|
||||
// tiorpmsg.c_lflag &= ~ECHO;
|
||||
// /*do not convert LF to CR LF */
|
||||
// tiorpmsg.c_oflag &= ~ONLCR;
|
||||
// }
|
||||
// if (tcsetattr(mFdRpmsg[ttyNb%2], TCSANOW, &tiorpmsg) < 0) {
|
||||
// printf("Error %d in copro_openTtyRpmsg(%d) tcsetattr\n", errno, ttyNb);
|
||||
// return (errno * -1);
|
||||
// }
|
||||
// #endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_closeTtyRpmsg(int ttyNb)
|
||||
{
|
||||
close(mFdRpmsg[ttyNb%2]);
|
||||
mFdRpmsg[ttyNb%2] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_writeTtyRpmsg(int ttyNb, int len, char* pData)
|
||||
{
|
||||
int result = 0;
|
||||
if (mFdRpmsg[ttyNb%2] < 0) {
|
||||
printf("CA7 : Error writing ttyRPMSG%d, fileDescriptor is not set\n", ttyNb%2);
|
||||
return mFdRpmsg[ttyNb%2];
|
||||
}
|
||||
|
||||
result = write(mFdRpmsg[ttyNb%2], pData, len);
|
||||
if (result >= 0) {
|
||||
printf("CA7 : Succes writing ttyRPMSG%d, result=%d\n", ttyNb%2, result);
|
||||
}
|
||||
else {
|
||||
printf("CA7 : Error writing ttyRPMSG%d, err=-%d\n", ttyNb%2, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int RTSCoproHelper::Copro_readTtyRpmsg(int ttyNb, int len, char* pData)
|
||||
{
|
||||
int byte_rd, byte_avail;
|
||||
int result = 0;
|
||||
if (mFdRpmsg[ttyNb%2] < 0) {
|
||||
printf("CA7 : Error reading ttyRPMSG%d, fileDescriptor is not set\n", ttyNb%2);
|
||||
return mFdRpmsg[ttyNb%2];
|
||||
}
|
||||
ioctl(mFdRpmsg[ttyNb%2], FIONREAD, &byte_avail);
|
||||
if (byte_avail > 0) {
|
||||
if (byte_avail >= len) {
|
||||
byte_rd = read (mFdRpmsg[ttyNb%2], pData, len);
|
||||
} else {
|
||||
byte_rd = read (mFdRpmsg[ttyNb%2], pData, byte_avail);
|
||||
}
|
||||
//printf("CA7 : read successfully %d bytes to %p, [0]=0x%x\n", byte_rd, pData, pData[0]);
|
||||
result = byte_rd;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/********************************************************************************
|
||||
End of Copro functions
|
||||
*********************************************************************************/
|
||||
BIN
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/zephyr_openamp_rsc_table.elf
Executable file
BIN
recipes-vrpmdv/recipes-base/vrpmdv-rtservice/files/zephyr_openamp_rsc_table.elf
Executable file
Binary file not shown.
@@ -0,0 +1,49 @@
|
||||
SUMMARY = "vrpmdv-rtservice recipe"
|
||||
DESCRIPTION = "Recipe to add vrpmdv-setup-page to it's location."
|
||||
LICENSE = "CLOSED"
|
||||
# LICENSE_FLAGS = "commercial"
|
||||
|
||||
# inherit allarch perlnative
|
||||
inherit cmake
|
||||
|
||||
# DEPENDS += "perl"
|
||||
DEPENDS += "boost"
|
||||
|
||||
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
|
||||
|
||||
|
||||
SRC_URI += " \
|
||||
file://CMakeLists.txt \
|
||||
file://zephyr_openamp_rsc_table.elf \
|
||||
file://src/RTService.cpp \
|
||||
file://src/monitoringTask/RTSMonitoringTask.cpp \
|
||||
file://src/utilities/RTSCoproHelper.cpp \
|
||||
file://include/RTSCoproHelper.h \
|
||||
file://include/RTSMonFrame.h \
|
||||
file://include/RTSMonitoringTask.h \
|
||||
"
|
||||
|
||||
|
||||
S = "${WORKDIR}"
|
||||
|
||||
# ELFDESTINATION = "~/elffile"
|
||||
|
||||
|
||||
# FILES:${PN} += "${DESTINATION}"
|
||||
|
||||
# do_install () {
|
||||
# install -d ${D}${ELFDESTINATION}
|
||||
# install -m 0644 ${WORKDIR}/*.elf ${D}/${ELFDESTINATION}
|
||||
#
|
||||
#}
|
||||
|
||||
# RDEPENDS:${PN} += " perl"
|
||||
# RDEPENDS:${PN} += " boost"
|
||||
|
||||
BBCLASSEXTEND = "native "
|
||||
# BBCLASSEXTEND = "native nativesdk"
|
||||
|
||||
# EXTRA_OECMAKE += "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
||||
# EXTRA_OECMAKE += "-DSYSTEM_PROCESSOR=arm"
|
||||
# EXTRA_OECMAKE += "-DCROSSCOMPILING=1"
|
||||
# EXTRA_OECMAKE = "-DBUILD_TESTING=OFF"
|
||||
Reference in New Issue
Block a user