add IPC send
This commit is contained in:
parent
ce696f676a
commit
b1cc2ac13d
@ -10,22 +10,26 @@
|
|||||||
|
|
||||||
#include "reHDD.h"
|
#include "reHDD.h"
|
||||||
|
|
||||||
|
#include <sys/ipc.h>
|
||||||
|
#include <sys/msg.h>
|
||||||
|
|
||||||
#define STR_BUFFER_SIZE 64U
|
#define STR_BUFFER_SIZE 64U
|
||||||
|
#define IPC_MSG_QUEUE_KEY 0x1B11193C0
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char caDriveIndex[STR_BUFFER_SIZE];
|
char caDriveIndex[STR_BUFFER_SIZE];
|
||||||
char caDriveHours[STR_BUFFER_SIZE];
|
char caDriveHours[STR_BUFFER_SIZE];
|
||||||
char caDriveCycles[STR_BUFFER_SIZE];
|
char caDriveCycles[STR_BUFFER_SIZE];
|
||||||
char caDriveErrors[STR_BUFFER_SIZE];
|
char caDriveErrors[STR_BUFFER_SIZE];
|
||||||
char caDriveShredTimestamp[STR_BUFFER_SIZE];
|
char caDriveShredTimestamp[STR_BUFFER_SIZE];
|
||||||
char caDriveShredDuration[STR_BUFFER_SIZE];
|
char caDriveShredDuration[STR_BUFFER_SIZE];
|
||||||
char caDriveCapacity[STR_BUFFER_SIZE];
|
char caDriveCapacity[STR_BUFFER_SIZE];
|
||||||
char caDriveState[STR_BUFFER_SIZE];
|
char caDriveState[STR_BUFFER_SIZE];
|
||||||
char caDriveModelFamiliy[STR_BUFFER_SIZE];
|
char caDriveModelFamiliy[STR_BUFFER_SIZE];
|
||||||
char caDriveModelName[STR_BUFFER_SIZE];
|
char caDriveModelName[STR_BUFFER_SIZE];
|
||||||
char caDriveSerialnumber[STR_BUFFER_SIZE];
|
char caDriveSerialnumber[STR_BUFFER_SIZE];
|
||||||
char caDriveReHddVersion[STR_BUFFER_SIZE];
|
char caDriveReHddVersion[STR_BUFFER_SIZE];
|
||||||
|
|
||||||
} t_driveData;
|
} t_driveData;
|
||||||
|
|
||||||
@ -47,6 +51,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
static bool instanceFlag;
|
static bool instanceFlag;
|
||||||
static Printer *single;
|
static Printer *single;
|
||||||
|
int msqid;
|
||||||
Printer();
|
Printer();
|
||||||
~Printer();
|
~Printer();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define CHUNK_SIZE 1024*1024*32 //amount of bytes that are overwritten at once --> 32MB
|
#define CHUNK_SIZE 1024*1024*32 //amount of bytes that are overwritten at once --> 32MB
|
||||||
#define TFNG_DATA_SIZE CHUNK_SIZE //amount of bytes used by tfng
|
#define TFNG_DATA_SIZE CHUNK_SIZE //amount of bytes used by tfng
|
||||||
|
|
||||||
//#define DEMO_DRIVE_SIZE 1024*1024*256L // 256MB
|
#define DEMO_DRIVE_SIZE 1024*1024*256L // 256MB
|
||||||
//#define DEMO_DRIVE_SIZE 1024*1024*1024L // 1GB
|
//#define DEMO_DRIVE_SIZE 1024*1024*1024L // 1GB
|
||||||
//#define DEMO_DRIVE_SIZE 5*1024*1024*1024L // 5GB
|
//#define DEMO_DRIVE_SIZE 5*1024*1024*1024L // 5GB
|
||||||
//#define DEMO_DRIVE_SIZE 1024*1024*1024*10L // 10GB
|
//#define DEMO_DRIVE_SIZE 1024*1024*1024*10L // 10GB
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "../include/reHDD.h"
|
#include "../include/reHDD.h"
|
||||||
|
|
||||||
|
|
||||||
bool Printer::instanceFlag = false;
|
bool Printer::instanceFlag = false;
|
||||||
Printer* Printer::single = NULL;
|
Printer* Printer::single = NULL;
|
||||||
|
|
||||||
@ -19,7 +18,10 @@ Printer* Printer::single = NULL;
|
|||||||
*/
|
*/
|
||||||
Printer::Printer()
|
Printer::Printer()
|
||||||
{
|
{
|
||||||
|
if (-1 == (this->msqid = msgget((key_t)IPC_MSG_QUEUE_KEY, IPC_CREAT | 0666)))
|
||||||
|
{
|
||||||
|
Logger::logThis()->error("Printer: Create mgs queue failed!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,8 +37,28 @@ Printer::~Printer()
|
|||||||
* \brief send data to msg queue
|
* \brief send data to msg queue
|
||||||
* \return void
|
* \return void
|
||||||
*/
|
*/
|
||||||
void Printer::print(){
|
void Printer::print()
|
||||||
|
{
|
||||||
|
t_msgQueueData msgQueueData;
|
||||||
|
msgQueueData.msg_queue_type = 1;
|
||||||
|
|
||||||
|
sprintf(msgQueueData.driveData.caDriveIndex, "%i",42);
|
||||||
|
sprintf(msgQueueData.driveData.caDriveState, "shredded");
|
||||||
|
sprintf(msgQueueData.driveData.caDriveModelFamiliy, "Toshiba 2.5\\ HDD MK..65GSSX");
|
||||||
|
sprintf(msgQueueData.driveData.caDriveModelName, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
||||||
|
sprintf(msgQueueData.driveData.caDriveCapacity, "%li",343597383680); //343597383680
|
||||||
|
sprintf(msgQueueData.driveData.caDriveSerialnumber, "YG6742U56UDRL123");
|
||||||
|
sprintf(msgQueueData.driveData.caDriveHours, "%i",7074);
|
||||||
|
sprintf(msgQueueData.driveData.caDriveCycles, "%i",4792);
|
||||||
|
sprintf(msgQueueData.driveData.caDriveErrors, "%i",1);
|
||||||
|
sprintf(msgQueueData.driveData.caDriveShredTimestamp, "%i",1647937421);
|
||||||
|
sprintf(msgQueueData.driveData.caDriveShredDuration, "%i",81718);
|
||||||
|
sprintf(msgQueueData.driveData.caDriveReHddVersion, "bV0.2.2");
|
||||||
|
|
||||||
|
if (-1 == msgsnd(this->msqid, &msgQueueData, sizeof(t_msgQueueData) - sizeof(long), 0))
|
||||||
|
{
|
||||||
|
Logger::logThis()->error("Printer: Send mgs queue failed!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user