62 lines
2.1 KiB
C++
62 lines
2.1 KiB
C++
/**
|
|
* @file main.cpp
|
|
* @brief Send drive data to printer service using ipc msg queue
|
|
* @author Hendrik Schutter
|
|
* @date 06.12.2025
|
|
*/
|
|
|
|
#include "main.h"
|
|
|
|
#define REHDD_VERSION "V99.99.99"
|
|
|
|
/**
|
|
* \brief app entry point
|
|
* \param void
|
|
* \return Status-Code
|
|
*/
|
|
int main(void)
|
|
{
|
|
int msqid;
|
|
std::cout << "Dummy sender for IPC queue" << std::endl;
|
|
|
|
if (-1 == (msqid = msgget((key_t)IPC_MSG_QUEUE_KEY, IPC_CREAT | 0666)))
|
|
{
|
|
std::cout << "Printer: Create msg queue failed! Error: " << strerror(errno) << std::endl;
|
|
return EXIT_FAILURE;
|
|
}
|
|
else
|
|
{
|
|
std::cout << "Printer: Created/connected to msg queue (ID: " << msqid << ")" << std::endl;
|
|
}
|
|
|
|
t_msgQueueData msgQueueData;
|
|
msgQueueData.msg_queue_type = 1;
|
|
|
|
sprintf(msgQueueData.driveData.caDriveIndex, "%i", 0);
|
|
sprintf(msgQueueData.driveData.caDriveState, "shredded");
|
|
strcpy(msgQueueData.driveData.caDriveModelFamily, "Toshiba 2.5 HDD MK..65GSSX");
|
|
strcpy(msgQueueData.driveData.caDriveModelName, "TOSHIBA MK3265GSDX");
|
|
sprintf(msgQueueData.driveData.caDriveCapacity, "%li", 343597383000LU);
|
|
strcpy(msgQueueData.driveData.caDriveSerialnumber, "YG6742U56UDRL123456789ABCDEFGJKL");
|
|
sprintf(msgQueueData.driveData.caDriveHours, "%i", 7074);
|
|
sprintf(msgQueueData.driveData.caDriveCycles, "%i", 4792);
|
|
sprintf(msgQueueData.driveData.caDriveErrors, "%i", 1);
|
|
sprintf(msgQueueData.driveData.caDriveShredTimestamp, "%li", 71718LU);
|
|
sprintf(msgQueueData.driveData.caDriveShredDuration, "%li", 81718LU);
|
|
strcpy(msgQueueData.driveData.caDriveConnectionType, "sata");
|
|
sprintf(msgQueueData.driveData.caDriveReHddVersion, REHDD_VERSION);
|
|
|
|
std::cout << "Sending message to queue..." << std::endl;
|
|
if (-1 == msgsnd(msqid, &msgQueueData, sizeof(t_msgQueueData) - sizeof(long), 0))
|
|
{
|
|
std::cout << "Printer: Send msg queue failed! Error: " << strerror(errno) << std::endl;
|
|
return EXIT_FAILURE;
|
|
}
|
|
else
|
|
{
|
|
std::cout << "Printer: print triggered successfully" << std::endl;
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|