mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-01-19 20:47:58 -05:00
Add proper detection
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "Detector.h"
|
||||
#include "LogManager.h"
|
||||
#include "SeagateController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Seagate.h"
|
||||
@@ -31,16 +32,65 @@
|
||||
|
||||
void DetectSeagateControllers()
|
||||
{
|
||||
int fd = open("/dev/sdb", O_RDWR);
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Search for /dev/sgX nodes with model matching "FireCuda HDD" |
|
||||
\*---------------------------------------------------------------------*/
|
||||
unsigned int sg_idx = 0;
|
||||
|
||||
if(fd > 0)
|
||||
while(1)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Create the scsi_generic class model path |
|
||||
\*-------------------------------------------------*/
|
||||
char sg_dev_buf[1024];
|
||||
|
||||
snprintf(sg_dev_buf, 1024, "/sys/class/scsi_generic/sg%d/device/model", sg_idx);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Open the input event path to get the name |
|
||||
\*-------------------------------------------------*/
|
||||
int sg_model_fd = open(sg_dev_buf, O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if(sg_model_fd < 0)
|
||||
{
|
||||
SeagateController* controller = new SeagateController(fd, "/dev/sdb");
|
||||
RGBController_Seagate* rgb_controller = new RGBController_Seagate(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
break;
|
||||
}
|
||||
|
||||
memset(sg_dev_buf, 0, 1024);
|
||||
|
||||
if(read(sg_model_fd, sg_dev_buf, 1024) < 0)
|
||||
{
|
||||
LOG_WARNING("[Seagate Firecuda HDD] Probing %d, failed to read NVMe model", sg_idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[Seagate Firecuda HDD] Probing %d, model: %s", sg_idx, sg_dev_buf);
|
||||
}
|
||||
|
||||
close(sg_model_fd);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Check if this SCSI device is a Seagate Firecuda |
|
||||
| HDD |
|
||||
\*-------------------------------------------------*/
|
||||
if(strncmp(sg_dev_buf, "FireCuda HDD", 12) == 0)
|
||||
{
|
||||
snprintf(sg_dev_buf, 1024, "/dev/sg%d", sg_idx);
|
||||
|
||||
int fd = open(sg_dev_buf, O_RDWR);
|
||||
|
||||
if(fd > 0)
|
||||
{
|
||||
SeagateController* controller = new SeagateController(fd, sg_dev_buf);
|
||||
RGBController_Seagate* rgb_controller = new RGBController_Seagate(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
sg_idx++;
|
||||
}
|
||||
|
||||
} /* DetectSpectrixS40GControllers() */
|
||||
|
||||
REGISTER_DETECTOR( "Seagate Firecuda HDD", DetectSeagateControllers);
|
||||
|
||||
Reference in New Issue
Block a user