mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-09-24 19:35:02 -04:00
ENESMBusController robustness improvements - only register controller if valid device name and LED count were read
This commit is contained in:
1 parent
6838d9d9c0
commit
05983e2db2
3 files changed
+28
-8
No files matched your search
@@ -55,7 +55,7 @@ ENESMBusController::ENESMBusController(ENESMBusInterface* interface, ene_dev_id
|
||||
\*-------------------------------------------------*/
|
||||
if(LogManager::get()->GetLogLevel() >= LL_TRACE)
|
||||
{
|
||||
LOG_TRACE("[ENE SMBus] ENE config table for 0x%02X:", dev);
|
||||
LOG_TRACE("[ENE SMBus] ENE config table for 0x%02X (%s):", dev, device_version);
|
||||
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[0], config_table[1], config_table[2], config_table[3],
|
||||
config_table[4], config_table[5], config_table[6], config_table[7],
|
||||
config_table[8], config_table[9], config_table[10], config_table[11],
|
||||
@@ -293,14 +293,18 @@ ENESMBusController::ENESMBusController(ENESMBusInterface* interface, ene_dev_id
|
||||
channel_cfg = ENE_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Assume first generation controller if string does not |
|
||||
| match |
|
||||
| If string does not match any known variants, set LED |
|
||||
| count to 0 so that controller is not registered. |
|
||||
| This protects the device against invalid operations |
|
||||
| if reading the config table or device string were to |
|
||||
| fail. |
|
||||
\*-----------------------------------------------------*/
|
||||
else
|
||||
{
|
||||
direct_reg = ENE_REG_COLORS_DIRECT;
|
||||
effect_reg = ENE_REG_COLORS_EFFECT;
|
||||
channel_cfg = ENE_CONFIG_CHANNEL_V1;
|
||||
led_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,6 +401,11 @@ const char * ENESMBusController::GetChannelName(unsigned int cfg_zone)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int ENESMBusController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned int ENESMBusController::GetLEDCount(unsigned int cfg_zone)
|
||||
{
|
||||
LOG_TRACE("[%s] LED Count for zone %02d: %02d", device_version, cfg_zone, config_table[0x03 + cfg_zone]);
|
||||
@@ -536,10 +545,12 @@ bool ENESMBusController::SupportsMode14()
|
||||
|
||||
void ENESMBusController::UpdateDeviceName()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
device_version[i] = ENERegisterRead(ENE_REG_DEVICE_NAME + i);
|
||||
}
|
||||
|
||||
device_version[15] = '\0';
|
||||
}
|
||||
|
||||
unsigned char ENESMBusController::ENERegisterRead(ene_register reg)
|
||||
|
||||
@@ -117,6 +117,7 @@ public:
|
||||
device_type GetType();
|
||||
|
||||
const char* GetChannelName(unsigned int cfg_zone);
|
||||
unsigned int GetLEDCount();
|
||||
unsigned int GetLEDCount(unsigned int cfg_zone);
|
||||
unsigned char GetLEDRed(unsigned int led);
|
||||
unsigned char GetLEDGreen(unsigned int led);
|
||||
|
||||
@@ -198,11 +198,19 @@ DetectedControllers DetectENESMBusDRAMControllers(std::vector<i2c_smbus_interfac
|
||||
{
|
||||
if(TestForENESMBusController(buses[bus], ene_ram_addresses[address_list_idx]))
|
||||
{
|
||||
ENESMBusInterface_i2c_smbus* interface = new ENESMBusInterface_i2c_smbus(buses[bus]);
|
||||
ENESMBusController* controller = new ENESMBusController(interface, ene_ram_addresses[address_list_idx], "ENE DRAM", DEVICE_TYPE_DRAM);
|
||||
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
|
||||
ENESMBusInterface_i2c_smbus* interface = new ENESMBusInterface_i2c_smbus(buses[bus]);
|
||||
ENESMBusController* controller = new ENESMBusController(interface, ene_ram_addresses[address_list_idx], "ENE DRAM", DEVICE_TYPE_DRAM);
|
||||
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
if(controller->GetLEDCount() > 0)
|
||||
{
|
||||
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
|
||||
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
Reference in new issue
Block a user