Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Add RM750i protocol
Add Power Supply support
  • Loading branch information
audiohacked committed Feb 23, 2017
1 parent 6210563 commit 4ad9080
Show file tree
Hide file tree
Showing 11 changed files with 403 additions and 8 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ OpenCorsairLink
## Previous version of OpenCorsairLink has been moved to the legacy branch!

Supported Water Coolers (but not fully tested):
- H80i
- H100i
- H100i v2
- H110i
- H110i Extreme
- USB HID:
- H80i
- H100i
- H110i
- Asetek:
- H55
- H75
- H80i v2
- H90
- H105
- H100i v2
- H115i

Supported Power Supplies:
- RM750i

### What should work:
LED control
Expand All @@ -21,4 +31,4 @@ The program currently doesn't know the difference between Water Coolers... yet!
libusb-1.0

### Running
Since the program needs direct hardware access you should run this with 'sudo' or as root.
Since the program needs direct hardware access you should run this with 'sudo' or as root.
17 changes: 16 additions & 1 deletion device.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ struct corsair_device_driver corsairlink_driver_asetek = {
}
};

struct corsair_device_driver corsairlink_driver_rmi = {
.init = corsairlink_rmi_init,
.deinit = corsairlink_rmi_deinit,
.device_id = corsairlink_rmi_device_id,
.read = corsairlink_rmi_read,
.write = corsairlink_rmi_write,
.led = NULL,
.power = {
.select = corsairlink_rmi_output_select,
.voltage = corsairlink_rmi_output_volts,
.amperage = corsairlink_rmi_output_amps,
.wattage = corsairlink_rmi_output_watts,
}
};

struct corsair_device_info corsairlink_devices[] = {
{
.vendor_id = 0x1b1c,
Expand Down Expand Up @@ -138,7 +153,7 @@ struct corsair_device_info corsairlink_devices[] = {
.write_endpoint = 0x01|LIBUSB_ENDPOINT_OUT,
.handle = NULL,
.context = NULL,
.driver = &corsairlink_driver_hid,
.driver = &corsairlink_driver_rmi,
.led_control_count = 0,
.fan_control_count = 1,
.pump_index = 0,
Expand Down
7 changes: 7 additions & 0 deletions device.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ struct corsair_device_driver {
int (*custom)(struct corsair_device_info *dev, struct fan_table *custom_profile);
} pump_control;

struct {
int (*select)(struct corsair_device_info *dev, uint8_t output_select);
int (*voltage)(struct corsair_device_info *dev, float *volts);
int (*amperage)(struct corsair_device_info *dev, float *amps);
int (*wattage)(struct corsair_device_info *dev, float *watts;
} power;

int (*fan_speed_read)();
};

Expand Down
69 changes: 69 additions & 0 deletions lowlevel/rmi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This file is part of OpenCorsairLink.
* Copyright (C) 2017 Sean Nelson <[email protected]>
* OpenCorsairLink is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
* OpenCorsairLink is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <libusb.h>
#include "../lowlevel/rmi.h"

#define TIMEOUT_DEFAULT 1000
#define INTERRUPT_IN_ENDPOINT 0x81
#define INTERRUPT_OUT_ENDPOINT 0x01

int corsairlink_rmi_init(struct libusb_device_handle *dev_handle,
uint8_t endpoint)
{
return 0;
}

int corsairlink_rmi_deinit(struct libusb_device_handle *dev_handle,
uint8_t endpoint)
{
return 0;
}

int corsairlink_rmi_write(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
int length)
{
int bytes_transferred;
int r;

r = libusb_interrupt_transfer(dev_handle,
endpoint,
data, length,
&bytes_transfered, TIMEOUT_DEFAULT);

return r;
}

int corsairlink_rmi_read(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
int length)
{
int bytes_transferred;
int r;

r = libusb_interrupt_transfer(dev_handle,
endpoint,
data, length,
&bytes_transferred, TIMEOUT_DEFAULT);

return r;
}
38 changes: 38 additions & 0 deletions lowlevel/rmi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of OpenCorsairLink.
* Copyright (C) 2017 Sean Nelson <[email protected]>
* OpenCorsairLink is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
* OpenCorsairLink is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _LOWLEVEL_RMI_H
#define _LOWLEVEL_RMI_H

int corsairlink_rmi_init(struct libusb_device_handle *dev_handle,
uint8_t endpoint);

int corsairlink_rmi_deinit(struct libusb_device_handle *dev_handle,
uint8_t endpoint);

int corsairlink_rmi_write(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
int length);

int corsairlink_rmi_read(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
int length);

#endif
13 changes: 12 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,18 @@ int main(int argc, char *argv[])

r = dev->driver->init(dev->handle, dev->write_endpoint);

r = dev->driver->led(dev, &led_color, &warning_led, warning_led_temp, (warning_led_temp > -1));
float v, a, w;

for (i=0; i<5; i++) {
r = dev->driver->power->select(dev, i);
fprintf(stdout, "Output %d\n", i);
r = dev->driver->power->voltage(dev, &v);
fprintf(stdout, "\tVoltage %.2f\n", v);
r = dev->driver->power->amperage(dev, &a);
fprintf(stdout, "\tAmps %.2f\n", a);
r = dev->driver->power->wattage(dev, &w);
fprintf(stdout, "\tWatts %.2f\n", w);
}

r = dev->driver->deinit(dev->handle, dev->write_endpoint);

Expand Down
79 changes: 79 additions & 0 deletions protocol/rmi/core.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* This file is part of OpenCorsairLink.
* Copyright (C) 2017 Sean Nelson <[email protected]>
* OpenCorsairLink is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
* OpenCorsairLink is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <libusb.h>

#include "../../lowlevel/hid.h"
#include "../../device.h"
#include "core.h"

int corsairlink_hid_device_id(struct corsair_device_info *dev)
{
int r;
uint8_t response[64];
uint8_t commands[32] ;
memset(response, 0, sizeof(response));
memset(commands, 0, sizeof(commands));

uint8_t i = 1;

i = 1;
// Read Device ID: 0x3b = H80i. 0x3c = H100i. 0x41 = H110i. 0x42 = H110i Extreme
commands[i++] = CommandId++; // Command ID
commands[i++] = ReadOneByte; // Command Opcode
commands[i++] = DeviceID; // Command data...
commands[i++] = 0x00;

commands[0] = i; // Length

r = dev->driver->write(dev->handle, dev->write_endpoint, commands, i);
r = dev->driver->read(dev->handle, dev->read_endpoint, response, 64);

return response[2];
}

int corsairlink_hid_firmware_id(struct corsair_device_info *dev)
{
int r;
uint8_t response[64];
uint8_t commands[32] ;
memset(response, 0, sizeof(response));
memset(commands, 0, sizeof(commands));

uint8_t i = 1;

i = 1;
commands[i++] = CommandId++; // Command ID
commands[i++] = ReadTwoBytes; // Command Opcode
commands[i++] = FirmwareID; // Command data...
commands[i++] = 0x00;

commands[0] = i; // Length

r = dev->driver->write(dev->handle, dev->write_endpoint, commands, i);
r = dev->driver->read(dev->handle, dev->read_endpoint, response, 64);

int firmware = response[3]<<8;
firmware += response[2];
return firmware;
}
45 changes: 45 additions & 0 deletions protocol/rmi/core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* This file is part of OpenCorsairLink.
* Copyright (C) 2017 Sean Nelson <[email protected]>
* OpenCorsairLink is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
* OpenCorsairLink is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PROTOCOL_RMI_H
#define _PROTOCOL_RMI_H

#include "../../common.h"

int corsairlink_rmi_device_id(struct corsair_device_info *dev);
int corsairlink_rmi_firmware_id(struct corsair_device_info *dev);
int corsairlink_rmi_channel_id(struct corsair_device_info *dev);
int corsairlink_rmi_product_id(struct corsair_device_info *dev);

int corsairlink_rmi_output_select(struct corsair_device_info *dev, uint8_t select);
int corsairlink_rmi_output_voltage(struct corsair_device_info *dev, float volts);
int corsairlink_rmi_output_amps(struct corsair_device_info *dev, float amps);
int corsairlink_rmi_output_watts(struct corsair_device_info *dev, float watts);

int corsairlink_rmi_total_watts(struct corsair_device_info *dev, float watts);
int corsairlink_rmi_supply_volts(struct corsair_device_info *dev, float volts);

int corsairlink_rmi_temp1(struct corsair_device_info *dev, float temp);
int corsairlink_rmi_temp2(struct corsair_device_info *dev, float temp);

// int corsairlink_rmi_fan_mode();
// int corsairlink_rmi_fan_pwm();
// int corsairlink_rmi_fan_pwm_percent();
// int corsairlink_rmi_fan_status();

#endif
Empty file added protocol/rmi/fan.c
Empty file.
Loading

0 comments on commit 4ad9080

Please sign in to comment.