get data from Kernel driver

1st version of the json file with the header
This commit is contained in:
2024-06-24 20:34:18 +02:00
parent 454ae2f46e
commit 68a4f6bcbe
14 changed files with 833 additions and 111 deletions

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024 Markus Lehr.
*
*
* SPDX-License-Identifier: Owend property of Markus Lehr
*
*/
#ifndef RTS_INCLUDE_ICHANNELDESC_H_
#define RTS_INCLUDE_ICHANNELDESC_H_
#include <string>
#include <list>
enum VALUEFORMAT {
UINT32 = 0,
INT32,
FLOAT,
DOUBLE,
};
class IChannelDesc
{
virtual u_int32_t GetId() = 0;
virtual const std::string& GetName() = 0;
virtual VALUEFORMAT GetValueFormat() = 0;
/**
* return the length of the data that is neeeded for one value of the channel in UINT32
*
*/
virtual u_int32_t GetValueByteSpace() = 0;
};
#endif /* RTS_INCLUDE_ICHANNELDESC_H_ */

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 Markus Lehr.
*
*
* SPDX-License-Identifier: Owend property of Markus Lehr
*
*/
#ifndef RTS_INCLUDE_ISENSORDESC_H_
#define RTS_INCLUDE_ISENSORDESC_H_
#include <string>
#include <list>
#include <json.hpp>
using json = nlohmann::json;
class ISensorDesc
{
virtual int GetDescription() = 0;
virtual bool Add2Json(json& j) = 0;
};
#endif /* RTS_INCLUDE_ISENSORDESC_H_ */

View File

@@ -1,5 +1,13 @@
/*
*/
* Copyright (c) 2024 Markus Lehr.
*
*
* SPDX-License-Identifier: Owend property of Markus Lehr
*
*/
#ifndef RTS_INCLUDE_RTSCOPROHELPER_H_
#define RTS_INCLUDE_RTSCOPROHELPER_H_
#include <string>
@@ -35,3 +43,5 @@ private:
int Copro_setFwName(const char* nameStr);
};
#endif /* RTS_INCLUDE_RTSCOPROHELPER_H_ */

View File

@@ -1,9 +1,19 @@
/*
*/
* Copyright (c) 2024 Markus Lehr.
*
*
* SPDX-License-Identifier: Owend property of Markus Lehr
*
*/
#ifndef RTS_INCLUDE_RTSMONFRAME_H_
#define RTS_INCLUDE_RTSMONFRAME_H_
#include <string>
#include <list>
#include <ISensorDesc.h>
using json = nlohmann::json;
class RTSMonFrame
{
@@ -14,59 +24,35 @@ private:
int samplerate;
int sampleperiod;
int downtime;
std::string status;
std::list<std::string> items;
std::list<std::shared_ptr<ISensorDesc>> mSenorDesriptions;
std::string path;
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, std::string name, int samplerate, int sampleperiod, int downtime, const std::list<std::shared_ptr<ISensorDesc>>& sensDesc, std::string path);
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;
}
int GetId();
std::string GetName() {
return this->name;
}
void SetName(const std::string& name);
const std::string& GetName();
int GetSampleRate() {
return this->samplerate;
}
void SetSampleRate(int samplerate);
int GetSamplePeriod(){
return this->sampleperiod;
}
int GetSampleRate();
void SetSamplePeriod(int sampleperiod);
int GetSamplePeriod();
int GetDownTime(){
return this->downtime;
}
std::string Gettatus() {
return this->status;
}
void SetDownTime(int downtime);
std::list<std::string>& GetItems() {
return this->items;
}
int GetDownTime();
bool generate(u_int32_t* values);
};
#endif /* RTS_INCLUDE_RTSMONFRAME_H_ */

View File

@@ -1,13 +1,68 @@
/*
*/
* Copyright (c) 2024 Markus Lehr.
*
*
* SPDX-License-Identifier: Owend property of Markus Lehr
*
*/
#ifndef RTS_INCLUDE_RTSMONITORINGTASK_H_
#define RTS_INCLUDE_RTSMONITORINGTASK_H_
#include "RTSCoproHelper.h"
#include "RTSMonFrame.h"
#include <pthread.h>
#include <map>
#include <string>
#include <atomic>
#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 <fcntl.h>
#include <regex.h>
#include <sched.h>
#include <signal.h>
#include <inttypes.h>
#include <termios.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include <error.h>
#include <signal.h>
#include <stdio.h>
#define NB_BUF 1
typedef struct
{
int bufferId, eventfd;
} rpmsg_sdb_ioctl_set_efd;
typedef struct
{
int bufferId;
uint32_t size;
} rpmsg_sdb_ioctl_get_data_size;
struct vRCMDeviceData {
uint32_t packageNo; //current package Number
uint32_t packageCount; //complete package Number
uint32_t dataQuantity; //number of uint32_t in data
uint32_t data[]; //the data
};
class RTSMonitoringTask
{
@@ -15,13 +70,35 @@ private:
/* data */
//lock Element
//std::map<int, RTSMonFrame*> rtsMonFrames;
pthread_t monThread;
/* The file descriptor used to manage our TTY over RPMSG */
int mFdRpmsg[2] = {-1, -1};
RTSCoproHelper coproHelper;
/* The file descriptor used to manage our SDB over RPMSG */
int mFdSdbRpmsg = -1;
std::map<int, RTSMonFrame*> rtsMonFrames;
rpmsg_sdb_ioctl_get_data_size q_get_data_size;
pthread_t monThread;
rpmsg_sdb_ioctl_set_efd q_set_efd;
int mefd[NB_BUF];
void* mmappedData[NB_BUF];
bool mfMappedData = false;
struct pollfd mfds[NB_BUF];
//uint8_t mDdrBuffAwaited = 1;
uint32_t mNbUncompData=0;
uint32_t mNbWrittenInFileData;
uint32_t mNbUncompMB=0;
uint32_t mNbPrevUncompMB=0;
uint32_t mNbTty0Frame=0;
char mByteBuffCpy[512];
struct timeval tval_before, tval_after, tval_result;
std::atomic_bool mRunThread= true;
public:
@@ -30,13 +107,24 @@ public:
//static RTSMonitoringTask& Instance();
bool Init();
bool CreateMonitoring(int id, std::string name, int samplerate, int sampleperiod, int downtime, std::string status);
//bool CreateMonitoring(int id, std::string name, int samplerate, int sampleperiod, int downtime, std::string status);
bool LoadFW();
bool Start();
bool Stop();
int Open(std::string monfilename);
bool Close();
std::string Read();
bool GetRunState();
void SetRunState(bool runThread);
private:
static void* Run(void *obj);
bool Load();
};
#endif /* RTS_INCLUDE_RTSMONITORINGTASK_H_ */

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2024 Markus Lehr.
*
*
* SPDX-License-Identifier: Owend property of Markus Lehr
*
*/
#ifndef RTS_INCLUDE_VIBCHANNELDESC_H_
#define RTS_INCLUDE_VIBCHANNELDESC_H_
#include <string>
#include <list>
#include <IChannelDesc.h>
class VibChannelDesc : IChannelDesc
{
private:
u_int32_t id;
std::string name;
VALUEFORMAT valueFormat;
u_int32_t vByteSpace;
public:
VibChannelDesc(u_int32_t id, const std::string& name, VALUEFORMAT valueFormat, u_int32_t vByteSpace = 1);
u_int32_t GetId() override;
const std::string& GetName() override;
VALUEFORMAT GetValueFormat() override;
/**
* return the length of the data that is neeeded for one value of the channel in UINT32
*
*/
u_int32_t GetValueByteSpace() override;
};
#endif /* RTS_INCLUDE_VIBCHANNELDESC_H_ */

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 Markus Lehr.
*
*
* SPDX-License-Identifier: Owend property of Markus Lehr
*
*/
#ifndef RTS_INCLUDE_VIBSENSORDESC_H_
#define RTS_INCLUDE_VIBSENSORDESC_H_
#include <ISensorDesc.h>
#include <IChannelDesc.h>
#include <string>
#include <list>
#include <json.hpp>
using json = nlohmann::json;
class VibSensorDesc: public ISensorDesc
{
private:
std::list<std::shared_ptr<IChannelDesc>> mDescriptions;
public:
VibSensorDesc();
virtual int GetDescription() override;
virtual bool Add2Json(json& j) override;
};
#endif /* RTS_INCLUDE_VIBSENSORDESC_H_ */