CorsairOfficial / cue-sdk

Corsair iCUE SDK
https://corsairofficial.github.io/cue-sdk/
215 stars 23 forks source link

Wrong number of leds in channels reported by the SDK #26

Closed DarthAffe closed 2 years ago

DarthAffe commented 2 years ago

Hey,

we're currently seeing an issue with the channel-data reported for the Commander CORE with a pump and two 8-led-fans attached. Reading the data for the device yields the following:

### Commander CORE ###
ledCount: 37
Channels:
Type: Invalid
ledCount: 8
Type: Invalid
ledCount: 8
Type: Invalid
ledCount: 8
---------------------------------
CustomDeviceChannel1Led1
CustomDeviceChannel1Led2
CustomDeviceChannel1Led3
CustomDeviceChannel1Led4
CustomDeviceChannel1Led5
CustomDeviceChannel1Led6
CustomDeviceChannel1Led7
CustomDeviceChannel1Led8
CustomDeviceChannel1Led9
CustomDeviceChannel1Led10
CustomDeviceChannel1Led11
CustomDeviceChannel1Led12
CustomDeviceChannel1Led13
CustomDeviceChannel1Led14
CustomDeviceChannel1Led15
CustomDeviceChannel1Led16
CustomDeviceChannel1Led17
CustomDeviceChannel1Led18
CustomDeviceChannel1Led19
CustomDeviceChannel1Led20
CustomDeviceChannel1Led21
CustomDeviceChannel1Led43
CustomDeviceChannel1Led44
CustomDeviceChannel1Led45
CustomDeviceChannel1Led46
CustomDeviceChannel1Led47
CustomDeviceChannel1Led48
CustomDeviceChannel1Led49
CustomDeviceChannel1Led50
CustomDeviceChannel1Led85
CustomDeviceChannel1Led86
CustomDeviceChannel1Led87
CustomDeviceChannel1Led88
CustomDeviceChannel1Led89
CustomDeviceChannel1Led90
CustomDeviceChannel1Led91
CustomDeviceChannel1Led92

The overall led-count and the led ids reported are correct, but the led-counts for each channels aren't since the first channel (the pump) consists of 21 leds. This causes our mapping to take 24 (3*8) leds into account instead of the expected 37 (and the grouping is a mess).

The code extracting this data uses CorsairGetDeviceInfo to get the CorsairChannelsInfo and CorsairGetLedPositionsByDeviceIndex to get the actual leds.

The test was done using iCUE v. 4.17.244 and the latest as well as the previous SDK.

EliasStar commented 2 years ago

Can confirm. I have an 'iCUE H150i ELITE CAPELLIX' cooler connected through a Commander CORE with six 8-LED series fans. The SDK returns 7 channels with 8 leds each. Channels 1..3 contain the leds from the pump head with the 3rd including also 3 leds from the first fan. 5 leds from the 5th fan and the entire last fan aren't accessible at all.

intrueder commented 2 years ago

@DarthAffe @EliasStar could you please check iCUE v4.21?

DarthAffe commented 2 years ago

It seems like this changes it the wrong way around. Instead of returning the correct amount of leds in the channel->ledCount it just removed any led past the (wrong) count.

### Commander Pro ###
ledCount: 24
Channels:
Type: Invalid
ledCount: 8
Type: Invalid
ledCount: 8
Type: Invalid
ledCount: 8
---------------------------------
CustomDeviceChannel1Led1
CustomDeviceChannel1Led2
CustomDeviceChannel1Led3
CustomDeviceChannel1Led4
CustomDeviceChannel1Led5
CustomDeviceChannel1Led6
CustomDeviceChannel1Led7
CustomDeviceChannel1Led8
CustomDeviceChannel1Led43
CustomDeviceChannel1Led44
CustomDeviceChannel1Led45
CustomDeviceChannel1Led46
CustomDeviceChannel1Led47
CustomDeviceChannel1Led48
CustomDeviceChannel1Led49
CustomDeviceChannel1Led50
CustomDeviceChannel1Led85
CustomDeviceChannel1Led86
CustomDeviceChannel1Led87
CustomDeviceChannel1Led88
CustomDeviceChannel1Led89
CustomDeviceChannel1Led90
CustomDeviceChannel1Led91
CustomDeviceChannel1Led92

We would expect it to be

### Commander Pro ###
ledCount: 37
Channels:
Type: Invalid
ledCount: 21
Type: Invalid
ledCount: 8
Type: Invalid
ledCount: 8

<LedIds like in the original message>
intrueder commented 2 years ago

I assume you are looking at channel LEDs only. Could you also check the LEDs on the device itself? Because that's how it works in 4.21: Commander CORE shows pump LEDs as part of the device itself, and channel LEDs are fans.

DarthAffe commented 2 years ago

I thought about this quite a while now, but I really can't see how this should work with the data returned.

The call to CorsairGetDeviceInfo returns a CorsairDeviceInfo. The count in there is 24 which is completely unexpected for me. I would understand if it's 21 (that would be the case you're describing -> the pump is "the device"), or 37 (it returns the sum of all channels). The second thing I don't get are the return values of CorsairGetLedPositionsByDeviceIndex. So far I expected this to return the IDs of all leds of the device (device-leds and channel-leds). But as stated above I get 3 blocks of 8 leds which again doesn't fit into the 21 of the pump at all.

To me it seems like CorsairDeviceInfo.count is the sum of the counts of all channels and it just ignores the device leds.

intrueder commented 2 years ago

@DarthAffe, when a pump is connected to Commander CORE, it shows all leds in CorsairGetLedPositionsByDeviceIndex, device leds and channel leds (LC_C1, D_C1, see below)

If possible, use the following python script to dump LEDs on your system (but first, run pip install cue-sdk):

from cuesdk import CueSdk
import sys

sdk = CueSdk()
if not sdk.connect():
    print(sdk.protocol_details)
    print("\nERROR: Unable to connect to iCUE")
    sys.exit()

print(sdk.protocol_details)
print(sdk.get_devices())

for i, v in enumerate(sdk.get_devices()):
    print("\n\n%s:%s (leds: %d)\n" % (v.type, v.model, v.led_count))
    positions = sdk.get_led_positions_by_device_index(i)
    print("\tLEDS:")
    for p in positions.keys():
        print(p)
    for chi, ch in enumerate(v.channels):
        print("\tCHANNEL %d (total leds: %d)" % (chi + 1, ch.total_led_count))
        for d in ch.devices:
            print(d.type, d.led_count)

On our test machine we have the output, that includes 45 leds for the device, 24 of them belong to Channel 1 (3 x 8):

# Commander CORE
ledsCount: 45

## CorsairGetLedPositionsByDeviceIndex:

CorsairLedId.LC_C1_1
CorsairLedId.LC_C1_2
CorsairLedId.LC_C1_3
CorsairLedId.LC_C1_4
CorsairLedId.LC_C1_5
CorsairLedId.LC_C1_6
CorsairLedId.LC_C1_7
CorsairLedId.LC_C1_8
CorsairLedId.LC_C1_9
CorsairLedId.LC_C1_10
CorsairLedId.LC_C1_11
CorsairLedId.LC_C1_12
CorsairLedId.LC_C1_13
CorsairLedId.LC_C1_14
CorsairLedId.LC_C1_15
CorsairLedId.LC_C1_16
CorsairLedId.LC_C1_17
CorsairLedId.LC_C1_18
CorsairLedId.LC_C1_19
CorsairLedId.LC_C1_20
CorsairLedId.LC_C1_21
CorsairLedId.D_C1_43
CorsairLedId.D_C1_44
CorsairLedId.D_C1_45
CorsairLedId.D_C1_46
CorsairLedId.D_C1_47
CorsairLedId.D_C1_48
CorsairLedId.D_C1_49
CorsairLedId.D_C1_50
CorsairLedId.D_C1_85
CorsairLedId.D_C1_86
CorsairLedId.D_C1_87
CorsairLedId.D_C1_88
CorsairLedId.D_C1_89
CorsairLedId.D_C1_90
CorsairLedId.D_C1_91
CorsairLedId.D_C1_92
CorsairLedId.D_C1_127
CorsairLedId.D_C1_128
CorsairLedId.D_C1_129
CorsairLedId.D_C1_130
CorsairLedId.D_C1_131
CorsairLedId.D_C1_132
CorsairLedId.D_C1_133
CorsairLedId.D_C1_134

## CHANNEL 1
totalLedsCount: 24

Channel devices:
1. CorsairChannelDeviceType.SPPRO_Fan - deviceLedCount: 8
2. CorsairChannelDeviceType.SPPRO_Fan - deviceLedCount: 8
3. CorsairChannelDeviceType.SPPRO_Fan - deviceLedCount: 8
DarthAffe commented 2 years ago

Ok this helped to figure it out. 4.21 works as you described.

Since I don't have a device to test, it was a collaborative work and we somehow ran into some confusion with multiple connected commanders. Sorry for that and thanks again for the help :)