├── extras └── cmocka-1.1.1 │ ├── NEWS │ ├── .clang_complete │ ├── include │ ├── cmockery │ │ ├── cmockery.h │ │ └── pbc.h │ ├── CMakeLists.txt │ └── cmocka_pbc.h │ ├── cmocka-build-tree-settings.cmake.in │ ├── doc │ └── CMakeLists.txt │ ├── example │ ├── chef_wrap │ │ ├── waiter_test_wrap.h │ │ ├── CMakeLists.txt │ │ ├── chef.h │ │ └── chef.c │ ├── assert_macro.h │ ├── simple_test.c │ ├── assert_module.h │ ├── product_database.c │ ├── key_value.h │ ├── assert_module.c │ ├── assert_macro.c │ ├── database.h │ ├── assert_macro_test.c │ ├── allocate_module_test.c │ ├── key_value.c │ ├── assert_module_test.c │ ├── allocate_module.c │ ├── customer_database.c │ ├── key_value_test.c │ ├── product_database_test.c │ └── customer_database_test.c │ ├── AUTHORS │ ├── coverity │ ├── coverity_internal_model.c │ ├── README │ └── coverity_assert_model.c │ ├── cmocka.pc.cmake │ ├── DefineOptions.cmake │ ├── CTestConfig.cmake │ ├── cmocka-config.cmake.in │ ├── cmocka-config-version.cmake.in │ ├── README │ ├── cmake │ └── Modules │ │ ├── DefinePlatformDefaults.cmake │ │ ├── MacroEnsureOutOfSourceBuild.cmake │ │ ├── CheckCCompilerFlagSSP.cmake │ │ ├── DefineCMakeDefaults.cmake │ │ ├── AddCMockaTest.cmake │ │ ├── COPYING-CMAKE-SCRIPTS │ │ ├── FindNSIS.cmake │ │ └── DefineCompilerFlags.cmake │ ├── tests │ ├── test_exception_handler.c │ ├── test_group_setup_fail.c │ ├── test_group_setup_assert.c │ ├── test_assert_macros.c │ ├── test_assert_macros_fail.c │ ├── test_cmockery.c │ ├── test_skip.c │ ├── test_group_fixtures.c │ ├── test_setup_fail.c │ ├── test_basics.c │ ├── test_returns.c │ ├── test_returns_fail.c │ ├── test_groups.c │ ├── test_fixtures.c │ ├── test_alloc.c │ ├── test_ordering_fail.c │ ├── ctest-default.cmake │ └── test_ordering.c │ ├── src │ ├── cmocka.def │ └── CMakeLists.txt │ ├── CPackConfig.cmake │ ├── CMakeLists.txt │ └── INSTALL ├── docs ├── add_driver.md ├── git_hooks │ └── pre-commit ├── reverse_engineering.md ├── CODING_STANDARDS.md ├── add_device.md ├── device_dumps │ ├── H100i_RGB_Pro_XT.txt │ ├── H80iGT.txt │ ├── H150i_Pro.txt │ ├── H115i_Pro.txt │ ├── H100i_asetek.txt │ ├── H110i.txt │ └── CommanderPro.txt └── CODE_OF_CONDUCT.md ├── .gitignore ├── protocol ├── commanderpro │ ├── .DS_Store │ ├── power.c │ └── temperature.c ├── rmi │ ├── fan.c │ ├── temperature.c │ └── time.c ├── platinum │ ├── crc.c │ ├── temperature.c │ ├── core.c │ ├── pump.c │ └── led.c ├── asetek │ └── temperature.c ├── asetekpro │ ├── temperature.c │ └── core.c └── coolit │ ├── led.c │ └── temperature.c ├── include ├── protocol │ └── crc.h ├── common.h ├── logic │ ├── scan.h │ └── print.h ├── unsupported.h ├── lowlevel │ ├── commanderpro.h │ ├── asetek.h │ ├── rmi.h │ ├── coolit.h │ └── platinum.h └── device.h ├── Dockerfile ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── PULL_REQUEST_TEMPLATE.md ├── README.md ├── .travis.yml ├── CONTRIBUTING.md ├── .appveyor.yml ├── drivers ├── dongle.c ├── unsupported.c ├── rmi.c └── commanderpro.c ├── lowlevel ├── commanderpro.c ├── asetek.c ├── rmi.c └── coolit.c ├── OLD.md ├── logic ├── print.c ├── options_pump.c └── options_fan.c └── tests └── test_protocol_asetek.c /extras/cmocka-1.1.1/NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/add_driver.md: -------------------------------------------------------------------------------- 1 | # How to Add A Driver 2 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/.clang_complete: -------------------------------------------------------------------------------- 1 | -Iinclude 2 | -Iobj 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.elf 3 | .vscode 4 | .idea 5 | out 6 | gen 7 | build -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/include/cmockery/cmockery.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/include/cmockery/pbc.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmocka-build-tree-settings.cmake.in: -------------------------------------------------------------------------------- 1 | set(CMOCKA_INLUDE_DIR @PROJECT_SOURCE_DIR@/include) 2 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Build the documentation 3 | # 4 | include(UseDoxygen OPTIONAL) 5 | 6 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/chef_wrap/waiter_test_wrap.h: -------------------------------------------------------------------------------- 1 | 2 | int __wrap_chef_cook(const char *order, char **dish_out); 3 | -------------------------------------------------------------------------------- /protocol/commanderpro/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperkineticnerd/OpenCorsairLink/HEAD/protocol/commanderpro/.DS_Store -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/AUTHORS: -------------------------------------------------------------------------------- 1 | opensource@google.com 2 | Andreas Schneider 3 | Jakub Hrozek 4 | -------------------------------------------------------------------------------- /include/protocol/crc.h: -------------------------------------------------------------------------------- 1 | // crc8.h 2 | 3 | #include 4 | #include 5 | 6 | uint8_t crc8ccitt(const void * data, size_t size); 7 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/assert_macro.h: -------------------------------------------------------------------------------- 1 | const char* get_status_code_string(const unsigned int status_code); 2 | unsigned int string_to_status_code(const char* const status_code_string); 3 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/coverity/coverity_internal_model.c: -------------------------------------------------------------------------------- 1 | /* Functions to help coverity do static analysis on cmocka */ 2 | void exit_test(const int quit_application) 3 | { 4 | __coverity_panic__(); 5 | } 6 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmocka.pc.cmake: -------------------------------------------------------------------------------- 1 | Name: ${APPLICATION_NAME} 2 | Description: The cmocka unit testing library 3 | Version: ${APPLICATION_VERSION} 4 | Libs: -L${LIB_INSTALL_DIR} -lcmocka 5 | Cflags: -I${INCLUDE_INSTALL_DIR} 6 | 7 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/DefineOptions.cmake: -------------------------------------------------------------------------------- 1 | option(WITH_STATIC_LIB "Build with a static library" OFF) 2 | option(WITH_CMOCKERY_SUPPORT "Install a cmockery header" OFF) 3 | option(UNIT_TESTING "Build with unit testing" OFF) 4 | 5 | if (UNIT_TESTING) 6 | set(WITH_STATIC_LIB ON) 7 | endif() 8 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/CTestConfig.cmake: -------------------------------------------------------------------------------- 1 | set(UPDATE_TYPE "true") 2 | 3 | set(CTEST_PROJECT_NAME "cmocka") 4 | set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") 5 | 6 | set(CTEST_DROP_METHOD "https") 7 | set(CTEST_DROP_SITE "mock.cryptomilk.org") 8 | set(CTEST_DROP_LOCATION "/submit.php?project=${CTEST_PROJECT_NAME}") 9 | set(CTEST_DROP_SITE_CDASH TRUE) 10 | 11 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/coverity/README: -------------------------------------------------------------------------------- 1 | coverity_assert_model.c: 2 | 3 | This file is a Coverity Modeling file for projects using CMocka for unit 4 | testing. The assert functiions could create false positives, to avoid that you 5 | can load this modeling file in the Coverity web interface. 6 | 7 | coverity_internal_model.c: 8 | 9 | This file is for the CMocka source code itself. 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | ARG BRANCH=testing 4 | 5 | LABEL maintainer="zaggash" 6 | 7 | RUN \ 8 | apt-get update && \ 9 | apt-get install -y \ 10 | git \ 11 | libusb-1.0 \ 12 | pkg-config 13 | 14 | RUN \ 15 | git clone -b ${BRANCH} https://github.com/audiohacked/OpenCorsairLink.git /OpenCorsairLink && \ 16 | cd /OpenCorsairLink && \ 17 | make 18 | 19 | WORKDIR /OpenCorsairLink 20 | ENTRYPOINT cp OpenCorsairLink.elf /opt 21 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmocka-config.cmake.in: -------------------------------------------------------------------------------- 1 | get_filename_component(CMOCKA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 2 | 3 | if (EXISTS "${CMOCKA_CMAKE_DIR}/CMakeCache.txt") 4 | # In build tree 5 | include(${CMOCKA_CMAKE_DIR}/cmocka-build-tree-settings.cmake) 6 | else() 7 | set(CMOCKA_INCLUDE_DIR @INCLUDE_INSTALL_DIR@) 8 | endif() 9 | 10 | set(CMOCKA_LIBRARY @LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@) 11 | set(CMOCKA_LIBRARIES @LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@) 12 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmocka-config-version.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION @APPLICATION_VERSION@) 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/simple_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* A test case that does nothing and succeeds. */ 7 | static void null_test_success(void **state) { 8 | (void) state; /* unused */ 9 | } 10 | 11 | int main(void) { 12 | const struct CMUnitTest tests[] = { 13 | cmocka_unit_test(null_test_success), 14 | }; 15 | 16 | return cmocka_run_group_tests(tests, NULL, NULL); 17 | } 18 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cmocka-headers C) 2 | 3 | set(cmocka_HDRS 4 | cmocka.h 5 | cmocka_pbc.h 6 | ) 7 | 8 | install( 9 | FILES 10 | ${cmocka_HDRS} 11 | DESTINATION 12 | ${INCLUDE_INSTALL_DIR} 13 | COMPONENT 14 | headers 15 | ) 16 | 17 | if (WITH_CMOCKERY_SUPPORT) 18 | install( 19 | FILES 20 | cmockery/cmockery.h 21 | cmockery/pbc.h 22 | DESTINATION 23 | ${INCLUDE_INSTALL_DIR}/cmockery 24 | COMPONENT 25 | headers 26 | ) 27 | endif() 28 | -------------------------------------------------------------------------------- /docs/git_hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/ bin / bash 2 | 3 | STYLE = $( git config-- get hooks.clangformat.style ) if[-n "${STYLE}"]; 4 | then STYLEARG = "-style=${STYLE}" else STYLEARG = "" fi 5 | 6 | format_file() 7 | { 8 | file = "${1}" clang - format - i ${ STYLEARG } ${ 1 } git add $ 9 | { 10 | 1 11 | } 12 | } 13 | 14 | case "${1}" in 15 | --about ) 16 | echo "Runs clang-format on source files" 17 | ;; 18 | * ) 19 | for file in `git diff-index --cached --name-only HEAD` ; do 20 | format_file "${file}" 21 | done 22 | ;; 23 | esac 24 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/README: -------------------------------------------------------------------------------- 1 | CMOCKA 2 | ======= 3 | 4 | cmocka is a fork for Google's cmockery unit testing framework to fix bugs and 5 | support it in future. 6 | See https://code.google.com/p/cmockery/ 7 | 8 | For information about how to use the cmocka unit testing framework see 9 | doc/index.html. 10 | 11 | COMPILING 12 | --------- 13 | To compile the cmocka library and example applications run, create a build dir, 14 | and in the build dir call 'cmake /path/to/cmocka' followed by 'make'. On 15 | Windows you can use the cmake gui. More details can be found in the INSTALL file. 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmake/Modules/DefinePlatformDefaults.cmake: -------------------------------------------------------------------------------- 1 | # Set system vars 2 | 3 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 4 | set(LINUX TRUE) 5 | endif(CMAKE_SYSTEM_NAME MATCHES "Linux") 6 | 7 | if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 8 | set(FREEBSD TRUE) 9 | endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 10 | 11 | if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") 12 | set(OPENBSD TRUE) 13 | endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") 14 | 15 | if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") 16 | set(NETBSD TRUE) 17 | endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD") 18 | 19 | if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") 20 | set(SOLARIS TRUE) 21 | endif (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") 22 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/chef_wrap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cmocka-wrap-examples C) 2 | 3 | include_directories( 4 | ${CMAKE_BINARY_DIR} 5 | ${CMAKE_CURRENT_SOURCE_DIR} 6 | ${CMOCKA_PUBLIC_INCLUDE_DIRS} 7 | ) 8 | 9 | add_executable(waiter_test_wrap waiter_test_wrap.c chef.c) 10 | target_link_libraries(waiter_test_wrap ${CMOCKA_SHARED_LIBRARY}) 11 | 12 | add_test(waiter_test_wrap ${CMAKE_CURRENT_BINARY_DIR}/waiter_test_wrap) 13 | 14 | set_target_properties(waiter_test_wrap 15 | PROPERTIES 16 | LINK_FLAGS "-Wl,--wrap=chef_cook" 17 | ) 18 | if (WIN32 OR MINGW OR CYGWIN) 19 | set_tests_properties(waiter_test_wrap PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}") 20 | endif (WIN32 OR MINGW OR CYGWIN) 21 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_exception_handler.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | struct test_segv { 9 | int x; 10 | int y; 11 | }; 12 | 13 | static void test_segfault_recovery(void **state) 14 | { 15 | struct test_segv *s = NULL; 16 | 17 | (void) state; /* unused */ 18 | 19 | s->x = 1; 20 | } 21 | 22 | int main(void) { 23 | const struct CMUnitTest tests[] = { 24 | cmocka_unit_test(test_segfault_recovery), 25 | cmocka_unit_test(test_segfault_recovery), 26 | cmocka_unit_test(test_segfault_recovery), 27 | }; 28 | 29 | return cmocka_run_group_tests(tests, NULL, NULL); 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenCorsairLink 2 | 3 | I (Audiohacked) have decided to retire OpenCorsairLink. The Reasons for this is: 4 | - I was the sole developer and with my job (Consultant) I have far less time to work on this project. 5 | - This project is written in C and thus hard(er) to program for most people. 6 | - Most of the support was through reverse engineering the iCUE/CorsairLink protocols as I bought the hardware. 7 | 8 | As I am still a fan of Corsair Products, any work/development/reverse-engineering I do in the future will available at https://github.com/jonasmalacofilho/liquidctl. 9 | 10 | P.S. As of late I've already have been contributing to liquidctl. Python is so much easier to work with, and faster than when I first learned Python. 11 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/assert_module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | void increment_value(int * const value); 18 | void decrement_value(int * const value); 19 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake: -------------------------------------------------------------------------------- 1 | # - MACRO_ENSURE_OUT_OF_SOURCE_BUILD() 2 | # MACRO_ENSURE_OUT_OF_SOURCE_BUILD() 3 | 4 | # Copyright (c) 2006, Alexander Neundorf, 5 | # 6 | # Redistribution and use is allowed according to the terms of the BSD license. 7 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 8 | 9 | macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage) 10 | 11 | string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource) 12 | if (_insource) 13 | message(SEND_ERROR "${_errorMessage}") 14 | message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.") 15 | endif (_insource) 16 | 17 | endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD) 18 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_group_setup_fail.c: -------------------------------------------------------------------------------- 1 | /* Use the unit test allocators */ 2 | #define UNIT_TESTING 1 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static int group_setup_failing(void **state) 10 | { 11 | (void) state; /* unused */ 12 | return 1; /* To indicate the failure */ 13 | } 14 | 15 | static void test_true(void **state) 16 | { 17 | (void) state; /* unused */ 18 | assert_true(1); 19 | } 20 | 21 | static void test_false(void **state) 22 | { 23 | (void) state; /* unused */ 24 | assert_false(0); 25 | } 26 | 27 | int main(void) { 28 | const struct CMUnitTest tests[] = { 29 | cmocka_unit_test(test_true), 30 | cmocka_unit_test(test_false), 31 | }; 32 | 33 | return cmocka_run_group_tests(tests, group_setup_failing, NULL); 34 | } 35 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_group_setup_assert.c: -------------------------------------------------------------------------------- 1 | /* Use the unit test allocators */ 2 | #define UNIT_TESTING 1 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static int group_setup_failing(void **state) 10 | { 11 | (void) state; /* unused */ 12 | 13 | assert_int_equal(0, 1); 14 | 15 | return 0; 16 | } 17 | 18 | static void test_true(void **state) 19 | { 20 | (void) state; /* unused */ 21 | assert_true(1); 22 | } 23 | 24 | static void test_false(void **state) 25 | { 26 | (void) state; /* unused */ 27 | assert_false(0); 28 | } 29 | 30 | int main(void) { 31 | const struct CMUnitTest tests[] = { 32 | cmocka_unit_test(test_true), 33 | cmocka_unit_test(test_false), 34 | }; 35 | 36 | return cmocka_run_group_tests(tests, group_setup_failing, NULL); 37 | } 38 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/chef_wrap/chef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 (c) Andreas Schneider 3 | * Jakub Hrozek 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | int chef_cook(const char *order, char **dish_out); 19 | const char *chef_strerror(int error); 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/product_database.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | DatabaseConnection* connect_to_product_database(void); 19 | 20 | /* Connect to the database containing customer information. */ 21 | DatabaseConnection* connect_to_product_database(void) { 22 | return connect_to_database("products.abcd.org", 322); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /docs/reverse_engineering.md: -------------------------------------------------------------------------------- 1 | Use Wireshark with filters: 2 | 3 | Packets from Host to Device 4 | ``` 5 | (usb.src contains "host" && usb.dst contains "1.2.0") 6 | ``` 7 | 8 | Packets from Device to Host 9 | ``` 10 | (usb.src contains "1.2.1" && usb.dst contains "host") 11 | ``` 12 | 13 | Protocol Packets: 14 | ``` 15 | (usb.src contains "1.8.1") or (usb.dst contains "1.8.0") 16 | ``` 17 | 18 | Protocol Packet Data Fragments: 19 | ``` 20 | (usb.data_fragment[0] == 3f && usb.data_fragment[2] == 14) 21 | ``` 22 | 23 | Curve 1 24 | 25% = 0x19 25 | 30% = 0x1E 26 | 35% = 0x23 27 | 40% = 0x28 28 | 45% = 0x2D 29 | 50% = 0x32 30 | 55% = 0x37 31 | 32 | 20C = 0x14 33 | 30C = 0x1E 34 | 40C = 0x28 35 | 50C = 0x32 36 | 60C = 0x3C 37 | 70C = 0x46 38 | 80C = 0x50 39 | 40 | Curve 2 41 | 35% = 0x23 42 | 40% = 0x28 43 | 45% = 0x2D 44 | 50% = 0x32 45 | 55% = 0x37 46 | 60% = 0x3C 47 | 65% = 0x41 48 | 49 | 20C = 0x14 50 | 30C = 0x1E 51 | 40C = 0x28 52 | 50C = 0x32 53 | 60C = 0x3C 54 | 70C = 0x46 55 | 80C = 0x50 56 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_assert_macros.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #ifdef HAVE_UNISTD_H 13 | #include 14 | #endif 15 | #include 16 | 17 | /************************************** 18 | *** assert_return_code 19 | **************************************/ 20 | static void test_assert_return_code(void **state) 21 | { 22 | struct stat sb; 23 | int rc; 24 | 25 | (void)state; /* unused */ 26 | 27 | rc = stat(".", &sb); 28 | assert_return_code(rc, 0); 29 | 30 | #ifndef _MSC_VER 31 | assert_true(S_ISDIR(sb.st_mode)); 32 | #endif 33 | } 34 | 35 | int main(void) { 36 | const struct CMUnitTest tests[] = { 37 | cmocka_unit_test(test_assert_return_code), 38 | }; 39 | 40 | return cmocka_run_group_tests(tests, NULL, NULL); 41 | } 42 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | compiler: 8 | - clang 9 | - gcc 10 | 11 | addons: 12 | apt: 13 | update: true 14 | packages: 15 | - libusb-1.0-0-dev 16 | homebrew: 17 | packages: 18 | - libusb 19 | update: true 20 | 21 | script: 22 | - make 23 | 24 | # matrix: 25 | # include: 26 | # - os: linux 27 | # dist: xenial 28 | # sudo: required 29 | # - os: osx 30 | # osx_image: xcode6.4 31 | 32 | #before_deploy: 33 | # # Set up git user name and tag this commit 34 | # - git config --local user.name "audiohacked" 35 | # - git config --local user.email "audiohacked@gmail.com" 36 | # - git tag "$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)" 37 | #deploy: 38 | # provider: releases 39 | # api_key: 40 | # secure: YOUR_API_KEY_ENCRYPTED 41 | # file: "FILE TO UPLOAD" 42 | # skip_cleanup: true 43 | # on: 44 | # tags: true 45 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/key_value.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | typedef struct KeyValue { 18 | unsigned int key; 19 | const char* value; 20 | } KeyValue; 21 | 22 | void set_key_values(KeyValue * const new_key_values, 23 | const unsigned int new_number_of_key_values); 24 | 25 | KeyValue* find_item_by_value(const char * const value); 26 | 27 | void sort_items_by_key(void); 28 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_assert_macros_fail.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #ifdef HAVE_UNISTD_H 13 | #include 14 | #endif 15 | #ifdef HAVE_IO_H 16 | #include 17 | #endif 18 | #include 19 | 20 | /************************************** 21 | *** assert_return_code 22 | **************************************/ 23 | static void test_assert_return_code_fail(void **state) 24 | { 25 | int fd; 26 | 27 | (void)state; /* unused */ 28 | 29 | fd = open("this_file_doesnt_exist.cmocka", 0); 30 | assert_return_code(fd, errno); 31 | 32 | if (fd >= 0) { 33 | close(fd); 34 | } 35 | } 36 | 37 | int main(void) { 38 | const struct CMUnitTest tests[] = { 39 | cmocka_unit_test(test_assert_return_code_fail), 40 | }; 41 | 42 | return cmocka_run_group_tests(tests, NULL, NULL); 43 | } 44 | -------------------------------------------------------------------------------- /docs/CODING_STANDARDS.md: -------------------------------------------------------------------------------- 1 | # Coding Standards for OpenCorsairLink 2 | Many of these Coding Standards are not being followed currently. That is my (audiohacked's) fault. Eventually, OpenCorsairLink will conform to these Coding Standards. I, Audiohacked, reserve the right to change the standard after much deliberation. 3 | 4 | ## Basic Formatting 5 | ### Tabs 6 | Tabs should be soft-tabs and equivalent to 4 spaces. 7 | 8 | ### Line Wrap 9 | Line wrap limit should be at 100 columns, its ok to go over but no more than 120 columns total. 10 | 11 | ## Code Style 12 | ### Functions 13 | The return type should be of a type similar to `uint16_t` and be used strictly for error code returning. And variables given or that need to be returned should be put in the parameter list of the function. Function names should follow naming scheme as seen in other files within this project. 14 | 15 | ### Other formatting 16 | Curly Braces should fall on their own line and line up with their proper indentation. For and If statements must be accompanied by curly braces; no one-liner statements! 17 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_cmockery.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* A test case that does nothing and succeeds. */ 23 | static void null_test_success(void **state) { 24 | (void) state; /* unused */ 25 | } 26 | 27 | int main(void) { 28 | const UnitTest tests[] = { 29 | unit_test(null_test_success), 30 | }; 31 | return run_tests(tests); 32 | } 33 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmake/Modules/CheckCCompilerFlagSSP.cmake: -------------------------------------------------------------------------------- 1 | # - Check whether the C compiler supports a given flag in the 2 | # context of a stack checking compiler option. 3 | 4 | # CHECK_C_COMPILER_FLAG_SSP(FLAG VARIABLE) 5 | # 6 | # FLAG - the compiler flag 7 | # VARIABLE - variable to store the result 8 | # 9 | # This actually calls check_c_source_compiles. 10 | # See help for CheckCSourceCompiles for a listing of variables 11 | # that can modify the build. 12 | 13 | # Copyright (c) 2006, Alexander Neundorf, 14 | # 15 | # Redistribution and use is allowed according to the terms of the BSD license. 16 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 17 | 18 | 19 | include(CheckCSourceCompiles) 20 | 21 | function(CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT) 22 | set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") 23 | set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") 24 | check_c_source_compiles("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" ${_RESULT}) 25 | set(CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") 26 | endfunction(CHECK_C_COMPILER_FLAG_SSP) 27 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_skip.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* A test case that does check if an int is equal. */ 23 | static void test_check_skip(void **state) { 24 | (void)state; /* unused */ 25 | 26 | skip(); 27 | 28 | assert_true(0); 29 | } 30 | 31 | 32 | int main(void) { 33 | const struct CMUnitTest tests[] = { 34 | cmocka_unit_test(test_check_skip), 35 | }; 36 | 37 | return cmocka_run_group_tests(tests, NULL, NULL); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_group_fixtures.c: -------------------------------------------------------------------------------- 1 | /* Use the unit test allocators */ 2 | #define UNIT_TESTING 1 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static int group_setup(void **state) 10 | { 11 | int *answer = malloc(sizeof(int)); 12 | assert_non_null(answer); 13 | *answer = 42; 14 | 15 | *state = answer; 16 | return 0; 17 | } 18 | 19 | static int group_teardown(void **state) 20 | { 21 | int *answer = (int *)*state; 22 | 23 | free(answer); 24 | return 0; 25 | } 26 | 27 | static void test_value_equal(void **state) 28 | { 29 | int a = *((int *)*state); 30 | 31 | assert_int_equal(a, 42); 32 | } 33 | 34 | static void test_value_range(void **state) 35 | { 36 | int a = *((int *)*state); 37 | 38 | assert_in_range(a, 0, 100); 39 | } 40 | 41 | int main(void) { 42 | int prestate = 1337; 43 | const struct CMUnitTest tests[] = { 44 | cmocka_unit_test(test_value_equal), 45 | cmocka_unit_test(test_value_range), 46 | cmocka_unit_test_prestate(test_value_equal, &prestate), 47 | }; 48 | 49 | return cmocka_run_group_tests(tests, group_setup, group_teardown); 50 | } 51 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We love pull requests from everyone. By participating in this project, you 4 | agree to abide by the OpenCorsairLink [code of conduct]. 5 | 6 | [code of conduct]: https://github.com/audiohacked/OpenCorsairLink/blob/testing/.github/CODE_OF_CONDUCT.md 7 | 8 | Fork, then clone the repo: 9 | 10 | git clone git@github.com:your-username/OpenCorsairLink.git 11 | 12 | Make your change. And Run the style formatter (clang-format): 13 | 14 | make style 15 | 16 | Push to your fork and [submit a pull request][pr]. 17 | 18 | [pr]: https://github.com/audiohacked/OpenCorsairLink/compare/ 19 | 20 | At this point you're waiting on us. We like to at least comment on pull requests 21 | within three business days (and, typically, one business day). We may suggest 22 | some changes or improvements or alternatives. 23 | 24 | Some things that will increase the chance that your pull request is accepted: 25 | 26 | * Write tests. 27 | * Follow our [style guide][style]. 28 | * Write a [good commit message][commit]. 29 | 30 | [style]: https://github.com/audiohacked/OpenCorsairLink/tree/testing/docs/CODING_STANDARDS.md 31 | [commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 32 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/src/cmocka.def: -------------------------------------------------------------------------------- 1 | LIBRARY cmocka 2 | EXPORTS 3 | _assert_in_range 4 | _assert_in_set 5 | _assert_int_equal 6 | _assert_int_not_equal 7 | _assert_memory_equal 8 | _assert_memory_not_equal 9 | _assert_not_in_range 10 | _assert_not_in_set 11 | _assert_return_code 12 | _assert_string_equal 13 | _assert_string_not_equal 14 | _assert_true 15 | _check_expected 16 | _cmocka_run_group_tests 17 | _expect_any 18 | _expect_check 19 | _expect_function_call 20 | _expect_in_range 21 | _expect_in_set 22 | _expect_memory 23 | _expect_not_in_range 24 | _expect_not_in_set 25 | _expect_not_memory 26 | _expect_not_string 27 | _expect_not_value 28 | _expect_string 29 | _expect_value 30 | _fail 31 | _function_called 32 | _mock 33 | _run_test 34 | _run_tests 35 | _skip 36 | _test_calloc 37 | _test_free 38 | _test_malloc 39 | _test_realloc 40 | _will_return 41 | cmocka_set_message_output 42 | global_expect_assert_env 43 | global_expecting_assert 44 | global_last_failed_assert 45 | mock_assert 46 | print_error 47 | print_message 48 | vprint_error 49 | vprint_message 50 | -------------------------------------------------------------------------------- /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build}-{branch} 2 | 3 | branches: 4 | only: 5 | - master 6 | - testing 7 | except: 8 | - legacy 9 | 10 | image: 11 | - Ubuntu 12 | 13 | platform: 14 | - x86 15 | - x64 16 | - Any CPU 17 | 18 | configuration: 19 | - Debug 20 | - Release 21 | 22 | environment: 23 | APPVEYOR_YML_DISABLE_PS_LINUX: true 24 | 25 | install: 26 | - sh: sudo apt-get update 27 | - sh: sudo apt-get install -y libusb-1.0-0-dev 28 | 29 | #before_build: 30 | # - cmake -H. -BBuild -A%PLATFORM% 31 | 32 | build: off 33 | build_script: 34 | - make rebuild 35 | 36 | test: off 37 | #test_script: 38 | # - make test 39 | 40 | #deploy: 41 | # release: myproduct-v$(appveyor_build_version) 42 | # description: 'Release description' 43 | # provider: GitHub 44 | # auth_token: 45 | # secure: # your encrypted token from GitHub 46 | # artifact: /.*\.nupkg/ # upload all NuGet packages to release assets 47 | # draft: false 48 | # prerelease: false 49 | # on: 50 | # branch: 51 | # - master # release from master branch only 52 | # - testing 53 | # appveyor_repo_tag: true # deploy on tag push only 54 | -------------------------------------------------------------------------------- /include/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #ifndef _COMMON_H 20 | #define _COMMON_H 21 | 22 | #define STR_HELPER( x ) #x 23 | #define STR( x ) STR_HELPER( x ) 24 | 25 | // #define MAJOR 0 // Full Rewrite 26 | // #define MINOR 9 // Major API Change 27 | // #define PATCH_MAJOR 0 // Backward-compatible API Change 28 | // #define PATCH_MINOR 0 // Patch/Fix Change 29 | 30 | // #define VERSION "v" STR( MAJOR ) "." STR( MINOR ) "." STR( PATCH_MAJOR ) "." STR( PATCH_MINOR ) 31 | 32 | #endif /* _COMMON_H */ 33 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_setup_fail.c: -------------------------------------------------------------------------------- 1 | #define UNIT_TESTING 1 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static int setup_fail(void **state) { 9 | *state = NULL; 10 | 11 | /* We need to fail in setup */ 12 | return -1; 13 | } 14 | 15 | static void int_test_ignored(void **state) { 16 | /* should not be called */ 17 | assert_non_null(*state); 18 | } 19 | 20 | static int setup_ok(void **state) { 21 | int *answer; 22 | 23 | answer = malloc(sizeof(int)); 24 | if (answer == NULL) { 25 | return -1; 26 | } 27 | *answer = 42; 28 | 29 | *state = answer; 30 | 31 | return 0; 32 | } 33 | 34 | /* A test case that does check if an int is equal. */ 35 | static void int_test_success(void **state) { 36 | int *answer = *state; 37 | 38 | assert_int_equal(*answer, 42); 39 | } 40 | 41 | static int teardown(void **state) { 42 | free(*state); 43 | 44 | return 0; 45 | } 46 | 47 | int main(void) { 48 | const struct CMUnitTest tests[] = { 49 | cmocka_unit_test_setup_teardown(int_test_ignored, setup_fail, teardown), 50 | cmocka_unit_test_setup_teardown(int_test_success, setup_ok, teardown), 51 | }; 52 | 53 | return cmocka_run_group_tests(tests, NULL, NULL); 54 | } 55 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmake/Modules/DefineCMakeDefaults.cmake: -------------------------------------------------------------------------------- 1 | # Always include srcdir and builddir in include path 2 | # This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in 3 | # about every subdir 4 | # since cmake 2.4.0 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | # Put the include dirs which are in the source or build tree 8 | # before all other include dirs, so the headers in the sources 9 | # are prefered over the already installed ones 10 | # since cmake 2.4.1 11 | set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) 12 | 13 | # Use colored output 14 | # since cmake 2.4.0 15 | set(CMAKE_COLOR_MAKEFILE ON) 16 | 17 | # Define the generic version of the libraries here 18 | set(GENERIC_LIB_VERSION "0.1.0") 19 | set(GENERIC_LIB_SOVERSION "0") 20 | 21 | # Set the default build type to release with debug info 22 | if (NOT CMAKE_BUILD_TYPE) 23 | set(CMAKE_BUILD_TYPE RelWithDebInfo 24 | CACHE STRING 25 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." 26 | ) 27 | endif (NOT CMAKE_BUILD_TYPE) 28 | 29 | # Create the compile command database for clang by default 30 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 31 | 32 | if (APPLE) 33 | set(CMAKE_MACOSX_RPATH ON) 34 | set(CMAKE_SKIP_BUILD_RPATH FALSE) 35 | set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 36 | endif(APPLE) 37 | -------------------------------------------------------------------------------- /docs/add_device.md: -------------------------------------------------------------------------------- 1 | # Adding A new Device 2 | 3 | ``` 4 | { 5 | .vendor_id = 0x1b1c, 6 | .product_id = 0x0c04, 7 | .device_id = 0x3b, 8 | .name = "H80i", 9 | .read_endpoint = 0x01 | LIBUSB_ENDPOINT_IN, 10 | .write_endpoint = 0x00 | LIBUSB_ENDPOINT_OUT, 11 | .driver = &corsairlink_driver_coolit, 12 | .lowlevel = &corsairlink_lowlevel_coolit, 13 | .led_control_count = 1, 14 | .fan_control_count = 4, 15 | .pump_index = 5, 16 | }, 17 | ``` 18 | 19 | - `vendor_id` is used for the Corsair USB Vendor ID (0x1B1C). 20 | - `product_id` is used for the USB Product ID. 21 | - `device_id` is used for early CorsairLink CoolIT AIOs; Should use 0xFF if not supported by the device protocol. 22 | - `name` is the String for OpenCorsairLink, can be copied from USB device string. 23 | - `read_endpoint` the device endpoint for reading data from the device. 24 | - `write_endpoint` the device endpoint for commanding device. 25 | - `driver` the driver/protocol that the device uses. 26 | - `lowlevel` the low level protocol for the device. 27 | - `led_control_count` is the number of led channels. 28 | - `fan_control_count` is the number of fan channels. 29 | - `pump_index` is the array offset for pump channel, typically the pump channel will come after fan channels as they usually share the same command. 30 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/assert_module.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | #include "assert_module.h" 19 | 20 | /* If unit testing is enabled override assert with mock_assert(). */ 21 | #ifdef UNIT_TESTING 22 | extern void mock_assert(const int result, const char* const expression, 23 | const char * const file, const int line); 24 | #undef assert 25 | #define assert(expression) \ 26 | mock_assert(((expression) ? 1 : 0), #expression, __FILE__, __LINE__); 27 | #endif /* UNIT_TESTING */ 28 | 29 | void increment_value(int * const value) { 30 | assert(value); 31 | (*value) ++; 32 | } 33 | 34 | void decrement_value(int * const value) { 35 | if (value) { 36 | (*value) --; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /include/logic/scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #ifndef _SCAN_H 20 | #define _SCAN_H 21 | 22 | #include 23 | 24 | struct corsair_device_scan 25 | { 26 | struct corsair_device_info* device; 27 | 28 | /** libusb device structures */ 29 | struct libusb_device_handle* handle; 30 | }; 31 | 32 | extern struct corsair_device_scan scanlist[10]; 33 | 34 | int 35 | corsairlink_handle_close( struct libusb_device_handle* handle ); 36 | int 37 | corsairlink_close( libusb_context* context ); 38 | int 39 | corsairlink_device_scanner( libusb_context* context, int* _scanlist_count ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmake/Modules/AddCMockaTest.cmake: -------------------------------------------------------------------------------- 1 | # - ADD_CMOCKA_TEST(test_name test_source linklib1 ... linklibN) 2 | 3 | # Copyright (c) 2007 Daniel Gollub 4 | # Copyright (c) 2007-2010 Andreas Schneider 5 | # 6 | # Redistribution and use is allowed according to the terms of the BSD license. 7 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 8 | 9 | enable_testing() 10 | include(CTest) 11 | 12 | if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW) 13 | set(CMAKE_C_FLAGS_PROFILING "-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wwrite-strings -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Compiler Flags") 14 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags") 15 | set(CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags") 16 | set(CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags") 17 | endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW) 18 | 19 | function (ADD_CMOCKA_TEST _testName _testSource) 20 | add_executable(${_testName} ${_testSource}) 21 | target_link_libraries(${_testName} ${ARGN}) 22 | add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName}) 23 | endfunction (ADD_CMOCKA_TEST) 24 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/assert_macro.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "assert_macro.h" 19 | 20 | static const char* status_code_strings[] = { 21 | "Address not found", 22 | "Connection dropped", 23 | "Connection timed out", 24 | }; 25 | 26 | const char* get_status_code_string(const unsigned int status_code) { 27 | return status_code_strings[status_code]; 28 | } 29 | 30 | unsigned int string_to_status_code(const char* const status_code_string) { 31 | unsigned int i; 32 | for (i = 0; i < sizeof(status_code_strings) / 33 | sizeof(status_code_strings[0]); i++) { 34 | if (strcmp(status_code_strings[i], status_code_string) == 0) { 35 | return i; 36 | } 37 | } 38 | return ~0U; 39 | } 40 | -------------------------------------------------------------------------------- /include/unsupported.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #ifndef _UNSUPPORTED_H 20 | #define _UNSUPPORTED_H 21 | 22 | int 23 | corsairlink_unsupported_led( 24 | struct corsair_device_info* dev, 25 | struct libusb_device_handle* handle, 26 | struct led_control* ctrl ); 27 | 28 | int 29 | corsairlink_unsupported_fan( 30 | struct corsair_device_info* dev, 31 | struct libusb_device_handle* handle, 32 | struct fan_control* ctrl ); 33 | 34 | int 35 | corsairlink_unsupported_pump( 36 | struct corsair_device_info* dev, 37 | struct libusb_device_handle* handle, 38 | struct pump_control* ctrl ); 39 | 40 | #endif // _UNSUPPORTED_H 41 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmake/Modules/COPYING-CMAKE-SCRIPTS: -------------------------------------------------------------------------------- 1 | Redistribution and use in source and binary forms, with or without 2 | modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain the copyright 6 | notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | 3. The name of the author may not be used to endorse or promote products 11 | derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /include/lowlevel/commanderpro.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #ifndef _LOWLEVEL_PRO_H 20 | 21 | #include 22 | 23 | int 24 | corsairlink_commanderpro_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 25 | 26 | int 27 | corsairlink_commanderpro_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 28 | 29 | int 30 | corsairlink_commanderpro_write( 31 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 32 | 33 | int 34 | corsairlink_commanderpro_read( 35 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 36 | 37 | #define _LOWLEVEL_PRO_H 38 | #endif 39 | -------------------------------------------------------------------------------- /drivers/dongle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "driver.h" 20 | 21 | #include "device.h" 22 | #include "lowlevel/rmi.h" 23 | #include "logic/print.h" 24 | #include "protocol/rmi.h" 25 | 26 | struct corsair_lowlevel_driver corsairlink_lowlevel_dongle = { 27 | .init = corsairlink_rmi_init, 28 | .deinit = corsairlink_rmi_deinit, 29 | .read = corsairlink_rmi_read, 30 | .write = corsairlink_rmi_write, 31 | }; 32 | 33 | struct corsair_device_driver corsairlink_driver_dongle = { 34 | .name = corsairlink_rmi_name, 35 | .vendor = corsairlink_rmi_vendor, 36 | .product = corsairlink_rmi_product, 37 | .device_id = corsairlink_rmi_device_id, 38 | .fw_version = corsairlink_rmi_firmware_id, 39 | }; 40 | -------------------------------------------------------------------------------- /include/lowlevel/asetek.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file lowlevel/asetek.h 20 | * \brief Lowlevel Routines for Asetek 21 | */ 22 | #ifndef _LOWLEVEL_ASETEK_H 23 | #define _LOWLEVEL_ASETEK_H 24 | 25 | #include 26 | 27 | int 28 | corsairlink_asetek_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 29 | 30 | int 31 | corsairlink_asetek_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 32 | 33 | int 34 | corsairlink_asetek_write( 35 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 36 | 37 | int 38 | corsairlink_asetek_read( 39 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/lowlevel/rmi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file lowlevel/rmi.h 20 | * \brief Lowlevel Routines for RMi Series of Power Supplies 21 | */ 22 | #ifndef _LOWLEVEL_RMI_H 23 | #define _LOWLEVEL_RMI_H 24 | 25 | #include 26 | 27 | int 28 | corsairlink_rmi_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 29 | 30 | int 31 | corsairlink_rmi_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 32 | 33 | int 34 | corsairlink_rmi_write( 35 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 36 | 37 | int 38 | corsairlink_rmi_read( 39 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/lowlevel/coolit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file lowlevel/coolit.h 20 | * \brief Lowlevel Routines for CoolIT USB HID based devices 21 | */ 22 | #ifndef _LOWLEVEL_COOLIT_H 23 | #define _LOWLEVEL_COOLIT_H 24 | 25 | #include 26 | 27 | int 28 | corsairlink_coolit_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 29 | 30 | int 31 | corsairlink_coolit_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 32 | 33 | int 34 | corsairlink_coolit_write( 35 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 36 | 37 | int 38 | corsairlink_coolit_read( 39 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/lowlevel/platinum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2019 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file lowlevel/platinum.h 20 | * \brief Lowlevel Routines for CoolIT USB HID based devices 21 | */ 22 | #ifndef _LOWLEVEL_PLATINUM_H 23 | #define _LOWLEVEL_PLATINUM_H 24 | 25 | #include 26 | 27 | int 28 | corsairlink_platinum_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 29 | 30 | int 31 | corsairlink_platinum_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ); 32 | 33 | int 34 | corsairlink_platinum_write( 35 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 36 | 37 | int 38 | corsairlink_platinum_read( 39 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/database.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | typedef struct DatabaseConnection DatabaseConnection; 17 | 18 | /* Function that takes an SQL query string and sets results to an array of 19 | * pointers with the result of the query. The value returned specifies the 20 | * number of items in the returned array of results. The returned array of 21 | * results are statically allocated and should not be deallocated using free() 22 | */ 23 | typedef unsigned int (*QueryDatabase)( 24 | DatabaseConnection* const connection, const char * const query_string, 25 | void *** const results); 26 | 27 | /* Connection to a database. */ 28 | struct DatabaseConnection { 29 | const char *url; 30 | unsigned int port; 31 | QueryDatabase query_database; 32 | }; 33 | 34 | /* Connect to a database. */ 35 | DatabaseConnection* connect_to_database(const char * const url, 36 | const unsigned int port); 37 | 38 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmake/Modules/FindNSIS.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find NSIS 2 | # Once done this will define 3 | # 4 | # NSIS_FOUND - system has NSIS 5 | # NSIS_MAKE - NSIS creator executable 6 | # 7 | #============================================================================= 8 | # Copyright (c) 2010-2013 Andreas Schneider 9 | # 10 | # Distributed under the OSI-approved BSD License (the "License"); 11 | # see accompanying file Copyright.txt for details. 12 | # 13 | # This software is distributed WITHOUT ANY WARRANTY; without even the 14 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | # See the License for more information. 16 | #============================================================================= 17 | # 18 | 19 | if (WIN32) 20 | set(_NSIS_ROOT_HINTS 21 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS;Default]") 22 | 23 | set(_NSIS_ROOT_PATHS 24 | $ENV{PROGRAMFILES}/NSIS) 25 | 26 | find_path(NSIS_ROOT_PATH 27 | NAMES 28 | Include/Library.nsh 29 | HINTS 30 | ${_NSIS_ROOT_HINTS} 31 | PATHS 32 | ${_NSIS_ROOT_PATHS} 33 | ) 34 | mark_as_advanced(NSIS_ROOT_PATH) 35 | endif (WIN32) 36 | 37 | find_program(NSIS_MAKE 38 | NAMES 39 | makensis 40 | PATHS 41 | ${NSIS_ROOT_PATH} 42 | ) 43 | 44 | include(FindPackageHandleStandardArgs) 45 | find_package_handle_standard_args(NSIS DEFAULT_MSG NSIS_MAKE) 46 | 47 | if (NSIS_MAKE) 48 | set(NSIS_FOUND TRUE) 49 | endif (NSIS_MAKE) 50 | 51 | mark_as_advanced(NSIS_MAKE) 52 | -------------------------------------------------------------------------------- /drivers/unsupported.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "driver.h" 20 | #include "logic/print.h" 21 | 22 | int 23 | corsairlink_unsupported_led( 24 | struct corsair_device_info* dev, struct libusb_device_handle* handle, struct led_control* ctrl ) 25 | { 26 | msg_info( "Unsupported LED Function\n" ); 27 | return 0; 28 | } 29 | 30 | int 31 | corsairlink_unsupported_fan( 32 | struct corsair_device_info* dev, struct libusb_device_handle* handle, struct fan_control* ctrl ) 33 | { 34 | msg_info( "Unsupported Fan Function\n" ); 35 | return 0; 36 | } 37 | 38 | int 39 | corsairlink_unsupported_pump( 40 | struct corsair_device_info* dev, 41 | struct libusb_device_handle* handle, 42 | struct pump_control* ctrl ) 43 | { 44 | msg_info( "Unsupported Pump Function\n" ); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/chef_wrap/chef.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 (c) Andreas Schneider 3 | * Jakub Hrozek 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "chef.h" 28 | 29 | 30 | /* This is the real chef, just not implemented yet, currently it always 31 | * returns ENOSYS 32 | */ 33 | int chef_cook(const char *order, char **dish_out) 34 | { 35 | if (order == NULL || dish_out == NULL) return EINVAL; 36 | 37 | return -ENOSYS; 38 | } 39 | 40 | /* Print chef return codes as string */ 41 | const char *chef_strerror(int error) 42 | { 43 | switch (error) { 44 | case 0: 45 | return "Success"; 46 | case -1: 47 | return "Unknown dish"; 48 | case -2: 49 | return "Not enough ingredients for the dish"; 50 | } 51 | 52 | return "Unknown error!"; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /include/device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #ifndef _DEVICE_H 20 | #define _DEVICE_H 21 | 22 | #include 23 | 24 | struct corsair_device_info 25 | { 26 | /** device info */ 27 | char name[64]; 28 | uint16_t vendor_id; 29 | uint16_t product_id; 30 | uint16_t device_id; 31 | 32 | /** device endpoints */ 33 | uint8_t read_endpoint; 34 | uint8_t write_endpoint; 35 | 36 | /** device control info */ 37 | struct corsair_device_driver* driver; 38 | struct corsair_lowlevel_driver* lowlevel; 39 | 40 | uint8_t led_control_count; // used mostly with COOLIT driver 41 | uint8_t fan_control_count; // used with COOLIT driver 42 | uint8_t temperature_control_count; 43 | uint8_t pump_index; // used with COOLIT driver 44 | }; 45 | 46 | extern struct corsair_device_info corsairlink_devices[]; 47 | extern uint8_t corsairlink_device_list_count; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /protocol/rmi/fan.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "driver.h" 20 | #include 21 | 22 | int corsairlink_rmi_fan_rpm( 23 | struct corsair_device_info* dev, struct libusb_device_handle* handle, uint16_t rpm ) 24 | { 25 | int rr; 26 | uint8_t response[64]; 27 | uint8_t commands[64]; 28 | memset( response, 0, sizeof( response ) ); 29 | memset( commands, 0, sizeof( commands ) ); 30 | 31 | commands[0] = 0x03; 32 | commands[1] = 0x90; 33 | commands[2] = 0x00; 34 | commands[3] = 0x00; 35 | 36 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 37 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 38 | 39 | memcpy( rpm, response + 2, 2 ); 40 | 41 | msg_debug2( 42 | "%02X %02X %02X %02X %02X %02X\n", response[0], response[1], response[2], response[3], 43 | response[4], response[5] ); 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /include/logic/print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #ifndef _PRINT_H 20 | #define _PRINT_H 21 | 22 | #include 23 | 24 | enum msglevel 25 | { 26 | MSG_ERROR = 1, 27 | MSG_WARN = 2, 28 | MSG_MACHINE = 3, 29 | MSG_INFO = 4, 30 | MSG_DEBUG = 5, 31 | MSG_DEBUG2 = 6, 32 | MSG_SPEW = 7, 33 | }; 34 | 35 | extern uint8_t verbose; 36 | 37 | int 38 | print( enum msglevel level, const char* fmt, ... ) __attribute__( ( format( printf, 2, 3 ) ) ); 39 | int 40 | dump_packet( uint8_t* packet, int size ); 41 | 42 | #define msg_err( ... ) print( MSG_ERROR, __VA_ARGS__ ) 43 | #define msg_warn( ... ) print( MSG_WARN, __VA_ARGS__ ) 44 | #define msg_info( ... ) print( MSG_INFO, __VA_ARGS__ ) 45 | #define msg_debug( ... ) print( MSG_DEBUG, __VA_ARGS__ ) 46 | #define msg_debug2( ... ) print( MSG_DEBUG2, __VA_ARGS__ ) 47 | #define msg_spew( ... ) print( MSG_SPEW, __VA_ARGS__ ) 48 | 49 | #define msg_machine( ... ) print( MSG_MACHINE, __VA_ARGS__ ) 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_basics.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* Use the unit test allocators */ 18 | #define UNIT_TESTING 1 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | static int setup(void **state) { 26 | int *answer = malloc(sizeof(int)); 27 | 28 | assert_non_null(answer); 29 | *answer = 42; 30 | 31 | *state = answer; 32 | 33 | return 0; 34 | } 35 | 36 | static int teardown(void **state) { 37 | free(*state); 38 | 39 | return 0; 40 | } 41 | 42 | /* A test case that does nothing and succeeds. */ 43 | static void null_test_success(void **state) { 44 | (void) state; 45 | } 46 | 47 | /* A test case that does check if an int is equal. */ 48 | static void int_test_success(void **state) { 49 | int *answer = *state; 50 | 51 | assert_int_equal(*answer, 42); 52 | } 53 | 54 | 55 | int main(void) { 56 | const struct CMUnitTest tests[] = { 57 | cmocka_unit_test(null_test_success), 58 | cmocka_unit_test_setup_teardown(int_test_success, setup, teardown), 59 | }; 60 | 61 | return cmocka_run_group_tests(tests, NULL, NULL); 62 | } 63 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/assert_macro_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "assert_macro.h" 22 | 23 | /* This test will fail since the string returned by get_status_code_string(0) 24 | * doesn't match "Connection timed out". */ 25 | static void get_status_code_string_test(void **state) { 26 | (void) state; /* unused */ 27 | 28 | assert_string_equal(get_status_code_string(0), "Address not found"); 29 | assert_string_equal(get_status_code_string(1), "Connection timed out"); 30 | } 31 | 32 | /* This test will fail since the status code of "Connection timed out" isn't 1 */ 33 | static void string_to_status_code_test(void **state) { 34 | (void) state; /* unused */ 35 | 36 | assert_int_equal(string_to_status_code("Address not found"), 0); 37 | assert_int_equal(string_to_status_code("Connection timed out"), 1); 38 | } 39 | 40 | int main(void) { 41 | const struct CMUnitTest tests[] = { 42 | cmocka_unit_test(get_status_code_string_test), 43 | cmocka_unit_test(string_to_status_code_test), 44 | }; 45 | return cmocka_run_group_tests(tests, NULL, NULL); 46 | } 47 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_returns.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | int mock_function(void); 12 | void mock_function_call_times(size_t times, int expectedValue); 13 | 14 | int mock_function(void) 15 | { 16 | return (int) mock(); 17 | } 18 | 19 | void mock_function_call_times(size_t times, int expectedValue) 20 | { 21 | size_t i; 22 | for (i = 0u; i < times; ++i) 23 | { 24 | assert_int_equal(expectedValue, mock_function()); 25 | } 26 | } 27 | 28 | static void test_will_return_maybe_for_no_calls(void **state) 29 | { 30 | (void) state; 31 | 32 | will_return_maybe(mock_function, 32); 33 | } 34 | 35 | static void test_will_return_maybe_for_one_mock_call(void **state) 36 | { 37 | int value; 38 | 39 | (void) state; 40 | 41 | value = rand(); 42 | will_return_maybe(mock_function, value); 43 | mock_function_call_times(1u, value); 44 | } 45 | 46 | static void test_will_return_maybe_for_more_than_one_call(void **state) 47 | { 48 | int value; 49 | size_t numberOfCalls; 50 | (void)state; 51 | 52 | value = rand(); 53 | numberOfCalls = (size_t) ((rand()) % 20 + 2); 54 | will_return_maybe(mock_function, value); 55 | mock_function_call_times(numberOfCalls, value); 56 | } 57 | 58 | int main(int argc, char **argv) { 59 | const struct CMUnitTest alloc_tests[] = { 60 | cmocka_unit_test(test_will_return_maybe_for_no_calls) 61 | ,cmocka_unit_test(test_will_return_maybe_for_one_mock_call) 62 | ,cmocka_unit_test(test_will_return_maybe_for_more_than_one_call) 63 | }; 64 | 65 | (void)argc; 66 | (void)argv; 67 | 68 | return cmocka_run_group_tests(alloc_tests, NULL, NULL); 69 | } 70 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/allocate_module_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | extern void leak_memory(void); 22 | extern void buffer_overflow(void); 23 | extern void buffer_underflow(void); 24 | 25 | /* Test case that fails as leak_memory() leaks a dynamically allocated block. */ 26 | static void leak_memory_test(void **state) { 27 | (void) state; /* unused */ 28 | 29 | leak_memory(); 30 | } 31 | 32 | /* Test case that fails as buffer_overflow() corrupts an allocated block. */ 33 | static void buffer_overflow_test(void **state) { 34 | (void) state; /* unused */ 35 | 36 | buffer_overflow(); 37 | } 38 | 39 | /* Test case that fails as buffer_underflow() corrupts an allocated block. */ 40 | static void buffer_underflow_test(void **state) { 41 | (void) state; /* unused */ 42 | 43 | buffer_underflow(); 44 | } 45 | 46 | int main(void) { 47 | const struct CMUnitTest tests[] = { 48 | cmocka_unit_test(leak_memory_test), 49 | cmocka_unit_test(buffer_overflow_test), 50 | cmocka_unit_test(buffer_underflow_test), 51 | }; 52 | return cmocka_run_group_tests(tests, NULL, NULL); 53 | } 54 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/key_value.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | 20 | #include "key_value.h" 21 | 22 | static KeyValue *key_values = NULL; 23 | static unsigned int number_of_key_values = 0; 24 | 25 | void set_key_values(KeyValue * const new_key_values, 26 | const unsigned int new_number_of_key_values) { 27 | key_values = new_key_values; 28 | number_of_key_values = new_number_of_key_values; 29 | } 30 | 31 | /* Compare two key members of KeyValue structures. */ 32 | static int key_value_compare_keys(const void *a, const void *b) { 33 | return (int)((KeyValue*)a)->key - (int)((KeyValue*)b)->key; 34 | } 35 | 36 | /* Search an array of key value pairs for the item with the specified value. */ 37 | KeyValue* find_item_by_value(const char * const value) { 38 | unsigned int i; 39 | for (i = 0; i < number_of_key_values; i++) { 40 | if (strcmp(key_values[i].value, value) == 0) { 41 | return &key_values[i]; 42 | } 43 | } 44 | return NULL; 45 | } 46 | 47 | /* Sort an array of key value pairs by key. */ 48 | void sort_items_by_key(void) { 49 | qsort(key_values, number_of_key_values, sizeof(*key_values), 50 | key_value_compare_keys); 51 | } 52 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/assert_module_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "assert_module.h" 22 | 23 | extern void increment_value(int * const value); 24 | 25 | /* This test case will fail but the assert is caught by run_tests() and the 26 | * next test is executed. */ 27 | static void increment_value_fail(void **state) { 28 | (void) state; 29 | 30 | increment_value(NULL); 31 | } 32 | 33 | /* This test case succeeds since increment_value() asserts on the NULL 34 | * pointer. */ 35 | static void increment_value_assert(void **state) { 36 | (void) state; 37 | 38 | expect_assert_failure(increment_value(NULL)); 39 | } 40 | 41 | /* This test case fails since decrement_value() doesn't assert on a NULL 42 | * pointer. */ 43 | static void decrement_value_fail(void **state) { 44 | (void) state; 45 | 46 | expect_assert_failure(decrement_value(NULL)); 47 | } 48 | 49 | int main(void) { 50 | const struct CMUnitTest tests[] = { 51 | cmocka_unit_test(increment_value_fail), 52 | cmocka_unit_test(increment_value_assert), 53 | cmocka_unit_test(decrement_value_fail), 54 | }; 55 | return cmocka_run_group_tests(tests, NULL, NULL); 56 | } 57 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Proposed changes 2 | 3 | Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. 4 | 5 | ## Types of changes 6 | 7 | What types of changes does your code introduce to OpenCorsairLink? 8 | _Put an `x` in the boxes that apply_ 9 | 10 | - [ ] Bugfix (non-breaking change which fixes an issue) 11 | - [ ] New feature (non-breaking change which adds functionality) 12 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 13 | 14 | ## Checklist 15 | 16 | _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._ 17 | 18 | - [ ] I have read the [CONTRIBUTING](https://github.com/audiohacked/OpenCorsairLink/blob/testing/CONTRIBUTING.md) doc 19 | - [ ] Make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). Don't request your master! 20 | - [ ] Make sure you are making a pull request against the **testing branch** (left side). Also you should start *your branch* off *our testing*. 21 | - [ ] Lint and unit tests pass locally with my changes 22 | - [ ] I have added tests that prove my fix is effective or that my feature works 23 | - [ ] I have added necessary documentation (if appropriate) 24 | - [ ] Any dependent changes have been merged and published in downstream modules 25 | - [ ] Check the commit's or even all commits' message styles matches our requested structure. 26 | 27 | ## Further comments 28 | 29 | If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... 30 | 31 | ### Thanks for contributing! 32 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/allocate_module.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifdef HAVE_CONFIG_H 17 | #include "config.h" 18 | #endif 19 | #ifdef HAVE_MALLOC_H 20 | #include 21 | #endif 22 | #include 23 | #include 24 | 25 | #ifdef UNIT_TESTING 26 | extern void* _test_malloc(const size_t size, const char* file, const int line); 27 | extern void* _test_calloc(const size_t number_of_elements, const size_t size, 28 | const char* file, const int line); 29 | extern void _test_free(void* const ptr, const char* file, const int line); 30 | 31 | #define malloc(size) _test_malloc(size, __FILE__, __LINE__) 32 | #define calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__) 33 | #define free(ptr) _test_free(ptr, __FILE__, __LINE__) 34 | #endif // UNIT_TESTING 35 | 36 | void leak_memory(void); 37 | void buffer_overflow(void); 38 | void buffer_underflow(void); 39 | 40 | void leak_memory(void) { 41 | int * const temporary = (int*)malloc(sizeof(int)); 42 | *temporary = 0; 43 | } 44 | 45 | void buffer_overflow(void) { 46 | char * const memory = (char*)malloc(sizeof(int)); 47 | memory[sizeof(int)] = '!'; 48 | free(memory); 49 | } 50 | 51 | void buffer_underflow(void) { 52 | char * const memory = (char*)malloc(sizeof(int)); 53 | memory[-1] = '!'; 54 | free(memory); 55 | } 56 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/customer_database.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #ifdef _WIN32 20 | #define snprintf _snprintf 21 | #endif /* _WIN32 */ 22 | 23 | DatabaseConnection* connect_to_customer_database(void); 24 | unsigned int get_customer_id_by_name( 25 | DatabaseConnection * const connection, 26 | const char * const customer_name); 27 | 28 | /* Connect to the database containing customer information. */ 29 | DatabaseConnection* connect_to_customer_database(void) { 30 | return connect_to_database("customers.abcd.org", 321); 31 | } 32 | 33 | /* Find the ID of a customer by his/her name returning a value > 0 if 34 | * successful, 0 otherwise. */ 35 | unsigned int get_customer_id_by_name( 36 | DatabaseConnection * const connection, 37 | const char * const customer_name) { 38 | char query_string[256]; 39 | int number_of_results; 40 | void **results; 41 | snprintf(query_string, sizeof(query_string), 42 | "SELECT ID FROM CUSTOMERS WHERE NAME = %s", customer_name); 43 | number_of_results = connection->query_database(connection, query_string, 44 | &results); 45 | 46 | if (number_of_results != 1) { 47 | return -1; 48 | } 49 | 50 | return (unsigned int)*((int *)results); 51 | } 52 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_returns_fail.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | int mock_function(void); 12 | void mock_function_call_times(size_t times, int expectedValue); 13 | 14 | int mock_function(void) 15 | { 16 | return (int) mock(); 17 | } 18 | 19 | void mock_function_call_times(size_t times, int expectedValue) 20 | { 21 | size_t i; 22 | for (i = 0u; i < times; ++i) 23 | { 24 | assert_int_equal(expectedValue, mock_function()); 25 | } 26 | } 27 | 28 | static void test_will_return_fails_for_no_calls(void **state) 29 | { 30 | (void) state; 31 | 32 | will_return(mock_function, 32); 33 | } 34 | 35 | static void test_will_return_count_fails_for_unreturned_items(void **state) 36 | { 37 | int value; 38 | size_t numberOfCalls; 39 | 40 | (void) state; 41 | 42 | value = rand(); 43 | numberOfCalls = (size_t) ((rand()) % 20 + 2); 44 | 45 | will_return_count(mock_function, value, numberOfCalls); 46 | mock_function_call_times(numberOfCalls - 1u, value); 47 | } 48 | 49 | static void test_will_return_always_fails_for_no_calls(void **state) 50 | { 51 | int value; 52 | 53 | (void) state; 54 | 55 | value = rand(); 56 | 57 | will_return_always(mock_function, value); 58 | } 59 | 60 | static int teardown(void **state) { 61 | free(*state); 62 | 63 | return 0; 64 | } 65 | 66 | int main(int argc, char **argv) { 67 | const struct CMUnitTest alloc_tests[] = { 68 | cmocka_unit_test_teardown(test_will_return_fails_for_no_calls, teardown) 69 | ,cmocka_unit_test_teardown(test_will_return_count_fails_for_unreturned_items, teardown) 70 | ,cmocka_unit_test_teardown(test_will_return_always_fails_for_no_calls, teardown) 71 | }; 72 | 73 | (void)argc; 74 | (void)argv; 75 | 76 | return cmocka_run_group_tests(alloc_tests, NULL, NULL); 77 | } 78 | -------------------------------------------------------------------------------- /lowlevel/commanderpro.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "lowlevel/commanderpro.h" 20 | 21 | #include 22 | #include 23 | 24 | #define TIMEOUT_DEFAULT 1000 /*!< TIMEOUT_DEFAULT */ 25 | 26 | int 27 | corsairlink_commanderpro_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ) 28 | { 29 | return 0; 30 | } 31 | 32 | int 33 | corsairlink_commanderpro_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ) 34 | { 35 | return 0; 36 | } 37 | 38 | int 39 | corsairlink_commanderpro_write( 40 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ) 41 | { 42 | int bytes_transferred; 43 | int rr; 44 | 45 | rr = libusb_interrupt_transfer( 46 | dev_handle, endpoint, data, length, &bytes_transferred, TIMEOUT_DEFAULT ); 47 | 48 | return rr; 49 | } 50 | 51 | int 52 | corsairlink_commanderpro_read( 53 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ) 54 | { 55 | int bytes_transferred; 56 | int rr; 57 | 58 | rr = libusb_interrupt_transfer( 59 | dev_handle, endpoint, data, length, &bytes_transferred, TIMEOUT_DEFAULT ); 60 | 61 | return rr; 62 | } 63 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_groups.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 David Schneider 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* Use the unit test allocators */ 18 | #define UNIT_TESTING 1 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | static int setup(void **state) { 26 | int *answer = malloc(sizeof(int)); 27 | 28 | assert_non_null(answer); 29 | *answer = 42; 30 | 31 | *state = answer; 32 | 33 | return 0; 34 | } 35 | 36 | static int teardown(void **state) { 37 | free(*state); 38 | 39 | return 0; 40 | } 41 | 42 | /* A test case that does nothing and succeeds. */ 43 | static void null_test_success(void **state) { 44 | (void) state; 45 | } 46 | 47 | /* A test case that does check if an int is equal. */ 48 | static void int_test_success(void **state) { 49 | int *answer = *state; 50 | 51 | assert_int_equal(*answer, 42); 52 | } 53 | 54 | 55 | int main(void) { 56 | const struct CMUnitTest test_group1[] = { 57 | cmocka_unit_test(null_test_success), 58 | }; 59 | 60 | const struct CMUnitTest test_group2[] = { 61 | cmocka_unit_test_setup_teardown(int_test_success, setup, teardown), 62 | }; 63 | 64 | int result = 0; 65 | result += cmocka_run_group_tests(test_group1, NULL, NULL); 66 | result += cmocka_run_group_tests(test_group2, NULL, NULL); 67 | 68 | return result; 69 | } 70 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_fixtures.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | static int setup_only(void **state) 9 | { 10 | *state = malloc(1); 11 | 12 | return 0; 13 | } 14 | 15 | static int teardown_only(void **state) 16 | { 17 | free(*state); 18 | 19 | return 0; 20 | } 21 | 22 | static void malloc_setup_test(void **state) 23 | { 24 | assert_non_null(*state); 25 | free(*state); 26 | } 27 | 28 | static void malloc_teardown_test(void **state) 29 | { 30 | *state = malloc(1); 31 | assert_non_null(*state); 32 | } 33 | 34 | static int prestate_setup(void **state) 35 | { 36 | int *val = (int *)*state, *a; 37 | 38 | a = malloc(sizeof(int)); 39 | *a = *val + 1; 40 | *state = a; 41 | 42 | return 0; 43 | } 44 | 45 | static int prestate_teardown(void **state) 46 | { 47 | free(*state); 48 | 49 | return 0; 50 | } 51 | 52 | static void prestate_setup_test(void **state) 53 | { 54 | int *a = (int *)*state; 55 | 56 | assert_non_null(a); 57 | assert_int_equal(*a, 43); 58 | } 59 | 60 | static void prestate_test(void **state) 61 | { 62 | int *a = (int *)*state; 63 | 64 | assert_non_null(a); 65 | assert_int_equal(*a, 42); 66 | } 67 | 68 | int main(void) { 69 | int prestate = 42; 70 | const struct CMUnitTest tests[] = { 71 | cmocka_unit_test_setup(malloc_setup_test, setup_only), 72 | cmocka_unit_test_setup(malloc_setup_test, setup_only), 73 | cmocka_unit_test_teardown(malloc_teardown_test, teardown_only), 74 | cmocka_unit_test_teardown(malloc_teardown_test, teardown_only), 75 | cmocka_unit_test_teardown(malloc_teardown_test, teardown_only), 76 | cmocka_unit_test_teardown(malloc_teardown_test, teardown_only), 77 | cmocka_unit_test_prestate(prestate_test, &prestate), 78 | cmocka_unit_test_prestate_setup_teardown(prestate_setup_test, prestate_setup, prestate_teardown, &prestate), 79 | }; 80 | 81 | return cmocka_run_group_tests(tests, NULL, NULL); 82 | } 83 | -------------------------------------------------------------------------------- /OLD.md: -------------------------------------------------------------------------------- 1 | # OpenCorsairLink [![Build Status](https://travis-ci.com/audiohacked/OpenCorsairLink.svg?branch=testing)](https://travis-ci.com/audiohacked/OpenCorsairLink) 2 | 3 | OpenCorsairLink is a status & control utility that interacts with CorsairLink products. 4 | 5 | ### Disclaimer 6 | > __DISCLAIMER__: OpenCorsairLink is not an official Corsair product. It is licensed under the GNU General Public License (version 2) in the hope that it will be useful, but with NO WARRANTY of any kind. Corsair and Corsair Link are trademarks or registered trademarks of Corsair Components, Inc. The trademark holders are not affiliated with the maker of this product and do not endorse this product. 7 | 8 | ## Installation 9 | ### Requirements 10 | * libusb-1.0 11 | * pkg-config 12 | 13 | ``` 14 | $ make 15 | $ sudo make install 16 | ``` 17 | 18 | ## Usage 19 | Since the program needs direct hardware access you should run this with 'sudo' or as root. 20 | 21 | ``` 22 | $ sudo ./OpenCorsairLink.elf 23 | $ sudo ./OpenCorsairLink.elf --help 24 | $ sudo ./OpenCorsairLink.elf --device 0 25 | $ sudo ./OpenCorsairLink.elf --device 0 --led channel=0,mode=0,colors=00FF00 26 | $ sudo ./OpenCorsairLink.elf --device 0 --fan channel=0,mode=5 27 | $ sudo ./OpenCorsairLink.elf --device 0 --pump mode=5 28 | ``` 29 | 30 | ## Development 31 | ### Branches 32 | - master: Stable or Release Version 33 | - testing: Testing or Release Canidate 34 | - feature\/\*: Cutting Edge Features (Use at your own risk) 35 | 36 | ## Contributing 37 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 38 | 39 | Please make sure to update tests as appropriate. 40 | 41 | ## Contact 42 | 43 | Maintainers reserve the rights to modify and remove issues, pull requests and comments therein, that are denunciating, off-topic, harmful, hateful and overall inappropriate. 44 | Please be appreciative, humble and kind to each other. 45 | 46 | * [GitHub Issues](https://github.com/audiohacked/OpenCorsairLink/issues) 47 | 48 | ## License 49 | [GPLv2](https://choosealicense.com/licenses/gpl-2.0/) 50 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/include/cmocka_pbc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Luis Pabon, Jr. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * Programming by Contract is a programming methodology 19 | * which binds the caller and the function called to a 20 | * contract. The contract is represented using Hoare Triple: 21 | * {P} C {Q} 22 | * where {P} is the precondition before executing command C, 23 | * and {Q} is the postcondition. 24 | * 25 | * See also: 26 | * http://en.wikipedia.org/wiki/Design_by_contract 27 | * http://en.wikipedia.org/wiki/Hoare_logic 28 | * http://dlang.org/dbc.html 29 | */ 30 | #ifndef CMOCKA_PBC_H_ 31 | #define CMOCKA_PBC_H_ 32 | 33 | #if defined(UNIT_TESTING) || defined (DEBUG) 34 | 35 | #include 36 | 37 | /* 38 | * Checks caller responsibility against contract 39 | */ 40 | #define REQUIRE(cond) assert(cond) 41 | 42 | /* 43 | * Checks function reponsability against contract. 44 | */ 45 | #define ENSURE(cond) assert(cond) 46 | 47 | /* 48 | * While REQUIRE and ENSURE apply to functions, INVARIANT 49 | * applies to classes/structs. It ensures that intances 50 | * of the class/struct are consistent. In other words, 51 | * that the instance has not been corrupted. 52 | */ 53 | #define INVARIANT(invariant_fnc) do{ (invariant_fnc) } while (0); 54 | 55 | #else 56 | #define REQUIRE(cond) do { } while (0); 57 | #define ENSURE(cond) do { } while (0); 58 | #define INVARIANT(invariant_fnc) do{ } while (0); 59 | 60 | #endif /* defined(UNIT_TESTING) || defined (DEBUG) */ 61 | #endif /* CMOCKA_PBC_H_ */ 62 | 63 | -------------------------------------------------------------------------------- /docs/device_dumps/H100i_RGB_Pro_XT.txt: -------------------------------------------------------------------------------- 1 | 2 | Bus 003 Device 006: ID 1b1c:0c20 Corsair 3 | Device Descriptor: 4 | bLength 18 5 | bDescriptorType 1 6 | bcdUSB 2.00 7 | bDeviceClass 0 8 | bDeviceSubClass 0 9 | bDeviceProtocol 0 10 | bMaxPacketSize0 64 11 | idVendor 0x1b1c Corsair 12 | idProduct 0x0c20 13 | bcdDevice 1.00 14 | iManufacturer 1 Corsair Inc. 15 | iProduct 2 H100iRGBPROXT 16 | iSerial 0 17 | bNumConfigurations 1 18 | Configuration Descriptor: 19 | bLength 9 20 | bDescriptorType 2 21 | wTotalLength 0x0022 22 | bNumInterfaces 1 23 | bConfigurationValue 1 24 | iConfiguration 0 25 | bmAttributes 0xc0 26 | Self Powered 27 | MaxPower 100mA 28 | Interface Descriptor: 29 | bLength 9 30 | bDescriptorType 4 31 | bInterfaceNumber 0 32 | bAlternateSetting 0 33 | bNumEndpoints 1 34 | bInterfaceClass 3 Human Interface Device 35 | bInterfaceSubClass 0 36 | bInterfaceProtocol 1 Keyboard 37 | iInterface 0 38 | HID Device Descriptor: 39 | bLength 9 40 | bDescriptorType 33 41 | bcdHID 1.11 42 | bCountryCode 0 Not supported 43 | bNumDescriptors 1 44 | bDescriptorType 34 Report 45 | wDescriptorLength 27 46 | Report Descriptors: 47 | ** UNAVAILABLE ** 48 | Endpoint Descriptor: 49 | bLength 7 50 | bDescriptorType 5 51 | bEndpointAddress 0x81 EP 1 IN 52 | bmAttributes 3 53 | Transfer Type Interrupt 54 | Synch Type None 55 | Usage Type Data 56 | wMaxPacketSize 0x0040 1x 64 bytes 57 | bInterval 7 58 | Device Status: 0x0001 59 | Self Powered 60 | -------------------------------------------------------------------------------- /protocol/platinum/crc.c: -------------------------------------------------------------------------------- 1 | // crc8.c 2 | 3 | #include "protocol/crc.h" 4 | 5 | static const uint8_t CRC_TABLE[256] = { 6 | 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 7 | 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, 8 | 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 9 | 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, 10 | 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 11 | 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, 12 | 0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 13 | 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD, 14 | 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 15 | 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA, 16 | 0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 17 | 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A, 18 | 0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 19 | 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A, 20 | 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 21 | 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A, 22 | 0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 23 | 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4, 24 | 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 25 | 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4, 26 | 0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 27 | 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44, 28 | 0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 29 | 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34, 30 | 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 31 | 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63, 32 | 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 33 | 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, 34 | 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 35 | 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, 36 | 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 37 | 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3 38 | }; 39 | 40 | uint8_t crc8ccitt(const void * data, size_t size) { 41 | uint8_t val = 0; 42 | 43 | uint8_t * pos = (uint8_t *) data; 44 | uint8_t * end = pos + size; 45 | 46 | while (pos < end) { 47 | val = CRC_TABLE[val ^ *pos]; 48 | pos++; 49 | } 50 | 51 | return val; 52 | } 53 | -------------------------------------------------------------------------------- /docs/device_dumps/H80iGT.txt: -------------------------------------------------------------------------------- 1 | Bus 003 Device 003: ID 1b1c:0c02 Corsair 2 | Device Descriptor: 3 | bLength 18 4 | bDescriptorType 1 5 | bcdUSB 1.10 6 | bDeviceClass 0 7 | bDeviceSubClass 0 8 | bDeviceProtocol 0 9 | bMaxPacketSize0 64 10 | idVendor 0x1b1c Corsair 11 | idProduct 0x0c02 12 | bcdDevice 1.00 13 | iManufacturer 1 Corsair Components, Inc. 14 | iProduct 2 H80iGT Cooler 15 | iSerial 3 7289_1.0 16 | bNumConfigurations 1 17 | Configuration Descriptor: 18 | bLength 9 19 | bDescriptorType 2 20 | wTotalLength 0x0020 21 | bNumInterfaces 1 22 | bConfigurationValue 1 23 | iConfiguration 0 24 | bmAttributes 0x80 25 | (Bus Powered) 26 | MaxPower 50mA 27 | Interface Descriptor: 28 | bLength 9 29 | bDescriptorType 4 30 | bInterfaceNumber 0 31 | bAlternateSetting 0 32 | bNumEndpoints 2 33 | bInterfaceClass 255 Vendor Specific Class 34 | bInterfaceSubClass 0 35 | bInterfaceProtocol 0 36 | iInterface 0 37 | Endpoint Descriptor: 38 | bLength 7 39 | bDescriptorType 5 40 | bEndpointAddress 0x02 EP 2 OUT 41 | bmAttributes 2 42 | Transfer Type Bulk 43 | Synch Type None 44 | Usage Type Data 45 | wMaxPacketSize 0x0040 1x 64 bytes 46 | bInterval 0 47 | Endpoint Descriptor: 48 | bLength 7 49 | bDescriptorType 5 50 | bEndpointAddress 0x82 EP 2 IN 51 | bmAttributes 2 52 | Transfer Type Bulk 53 | Synch Type None 54 | Usage Type Data 55 | wMaxPacketSize 0x0040 1x 64 bytes 56 | bInterval 0 57 | Device Status: 0x0000 58 | (Bus Powered) 59 | -------------------------------------------------------------------------------- /docs/device_dumps/H150i_Pro.txt: -------------------------------------------------------------------------------- 1 | Bus 001 Device 005: ID 1b1c:0c12 Corsair 2 | Device Descriptor: 3 | bLength 18 4 | bDescriptorType 1 5 | bcdUSB 2.00 6 | bDeviceClass 0 (Defined at Interface level) 7 | bDeviceSubClass 0 8 | bDeviceProtocol 0 9 | bMaxPacketSize0 64 10 | idVendor 0x1b1c Corsair 11 | idProduct 0x0c12 12 | bcdDevice 1.00 13 | iManufacturer 1 Corsair 14 | iProduct 2 H150i Platinum 15 | iSerial 3 7289_2.0 16 | bNumConfigurations 1 17 | Configuration Descriptor: 18 | bLength 9 19 | bDescriptorType 2 20 | wTotalLength 32 21 | bNumInterfaces 1 22 | bConfigurationValue 1 23 | iConfiguration 0 24 | bmAttributes 0xc0 25 | Self Powered 26 | MaxPower 64mA 27 | Interface Descriptor: 28 | bLength 9 29 | bDescriptorType 4 30 | bInterfaceNumber 0 31 | bAlternateSetting 0 32 | bNumEndpoints 2 33 | bInterfaceClass 255 Vendor Specific Class 34 | bInterfaceSubClass 0 35 | bInterfaceProtocol 0 36 | iInterface 0 37 | Endpoint Descriptor: 38 | bLength 7 39 | bDescriptorType 5 40 | bEndpointAddress 0x81 EP 1 IN 41 | bmAttributes 2 42 | Transfer Type Bulk 43 | Synch Type None 44 | Usage Type Data 45 | wMaxPacketSize 0x0040 1x 64 bytes 46 | bInterval 0 47 | Endpoint Descriptor: 48 | bLength 7 49 | bDescriptorType 5 50 | bEndpointAddress 0x01 EP 1 OUT 51 | bmAttributes 2 52 | Transfer Type Bulk 53 | Synch Type None 54 | Usage Type Data 55 | wMaxPacketSize 0x0040 1x 64 bytes 56 | bInterval 0 57 | Device Status: 0x0001 58 | Self Powered 59 | -------------------------------------------------------------------------------- /drivers/rmi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "driver.h" 20 | 21 | // #include "device.h" 22 | #include "lowlevel/rmi.h" 23 | #include "logic/print.h" 24 | #include "protocol/rmi.h" 25 | 26 | struct corsair_lowlevel_driver corsairlink_lowlevel_rmi = { 27 | .init = corsairlink_rmi_init, 28 | .deinit = corsairlink_rmi_deinit, 29 | .read = corsairlink_rmi_read, 30 | .write = corsairlink_rmi_write, 31 | }; 32 | 33 | struct corsair_device_driver corsairlink_driver_rmi = { 34 | .name = corsairlink_rmi_name, 35 | .vendor = corsairlink_rmi_vendor, 36 | .product = corsairlink_rmi_product, 37 | .device_id = corsairlink_rmi_device_id, 38 | .fw_version = corsairlink_rmi_firmware_id, 39 | .temperature = 40 | { 41 | .read = corsairlink_rmi_temperature, 42 | }, 43 | .power = 44 | { 45 | .supply_voltage = corsairlink_rmi_power_supply_voltage, 46 | .total_wattage = corsairlink_rmi_power_total_wattage, 47 | .sensor_select = corsairlink_rmi_sensor_select, 48 | .voltage = corsairlink_rmi_output_volts, 49 | .amperage = corsairlink_rmi_output_amps, 50 | .wattage = corsairlink_rmi_output_watts, 51 | }, 52 | .psu_time = 53 | { 54 | .powered = corsairlink_rmi_time_powered, 55 | .uptime = corsairlink_rmi_time_uptime, 56 | }, 57 | }; 58 | -------------------------------------------------------------------------------- /docs/device_dumps/H115i_Pro.txt: -------------------------------------------------------------------------------- 1 | 2 | Bus 002 Device 025: ID 1b1c:0c13 Corsair 3 | Device Descriptor: 4 | bLength 18 5 | bDescriptorType 1 6 | bcdUSB 2.00 7 | bDeviceClass 0 (Defined at Interface level) 8 | bDeviceSubClass 0 9 | bDeviceProtocol 0 10 | bMaxPacketSize0 64 11 | idVendor 0x1b1c Corsair 12 | idProduct 0x0c13 13 | bcdDevice 1.00 14 | iManufacturer 1 Corsair 15 | iProduct 2 H115i Platinum 16 | iSerial 3 7289_2.0 17 | bNumConfigurations 1 18 | Configuration Descriptor: 19 | bLength 9 20 | bDescriptorType 2 21 | wTotalLength 32 22 | bNumInterfaces 1 23 | bConfigurationValue 1 24 | iConfiguration 0 25 | bmAttributes 0xc0 26 | Self Powered 27 | MaxPower 64mA 28 | Interface Descriptor: 29 | bLength 9 30 | bDescriptorType 4 31 | bInterfaceNumber 0 32 | bAlternateSetting 0 33 | bNumEndpoints 2 34 | bInterfaceClass 255 Vendor Specific Class 35 | bInterfaceSubClass 0 36 | bInterfaceProtocol 0 37 | iInterface 0 38 | Endpoint Descriptor: 39 | bLength 7 40 | bDescriptorType 5 41 | bEndpointAddress 0x81 EP 1 IN 42 | bmAttributes 2 43 | Transfer Type Bulk 44 | Synch Type None 45 | Usage Type Data 46 | wMaxPacketSize 0x0040 1x 64 bytes 47 | bInterval 0 48 | Endpoint Descriptor: 49 | bLength 7 50 | bDescriptorType 5 51 | bEndpointAddress 0x01 EP 1 OUT 52 | bmAttributes 2 53 | Transfer Type Bulk 54 | Synch Type None 55 | Usage Type Data 56 | wMaxPacketSize 0x0040 1x 64 bytes 57 | bInterval 0 58 | Device Status: 0x0001 59 | Self Powered 60 | -------------------------------------------------------------------------------- /logic/print.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "logic/print.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | uint8_t verbose = MSG_INFO; 27 | 28 | int 29 | print( enum msglevel level, const char* fmt, ... ) 30 | { 31 | va_list ap; 32 | int ret = 0; 33 | FILE* output_type = stdout; 34 | 35 | if ( level < MSG_INFO ) 36 | output_type = stderr; 37 | 38 | if ( level == MSG_MACHINE ) 39 | { 40 | if ( verbose == MSG_MACHINE ) 41 | { 42 | va_start( ap, fmt ); 43 | ret = vfprintf( output_type, fmt, ap ); 44 | va_end( ap ); 45 | fflush( output_type ); 46 | } 47 | } 48 | else if ( level <= verbose ) 49 | { 50 | va_start( ap, fmt ); 51 | ret = vfprintf( output_type, fmt, ap ); 52 | va_end( ap ); 53 | if ( level != MSG_SPEW ) 54 | fflush( output_type ); 55 | } 56 | 57 | return 0; 58 | } 59 | 60 | int 61 | dump_packet( uint8_t* packet, int size ) 62 | { 63 | msg_debug2( "\n---- Packet dump: -----------------------------" ); 64 | for ( int8_t j = 0; j < size; j++ ) 65 | { 66 | if ( j % 16 == 0 ) 67 | msg_debug2( "\n" ); 68 | msg_debug2( "%02x ", packet[j] ); 69 | } 70 | msg_debug2( "\n-----------------------------------------------\n" ); 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /docs/device_dumps/H100i_asetek.txt: -------------------------------------------------------------------------------- 1 | 2 | Bus 002 Device 002: ID 1b1c:0c09 Corsair 3 | Device Descriptor: 4 | bLength 18 5 | bDescriptorType 1 6 | bcdUSB 1.10 7 | bDeviceClass 0 (Defined at Interface level) 8 | bDeviceSubClass 0 9 | bDeviceProtocol 0 10 | bMaxPacketSize0 64 11 | idVendor 0x1b1c Corsair 12 | idProduct 0x0c09 13 | bcdDevice 1.00 14 | iManufacturer 1 Corsair Components, Inc. 15 | iProduct 2 H100i v2 16 | iSerial 3 7289_2.0 17 | bNumConfigurations 1 18 | Configuration Descriptor: 19 | bLength 9 20 | bDescriptorType 2 21 | wTotalLength 32 22 | bNumInterfaces 1 23 | bConfigurationValue 1 24 | iConfiguration 0 25 | bmAttributes 0x80 26 | (Bus Powered) 27 | MaxPower 50mA 28 | Interface Descriptor: 29 | bLength 9 30 | bDescriptorType 4 31 | bInterfaceNumber 0 32 | bAlternateSetting 0 33 | bNumEndpoints 2 34 | bInterfaceClass 255 Vendor Specific Class 35 | bInterfaceSubClass 0 36 | bInterfaceProtocol 0 37 | iInterface 0 38 | Endpoint Descriptor: 39 | bLength 7 40 | bDescriptorType 5 41 | bEndpointAddress 0x02 EP 2 OUT 42 | bmAttributes 2 43 | Transfer Type Bulk 44 | Synch Type None 45 | Usage Type Data 46 | wMaxPacketSize 0x0040 1x 64 bytes 47 | bInterval 0 48 | Endpoint Descriptor: 49 | bLength 7 50 | bDescriptorType 5 51 | bEndpointAddress 0x82 EP 2 IN 52 | bmAttributes 2 53 | Transfer Type Bulk 54 | Synch Type None 55 | Usage Type Data 56 | wMaxPacketSize 0x0040 1x 64 bytes 57 | bInterval 0 58 | Device Status: 0x0000 59 | (Bus Powered) 60 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_alloc.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | static void torture_test_malloc(void **state) 14 | { 15 | char *str; 16 | size_t str_len; 17 | size_t len; 18 | 19 | (void)state; /* unsused */ 20 | 21 | str_len = 12; 22 | str = (char *)test_malloc(str_len); 23 | assert_non_null(str); 24 | 25 | len = snprintf(str, str_len, "test string"); 26 | assert_int_equal(len, 11); 27 | 28 | len = strlen(str); 29 | assert_int_equal(len, 11); 30 | 31 | test_free(str); 32 | } 33 | 34 | static void torture_test_realloc(void **state) 35 | { 36 | char *str; 37 | char *tmp; 38 | size_t str_len; 39 | size_t len; 40 | 41 | (void)state; /* unsused */ 42 | 43 | str_len = 16; 44 | str = (char *)test_malloc(str_len); 45 | assert_non_null(str); 46 | 47 | len = snprintf(str, str_len, "test string 123"); 48 | assert_int_equal(len, 15); 49 | 50 | len = strlen(str); 51 | assert_int_equal(len, 15); 52 | 53 | str_len = 20; 54 | tmp = test_realloc(str, str_len); 55 | assert_non_null(tmp); 56 | 57 | str = tmp; 58 | len = strlen(str); 59 | assert_string_equal(tmp, "test string 123"); 60 | 61 | snprintf(str + len, str_len - len, "4567"); 62 | assert_string_equal(tmp, "test string 1234567"); 63 | 64 | test_free(str); 65 | } 66 | 67 | static void torture_test_realloc_set0(void **state) 68 | { 69 | char *str; 70 | size_t str_len; 71 | 72 | (void)state; /* unsused */ 73 | 74 | str_len = 16; 75 | str = (char *)test_malloc(str_len); 76 | assert_non_null(str); 77 | 78 | /* realloc(ptr, 0) is like a free() */ 79 | str = (char *)test_realloc(str, 0); 80 | assert_null(str); 81 | } 82 | 83 | int main(void) { 84 | const struct CMUnitTest alloc_tests[] = { 85 | cmocka_unit_test(torture_test_malloc), 86 | cmocka_unit_test(torture_test_realloc), 87 | cmocka_unit_test(torture_test_realloc_set0), 88 | }; 89 | 90 | return cmocka_run_group_tests(alloc_tests, NULL, NULL); 91 | } 92 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/CPackConfig.cmake: -------------------------------------------------------------------------------- 1 | # For help take a look at: 2 | # http://www.cmake.org/Wiki/CMake:CPackConfiguration 3 | 4 | ### general settings 5 | set(CPACK_PACKAGE_NAME ${APPLICATION_NAME}) 6 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Unit testing framework for C with mock objects") 7 | set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README") 8 | set(CPACK_PACKAGE_VENDOR "Andreas Schneider") 9 | set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) 10 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING") 11 | 12 | 13 | ### versions 14 | set(CPACK_PACKAGE_VERSION_MAJOR "${APPLICATION_VERSION_MAJOR}") 15 | set(CPACK_PACKAGE_VERSION_MINOR "${APPLICATION_VERSION_MINOR}") 16 | set(CPACK_PACKAGE_VERSION_PATCH "${APPLICATION_VERSION_PATCH}") 17 | set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") 18 | 19 | 20 | ### source generator 21 | set(CPACK_SOURCE_GENERATOR "TGZ") 22 | set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/obj*;tags;cscope.*;.ycm_extra_conf.pyc") 23 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") 24 | 25 | if (WIN32) 26 | set(CPACK_GENERATOR "ZIP") 27 | 28 | ### nsis generator 29 | find_package(NSIS) 30 | if (NSIS_MAKE) 31 | set(CPACK_GENERATOR "${CPACK_GENERATOR};NSIS") 32 | set(CPACK_NSIS_DISPLAY_NAME "CMocka") 33 | set(CPACK_NSIS_COMPRESSOR "/SOLID zlib") 34 | set(CPACK_NSIS_MENU_LINKS "http://cmocka.org/" "cmocka homepage") 35 | endif (NSIS_MAKE) 36 | endif (WIN32) 37 | 38 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "cmocka") 39 | 40 | set(CPACK_PACKAGE_FILE_NAME ${APPLICATION_NAME}-${CPACK_PACKAGE_VERSION}) 41 | 42 | set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") 43 | set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers") 44 | set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION 45 | "Libraries used to build programs which use cmocka") 46 | set(CPACK_COMPONENT_HEADERS_DESCRIPTION 47 | "C/C++ header files for use with cmocka") 48 | set(CPACK_COMPONENT_HEADERS_DEPENDS libraries) 49 | #set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime") 50 | set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") 51 | set(CPACK_COMPONENT_HEADERS_GROUP "Development") 52 | 53 | include(CPack) 54 | -------------------------------------------------------------------------------- /protocol/commanderpro/power.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file protocol/commanderpro/power.c 20 | * \brief Power Routines for Commander Pro 21 | */ 22 | #include "device.h" 23 | #include "driver.h" 24 | #include "lowlevel/commanderpro.h" 25 | #include "logic/print.h" 26 | #include "protocol/commanderpro.h" 27 | #include "logic/options.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | int 37 | corsairlink_commanderpro_voltage( 38 | struct corsair_device_info* dev, 39 | struct libusb_device_handle* handle, 40 | uint8_t sensor_index, 41 | double* voltage ) 42 | { 43 | int rr; 44 | uint8_t response[16]; 45 | uint8_t commands[64]; 46 | memset( response, 0, sizeof( response ) ); 47 | memset( commands, 0, sizeof( commands ) ); 48 | 49 | commands[0] = 0x12; 50 | commands[1] = (uint8_t) sensor_index; 51 | 52 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 53 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 16 ); 54 | 55 | //msg_debug2( "%02X %02X %02X\n", response[0], response[1], response[2] ); 56 | 57 | uint16_t data = ( response[1] << 8 ) + response[2]; 58 | *( voltage ) = (double)data / 1000; 59 | 60 | // snprintf(voltage, voltage_str_len, "%2.3f V", volts); 61 | 62 | dump_packet( commands, sizeof( commands ) ); 63 | dump_packet( response, sizeof( response ) ); 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /protocol/asetek/temperature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "lowlevel/asetek.h" 22 | #include "logic/print.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | int 32 | corsairlink_asetek_tempsensorscount( 33 | struct corsair_device_info* dev, 34 | struct libusb_device_handle* handle, 35 | uint8_t* temperature_sensors_count ) 36 | { 37 | int rr = 0; 38 | // not defined - set default value of 3 39 | *( temperature_sensors_count ) = 3; 40 | return rr; 41 | } 42 | 43 | int 44 | corsairlink_asetek_temperature( 45 | struct corsair_device_info* dev, 46 | struct libusb_device_handle* handle, 47 | uint8_t selector, 48 | double* temperature ) 49 | { 50 | int rr; 51 | uint8_t response[64]; 52 | uint8_t commands[64]; 53 | memset( response, 0, sizeof( response ) ); 54 | memset( commands, 0, sizeof( commands ) ); 55 | 56 | commands[0] = 0x20; 57 | 58 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 32 ); 59 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 32 ); 60 | 61 | msg_debug2( "%02X %02X\n", response[10], response[14] ); 62 | 63 | //*(temperature) = (response[10]<<8) + response[14]; 64 | *( temperature ) = (double)response[10] + ( (double)response[14] / 10 ); 65 | // snprintf(temperature, temperature_str_len, "%5.2f C", celsius); 66 | 67 | return rr; 68 | } 69 | -------------------------------------------------------------------------------- /docs/device_dumps/H110i.txt: -------------------------------------------------------------------------------- 1 | Bus 001 Device 004: ID 1b1c:0c04 Corsair Link Cooling Node 2 | Device Descriptor: 3 | bLength 18 4 | bDescriptorType 1 5 | bcdUSB 2.00 6 | bDeviceClass 0 7 | bDeviceSubClass 0 8 | bDeviceProtocol 0 9 | bMaxPacketSize0 64 10 | idVendor 0x1b1c Corsair 11 | idProduct 0x0c04 Link Cooling Node 12 | bcdDevice 2.00 13 | iManufacturer 1 Corsair Memory, Inc. 14 | iProduct 2 Integrated USB Bridge 15 | iSerial 0 16 | bNumConfigurations 1 17 | Configuration Descriptor: 18 | bLength 9 19 | bDescriptorType 2 20 | wTotalLength 0x0022 21 | bNumInterfaces 1 22 | bConfigurationValue 1 23 | iConfiguration 0 24 | bmAttributes 0x80 25 | (Bus Powered) 26 | MaxPower 100mA 27 | Interface Descriptor: 28 | bLength 9 29 | bDescriptorType 4 30 | bInterfaceNumber 0 31 | bAlternateSetting 0 32 | bNumEndpoints 1 33 | bInterfaceClass 3 Human Interface Device 34 | bInterfaceSubClass 0 35 | bInterfaceProtocol 0 36 | iInterface 0 37 | HID Device Descriptor: 38 | bLength 9 39 | bDescriptorType 33 40 | bcdHID 1.11 41 | bCountryCode 0 Not supported 42 | bNumDescriptors 1 43 | bDescriptorType 34 Report 44 | wDescriptorLength 37 45 | Report Descriptors: 46 | ** UNAVAILABLE ** 47 | Endpoint Descriptor: 48 | bLength 7 49 | bDescriptorType 5 50 | bEndpointAddress 0x81 EP 1 IN 51 | bmAttributes 3 52 | Transfer Type Interrupt 53 | Synch Type None 54 | Usage Type Data 55 | wMaxPacketSize 0x0040 1x 64 bytes 56 | bInterval 1 57 | can't get device qualifier: Resource temporarily unavailable 58 | can't get debug descriptor: Resource temporarily unavailable 59 | Device Status: 0x0080 60 | (Bus Powered) -------------------------------------------------------------------------------- /protocol/rmi/temperature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file protocol/rmi/temperature.c 20 | * \brief Temperature Routines for RMi Series of Power Supplies 21 | */ 22 | #include "device.h" 23 | #include "driver.h" 24 | #include "lowlevel/rmi.h" 25 | #include "logic/print.h" 26 | #include "protocol/rmi.h" 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | int 36 | corsairlink_rmi_temperature( 37 | struct corsair_device_info* dev, 38 | struct libusb_device_handle* handle, 39 | uint8_t probe, 40 | double* temperature ) 41 | { 42 | int rr; 43 | uint8_t response[64]; 44 | uint8_t commands[64]; 45 | memset( response, 0, sizeof( response ) ); 46 | memset( commands, 0, sizeof( commands ) ); 47 | 48 | commands[0] = 0x03; 49 | commands[1] = 0x8D + probe; 50 | commands[2] = 0x00; 51 | commands[3] = 0x00; 52 | 53 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 54 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 55 | 56 | msg_debug2( 57 | "%02X %02X %02X %02X %02X %02X\n", response[0], response[1], response[2], response[3], 58 | response[4], response[5] ); 59 | 60 | // memcpy(temperature, response+2, 2); 61 | uint16_t temp = ( response[2] << 8 ) + response[3]; 62 | *( temperature ) = (double)temp / 1000; 63 | // snprintf(temperature, temperature_str_len, "%5.2f C", temp_double); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /protocol/asetekpro/temperature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "lowlevel/asetek.h" 22 | #include "logic/print.h" 23 | #include "protocol/asetekpro.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | int 33 | corsairlink_asetekpro_tempsensorscount( 34 | struct corsair_device_info* dev, 35 | struct libusb_device_handle* handle, 36 | uint8_t* temperature_sensors_count ) 37 | { 38 | int rr = 0; 39 | // not defined - set default value of 3 40 | *( temperature_sensors_count ) = 1; 41 | return rr; 42 | } 43 | 44 | int 45 | corsairlink_asetekpro_temperature( 46 | struct corsair_device_info* dev, 47 | struct libusb_device_handle* handle, 48 | uint8_t selector, 49 | double* temperature ) 50 | { 51 | int rr; 52 | uint8_t response[64]; 53 | uint8_t commands[64]; 54 | memset( response, 0, sizeof( response ) ); 55 | memset( commands, 0, sizeof( commands ) ); 56 | 57 | commands[0] = AsetekProReadTemp; 58 | 59 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 1 ); 60 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 6 ); 61 | 62 | msg_debug2( 63 | "%02X %02X %02X %02X %02X\n", response[0], response[1], response[2], response[3], 64 | response[4] ); 65 | 66 | if ( response[0] != 0xa9 || response[1] != 0x12 || response[2] != 0x34 ) 67 | { 68 | msg_debug2( "Bad Response\n" ); 69 | } 70 | 71 | *( temperature ) = (double)response[3] + ( (double)response[4] / 10 ); 72 | // snprintf(temperature, temperature_str_len, "%d.%d C", response[3], 73 | // response[4]); 74 | 75 | return rr; 76 | } 77 | -------------------------------------------------------------------------------- /docs/device_dumps/CommanderPro.txt: -------------------------------------------------------------------------------- 1 | 2 | Bus 002 Device 023: ID 1b1c:0c10 Corsair 3 | Device Descriptor: 4 | bLength 18 5 | bDescriptorType 1 6 | bcdUSB 2.00 7 | bDeviceClass 0 (Defined at Interface level) 8 | bDeviceSubClass 0 9 | bDeviceProtocol 0 10 | bMaxPacketSize0 8 11 | idVendor 0x1b1c Corsair 12 | idProduct 0x0c10 13 | bcdDevice 0.07 14 | iManufacturer 1 Corsair 15 | iProduct 6 Commander PRO 16 | iSerial 128 0205018464101D28 17 | bNumConfigurations 1 18 | Configuration Descriptor: 19 | bLength 9 20 | bDescriptorType 2 21 | wTotalLength 41 22 | bNumInterfaces 1 23 | bConfigurationValue 1 24 | iConfiguration 0 25 | bmAttributes 0xc0 26 | Self Powered 27 | MaxPower 0mA 28 | Interface Descriptor: 29 | bLength 9 30 | bDescriptorType 4 31 | bInterfaceNumber 0 32 | bAlternateSetting 0 33 | bNumEndpoints 2 34 | bInterfaceClass 3 Human Interface Device 35 | bInterfaceSubClass 0 No Subclass 36 | bInterfaceProtocol 0 None 37 | iInterface 0 38 | HID Device Descriptor: 39 | bLength 9 40 | bDescriptorType 33 41 | bcdHID 1.11 42 | bCountryCode 0 Not supported 43 | bNumDescriptors 1 44 | bDescriptorType 34 Report 45 | wDescriptorLength 27 46 | Report Descriptors: 47 | ** UNAVAILABLE ** 48 | Endpoint Descriptor: 49 | bLength 7 50 | bDescriptorType 5 51 | bEndpointAddress 0x81 EP 1 IN 52 | bmAttributes 3 53 | Transfer Type Interrupt 54 | Synch Type None 55 | Usage Type Data 56 | wMaxPacketSize 0x0010 1x 16 bytes 57 | bInterval 1 58 | Endpoint Descriptor: 59 | bLength 7 60 | bDescriptorType 5 61 | bEndpointAddress 0x02 EP 2 OUT 62 | bmAttributes 3 63 | Transfer Type Interrupt 64 | Synch Type None 65 | Usage Type Data 66 | wMaxPacketSize 0x0040 1x 64 bytes 67 | bInterval 1 68 | Device Status: 0x0001 69 | Self Powered 70 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/key_value_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "key_value.h" 23 | 24 | static KeyValue key_values[] = { 25 | { 10, "this" }, 26 | { 52, "test" }, 27 | { 20, "a" }, 28 | { 13, "is" }, 29 | }; 30 | 31 | static int create_key_values(void **state) { 32 | KeyValue * const items = (KeyValue*)test_malloc(sizeof(key_values)); 33 | memcpy(items, key_values, sizeof(key_values)); 34 | *state = (void*)items; 35 | set_key_values(items, sizeof(key_values) / sizeof(key_values[0])); 36 | 37 | return 0; 38 | } 39 | 40 | static int destroy_key_values(void **state) { 41 | test_free(*state); 42 | set_key_values(NULL, 0); 43 | 44 | return 0; 45 | } 46 | 47 | static void test_find_item_by_value(void **state) { 48 | unsigned int i; 49 | 50 | (void) state; /* unused */ 51 | 52 | for (i = 0; i < sizeof(key_values) / sizeof(key_values[0]); i++) { 53 | KeyValue * const found = find_item_by_value(key_values[i].value); 54 | assert_true(found != NULL); 55 | assert_int_equal(found->key, key_values[i].key); 56 | assert_string_equal(found->value, key_values[i].value); 57 | } 58 | } 59 | 60 | static void test_sort_items_by_key(void **state) { 61 | unsigned int i; 62 | KeyValue * const kv = *state; 63 | sort_items_by_key(); 64 | for (i = 1; i < sizeof(key_values) / sizeof(key_values[0]); i++) { 65 | assert_true(kv[i - 1].key < kv[i].key); 66 | } 67 | } 68 | 69 | int main(void) { 70 | const struct CMUnitTest tests[] = { 71 | cmocka_unit_test_setup_teardown(test_find_item_by_value, 72 | create_key_values, destroy_key_values), 73 | cmocka_unit_test_setup_teardown(test_sort_items_by_key, 74 | create_key_values, destroy_key_values), 75 | }; 76 | return cmocka_run_group_tests(tests, NULL, NULL); 77 | } 78 | -------------------------------------------------------------------------------- /protocol/rmi/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file protocol/rmi/time.c 20 | * \brief Uptime Routines for RMi Series of Power Supplies 21 | */ 22 | #include "device.h" 23 | #include "driver.h" 24 | #include "lowlevel/rmi.h" 25 | #include "protocol/rmi.h" 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | int 35 | corsairlink_rmi_time_powered( 36 | struct corsair_device_info* dev, struct libusb_device_handle* handle, uint32_t* powered ) 37 | { 38 | int rr; 39 | uint8_t response[64]; 40 | uint8_t commands[64]; 41 | memset( response, 0, sizeof( response ) ); 42 | memset( commands, 0, sizeof( commands ) ); 43 | 44 | commands[0] = 0x03; 45 | commands[1] = 0xd1; 46 | commands[2] = 0x00; 47 | commands[3] = 0x00; 48 | commands[4] = 0x00; 49 | commands[5] = 0x00; 50 | 51 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 52 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 53 | 54 | memcpy( powered, response + 2, 4 ); 55 | 56 | return 0; 57 | } 58 | 59 | int 60 | corsairlink_rmi_time_uptime( 61 | struct corsair_device_info* dev, struct libusb_device_handle* handle, uint32_t* uptime ) 62 | { 63 | int rr; 64 | uint8_t response[64]; 65 | uint8_t commands[64]; 66 | memset( response, 0, sizeof( response ) ); 67 | memset( commands, 0, sizeof( commands ) ); 68 | 69 | commands[0] = 0x03; 70 | commands[1] = 0xd2; 71 | commands[2] = 0x00; 72 | commands[3] = 0x00; 73 | commands[4] = 0x00; 74 | commands[5] = 0x00; 75 | 76 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 77 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 78 | 79 | memcpy( uptime, response + 2, 4 ); 80 | 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_ordering_fail.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static void mock_test_a_called(void) 10 | { 11 | function_called(); 12 | } 13 | 14 | static void mock_test_b_called(void) 15 | { 16 | function_called(); 17 | } 18 | 19 | static void mock_test_c_called(void) 20 | { 21 | function_called(); 22 | } 23 | 24 | static void test_does_fail_for_unexpected_call(void **state) 25 | { 26 | (void)state; 27 | expect_function_call(mock_test_a_called); 28 | expect_function_call(mock_test_a_called); 29 | 30 | mock_test_a_called(); 31 | mock_test_a_called(); 32 | mock_test_a_called(); 33 | } 34 | 35 | static void test_does_fail_for_unmade_expected_call(void **state) 36 | { 37 | (void)state; 38 | expect_function_call(mock_test_a_called); 39 | expect_function_call(mock_test_a_called); 40 | 41 | mock_test_a_called(); 42 | } 43 | 44 | static void test_ordering_fails_out_of_order(void **state) 45 | { 46 | (void)state; 47 | expect_function_call(mock_test_a_called); 48 | expect_function_call(mock_test_b_called); 49 | expect_function_call(mock_test_a_called); 50 | 51 | mock_test_b_called(); 52 | } 53 | 54 | static void test_ordering_fails_out_of_order_for_at_least_once_calls(void **state) 55 | { 56 | (void)state; 57 | expect_function_call_any(mock_test_a_called); 58 | ignore_function_calls(mock_test_b_called); 59 | 60 | mock_test_b_called(); 61 | mock_test_c_called(); 62 | } 63 | 64 | /* Primarily used to test error message */ 65 | static void test_fails_out_of_order_if_no_calls_found_on_any(void **state) 66 | { 67 | (void)state; 68 | expect_function_call_any(mock_test_a_called); 69 | ignore_function_calls(mock_test_b_called); 70 | 71 | mock_test_a_called(); 72 | mock_test_c_called(); 73 | } 74 | 75 | static void test_fails_if_zero_count_used(void **state) 76 | { 77 | (void)state; 78 | expect_function_calls(mock_test_a_called, 0); 79 | 80 | mock_test_a_called(); 81 | } 82 | 83 | int main(void) { 84 | const struct CMUnitTest tests[] = { 85 | cmocka_unit_test(test_does_fail_for_unexpected_call) 86 | ,cmocka_unit_test(test_does_fail_for_unmade_expected_call) 87 | ,cmocka_unit_test(test_does_fail_for_unmade_expected_call) 88 | ,cmocka_unit_test(test_ordering_fails_out_of_order) 89 | ,cmocka_unit_test(test_ordering_fails_out_of_order_for_at_least_once_calls) 90 | ,cmocka_unit_test(test_fails_out_of_order_if_no_calls_found_on_any) 91 | ,cmocka_unit_test(test_fails_if_zero_count_used) 92 | }; 93 | 94 | return cmocka_run_group_tests(tests, NULL, NULL); 95 | } 96 | -------------------------------------------------------------------------------- /lowlevel/asetek.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file lowlevel/asetek.c 20 | * \brief Lowlevel Routines for Asetek 21 | */ 22 | #include "lowlevel/asetek.h" 23 | 24 | #include 25 | #include 26 | 27 | #define TIMEOUT_DEFAULT 1000 /*!< TIMEOUT_DEFAULT */ 28 | 29 | /*! Asetek Init routine. 30 | * Asetek init routine uses two control transfers. 31 | * 32 | */ 33 | int 34 | corsairlink_asetek_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ) 35 | { 36 | int rr; 37 | 38 | rr = libusb_control_transfer( dev_handle, 0x40, 0x00, 0xffff, 0x0000, NULL, 0, 0 ); 39 | // if (rr < 0) 40 | // { 41 | // return rr; 42 | // } 43 | rr = libusb_control_transfer( dev_handle, 0x40, 0x02, 0x0002, 0x0000, NULL, 0, 0 ); 44 | 45 | return rr; 46 | } 47 | 48 | /*! Asetek De-Init routine. 49 | * Asetek de-init routine uses a control transfer. 50 | * 51 | */ 52 | int 53 | corsairlink_asetek_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ) 54 | { 55 | int rr; 56 | 57 | rr = libusb_control_transfer( dev_handle, 0x40, 0x02, 0x0004, 0x0000, NULL, 0, 200 ); 58 | 59 | return rr; 60 | } 61 | 62 | /*! Lowlevel Asetek Write routine. 63 | * Lowlevel Asetek Write rotine uses bulk transfer to send commands. 64 | * 65 | */ 66 | int 67 | corsairlink_asetek_write( 68 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ) 69 | { 70 | int bytes_transferred; 71 | int rr; 72 | 73 | rr = libusb_bulk_transfer( 74 | dev_handle, endpoint, data, length, &bytes_transferred, TIMEOUT_DEFAULT ); 75 | 76 | return rr; 77 | } 78 | 79 | /*! Lowlevel Asetek Read routine. 80 | * Lowlevel Asetek Read routine uses bulk transfer to receive responses. 81 | * 82 | */ 83 | int 84 | corsairlink_asetek_read( 85 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ) 86 | { 87 | int bytes_transferred; 88 | int rr; 89 | 90 | rr = libusb_bulk_transfer( 91 | dev_handle, endpoint, data, length, &bytes_transferred, TIMEOUT_DEFAULT ); 92 | 93 | return rr; 94 | } 95 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/coverity/coverity_assert_model.c: -------------------------------------------------------------------------------- 1 | #define LargestIntegralType unsigned long long 2 | 3 | void _assert_true(const LargestIntegralType result, 4 | const char* const expression, 5 | const char * const file, const int line) 6 | { 7 | __coverity_panic__(); 8 | } 9 | 10 | void _assert_int_equal( 11 | const LargestIntegralType a, const LargestIntegralType b, 12 | const char * const file, const int line) 13 | { 14 | __coverity_panic__(); 15 | } 16 | 17 | void _assert_int_not_equal( 18 | const LargestIntegralType a, const LargestIntegralType b, 19 | const char * const file, const int line) 20 | { 21 | __coverity_panic__(); 22 | } 23 | 24 | void _assert_return_code(const LargestIntegralType result, 25 | size_t rlen, 26 | const LargestIntegralType error, 27 | const char * const expression, 28 | const char * const file, 29 | const int line) 30 | { 31 | __coverity_panic__(); 32 | } 33 | 34 | void _assert_string_equal(const char * const a, const char * const b, 35 | const char * const file, const int line) 36 | { 37 | __coverity_panic__(); 38 | } 39 | 40 | void _assert_string_not_equal(const char * const a, const char * const b, 41 | const char *file, const int line) 42 | { 43 | __coverity_panic__(); 44 | } 45 | 46 | void _assert_memory_equal(const void * const a, const void * const b, 47 | const size_t size, const char* const file, 48 | const int line) 49 | { 50 | __coverity_panic__(); 51 | } 52 | 53 | void _assert_memory_not_equal(const void * const a, const void * const b, 54 | const size_t size, const char* const file, 55 | const int line) 56 | { 57 | __coverity_panic__(); 58 | } 59 | 60 | void _assert_in_range( 61 | const LargestIntegralType value, const LargestIntegralType minimum, 62 | const LargestIntegralType maximum, const char* const file, const int line) 63 | { 64 | __coverity_panic__(); 65 | } 66 | 67 | void _assert_not_in_range( 68 | const LargestIntegralType value, const LargestIntegralType minimum, 69 | const LargestIntegralType maximum, const char* const file, const int line) 70 | { 71 | __coverity_panic__(); 72 | } 73 | 74 | void _assert_in_set( 75 | const LargestIntegralType value, const LargestIntegralType values[], 76 | const size_t number_of_values, const char* const file, const int line) 77 | { 78 | __coverity_panic__(); 79 | } 80 | 81 | void _assert_not_in_set( 82 | const LargestIntegralType value, const LargestIntegralType values[], 83 | const size_t number_of_values, const char* const file, const int line) 84 | { 85 | __coverity_panic__(); 86 | } 87 | 88 | -------------------------------------------------------------------------------- /protocol/platinum/temperature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2019 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "lowlevel/platinum.h" 22 | #include "protocol/platinum.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | int 32 | corsairlink_platinum_tempsensorscount( 33 | struct corsair_device_info* dev, 34 | struct libusb_device_handle* handle, 35 | uint8_t* temperature_sensors_count ) 36 | { 37 | int rr = 0; 38 | // uint8_t response[64]; 39 | // uint8_t commands[64]; 40 | // memset( response, 0, sizeof( response ) ); 41 | // memset( commands, 0, sizeof( commands ) ); 42 | // 43 | // uint8_t ii = 0; 44 | // 45 | // commands[++ii] = CommandId++; // Command ID 46 | // commands[++ii] = ReadOneByte; // Command Opcode 47 | // commands[++ii] = TEMP_CountSensors; // Command data... 48 | // 49 | // commands[0] = ii; // Length 50 | // 51 | // rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 52 | // rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 53 | 54 | *( temperature_sensors_count ) = 1; 55 | 56 | return rr; 57 | } 58 | 59 | int 60 | corsairlink_platinum_temperature( 61 | struct corsair_device_info* dev, 62 | struct libusb_device_handle* handle, 63 | uint8_t selector, 64 | double* temperature ) 65 | { 66 | int rr; 67 | uint8_t response[64]; 68 | uint8_t commands[64]; 69 | memset( response, 0, sizeof( response ) ); 70 | memset( commands, 0, sizeof( commands ) ); 71 | 72 | commands[0x00] = 0x3F; 73 | commands[0x01] = 0x78; 74 | 75 | commands[0x3F] = crc8ccitt(commands+1, 62); 76 | 77 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 78 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 79 | 80 | // *(temperature) = (response[5]<<8) + response[4]; 81 | *( temperature ) = (double)response[8] + ( (double)response[7] / 256 ); 82 | // snprintf(temperature, temperature_str_len, "%d.%d C", response[5], 83 | // response[4]); 84 | 85 | return rr; 86 | } 87 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/ctest-default.cmake: -------------------------------------------------------------------------------- 1 | ## The directory to run ctest in. 2 | set(CTEST_DIRECTORY "$ENV{HOME}/workspace/tmp/dashboards/cmocka") 3 | 4 | ## The hostname of the machine 5 | set(CTEST_SITE "host.cmocka.org") 6 | ## The buildname 7 | set(CTEST_BUILD_NAME "Linux_GCC_x86_64_default") 8 | 9 | ## The Makefile generator to use 10 | set(CTEST_CMAKE_GENERATOR "Unix Makefiles") 11 | 12 | ## The Build configuration to use. 13 | set(CTEST_BUILD_CONFIGURATION "Debug") 14 | 15 | ## The build options for the project 16 | set(CTEST_BUILD_OPTIONS "-DUNIT_TESTING=ON -DWITH_CMOCKERY_SUPPORT=ON") 17 | 18 | #set(CTEST_CUSTOM_MEMCHECK_IGNORE torture_rand) 19 | 20 | ## The Model to set: Nightly, Continous, Experimental 21 | set(CTEST_MODEL "Experimental") 22 | 23 | ## The URL to the git repository 24 | set(CTEST_GIT_REPOSITORY "git://git.cryptomilk.org/projects/cmocka.git") 25 | 26 | ## The branch 27 | #set(CTEST_GIT_BRANCH "--branch v0-5") 28 | 29 | ## Wether to enable memory checking. 30 | set(WITH_MEMCHECK FALSE) 31 | 32 | ## Wether to enable code coverage. 33 | set(WITH_COVERAGE FALSE) 34 | 35 | ####################################################################### 36 | 37 | if (WITH_COVERAGE AND NOT WIN32) 38 | set(CTEST_BUILD_CONFIGURATION "Profiling") 39 | endif (WITH_COVERAGE AND NOT WIN32) 40 | 41 | set(CTEST_SOURCE_DIRECTORY "${CTEST_DIRECTORY}/${CTEST_BUILD_NAME}/source") 42 | set(CTEST_BINARY_DIRECTORY "${CTEST_DIRECTORY}/${CTEST_BUILD_NAME}/build") 43 | 44 | set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_SOURCE_DIR}/tests/valgrind.supp) 45 | 46 | find_program(CTEST_GIT_COMMAND NAMES git) 47 | find_program(CTEST_COVERAGE_COMMAND NAMES gcov) 48 | find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) 49 | 50 | if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") 51 | set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} clone ${CTEST_GIT_BRANCH} ${CTEST_GIT_REPOSITORY} ${CTEST_SOURCE_DIRECTORY}") 52 | endif() 53 | 54 | set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}") 55 | 56 | set(CTEST_CONFIGURE_COMMAND "${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION}") 57 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} ${CTEST_BUILD_OPTIONS}") 58 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"-G${CTEST_CMAKE_GENERATOR}\"") 59 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"${CTEST_SOURCE_DIRECTORY}\"") 60 | 61 | ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) 62 | 63 | ctest_start(${CTEST_MODEL} TRACK ${CTEST_MODEL}) 64 | ctest_update(SOURCE ${CTEST_SOURCE_DIRECTORY}) 65 | ctest_configure(BUILD ${CTEST_BINARY_DIRECTORY}) 66 | ctest_build(BUILD ${CTEST_BINARY_DIRECTORY}) 67 | ctest_test(BUILD ${CTEST_BINARY_DIRECTORY}) 68 | if (WITH_MEMCHECK AND CTEST_COVERAGE_COMMAND) 69 | ctest_coverage(BUILD ${CTEST_BINARY_DIRECTORY}) 70 | endif (WITH_MEMCHECK AND CTEST_COVERAGE_COMMAND) 71 | if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND) 72 | ctest_memcheck(BUILD ${CTEST_BINARY_DIRECTORY}) 73 | endif (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND) 74 | ctest_submit() 75 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cmocka C) 2 | 3 | # Required cmake version 4 | cmake_minimum_required(VERSION 2.6.0) 5 | 6 | # global needed variables 7 | set(APPLICATION_NAME ${PROJECT_NAME}) 8 | 9 | set(APPLICATION_VERSION_MAJOR "1") 10 | set(APPLICATION_VERSION_MINOR "1") 11 | set(APPLICATION_VERSION_PATCH "1") 12 | 13 | set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}") 14 | 15 | # SOVERSION scheme: CURRENT.AGE.REVISION 16 | # If there was an incompatible interface change: 17 | # Increment CURRENT. Set AGE and REVISION to 0 18 | # If there was a compatible interface change: 19 | # Increment AGE. Set REVISION to 0 20 | # If the source code was changed, but there were no interface changes: 21 | # Increment REVISION. 22 | set(LIBRARY_VERSION "0.4.1") 23 | set(LIBRARY_SOVERSION "0") 24 | 25 | # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked 26 | set(CMAKE_MODULE_PATH 27 | ${CMAKE_SOURCE_DIR}/cmake/Modules 28 | ) 29 | 30 | # add definitions 31 | include(DefineCMakeDefaults) 32 | include(DefinePlatformDefaults) 33 | include(DefineCompilerFlags) 34 | include(DefineInstallationPaths) 35 | include(DefineOptions.cmake) 36 | include(CPackConfig.cmake) 37 | include(CheckSymbolExists) 38 | 39 | # disallow in-source build 40 | include(MacroEnsureOutOfSourceBuild) 41 | macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.") 42 | 43 | # config.h checks 44 | include(ConfigureChecks.cmake) 45 | configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) 46 | 47 | # MinGW DLL Naming Workaround 48 | if (MINGW) 49 | set(CMAKE_SHARED_LIBRARY_PREFIX "") 50 | endif (MINGW) 51 | 52 | # check subdirectories 53 | add_subdirectory(doc) 54 | add_subdirectory(include) 55 | add_subdirectory(src) 56 | 57 | if (UNIT_TESTING) 58 | include(AddCMockaTest) 59 | add_subdirectory(tests) 60 | endif (UNIT_TESTING) 61 | 62 | add_subdirectory(example) 63 | 64 | # pkg-config file 65 | configure_file(cmocka.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmocka.pc) 66 | install( 67 | FILES 68 | ${CMAKE_CURRENT_BINARY_DIR}/cmocka.pc 69 | DESTINATION 70 | ${LIB_INSTALL_DIR}/pkgconfig 71 | COMPONENT 72 | pkgconfig 73 | ) 74 | 75 | # cmake config files 76 | set(CMOCKA_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) 77 | 78 | configure_file(${PROJECT_NAME}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake @ONLY) 79 | configure_file(${PROJECT_NAME}-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake @ONLY) 80 | install( 81 | FILES 82 | ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake 83 | ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake 84 | DESTINATION 85 | ${CMAKE_INSTALL_DIR}/${PROJECT_NAME} 86 | COMPONENT 87 | devel 88 | ) 89 | -------------------------------------------------------------------------------- /lowlevel/rmi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file lowlevel/rmi.c 20 | * \brief Lowlevel Routines for RMi Series of Power Supplies 21 | */ 22 | #include "lowlevel/rmi.h" 23 | 24 | #include 25 | #include 26 | 27 | #define TIMEOUT_DEFAULT 5000 28 | #define INTERRUPT_IN_ENDPOINT 0x81 29 | #define INTERRUPT_OUT_ENDPOINT 0x01 30 | 31 | /*! RMi Power Supply Init 32 | * RMi Power Supply Init is empty 33 | * @param[in] handle for the data 34 | * @param[in] device endpoint for the data 35 | * @return 0 36 | */ 37 | int 38 | corsairlink_rmi_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ) 39 | { 40 | return 0; 41 | } 42 | 43 | /*! RMi Power Supply De-Init 44 | * RMi Power Supply De-Init is empty 45 | * @param[in] handle for the data 46 | * @param[in] device endpoint for the data 47 | * @return 0 48 | */ 49 | int 50 | corsairlink_rmi_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ) 51 | { 52 | return 0; 53 | } 54 | 55 | /*! RMi Power Supply Lowlevel Write 56 | * RMi Power Supply Lowlevel Write uses a interrupt transfer 57 | * @param[in] handle for the data 58 | * @param[in] device endpoint for the data 59 | * @param[in] data to send 60 | * @param[in] length of data to send, in bytes 61 | * @return 0 62 | */ 63 | int 64 | corsairlink_rmi_write( 65 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ) 66 | { 67 | int bytes_transferred; 68 | int rr; 69 | 70 | rr = libusb_interrupt_transfer( 71 | dev_handle, endpoint, data, length, &bytes_transferred, TIMEOUT_DEFAULT ); 72 | 73 | return rr; 74 | } 75 | 76 | /*! RMi Power Supply Lowlevel Read 77 | * RMi Power Supply Lowlevel Read uses a interrupt transfer 78 | * @param[in] handle for the data 79 | * @param[in] device endpoint for the data 80 | * @param[in] data to send 81 | * @param[in] length of data to send, in bytes 82 | * @return 0 83 | */ 84 | int 85 | corsairlink_rmi_read( 86 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ) 87 | { 88 | int bytes_transferred; 89 | int rr; 90 | 91 | rr = libusb_interrupt_transfer( 92 | dev_handle, endpoint, data, length, &bytes_transferred, TIMEOUT_DEFAULT ); 93 | 94 | return rr; 95 | } 96 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/product_database_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | extern DatabaseConnection* connect_to_product_database(void); 23 | 24 | /* Mock connect to database function. 25 | * NOTE: This mock function is very general could be shared between tests 26 | * that use the imaginary database.h module. */ 27 | DatabaseConnection* connect_to_database(const char * const url, 28 | const unsigned int port) { 29 | check_expected_ptr(url); 30 | check_expected(port); 31 | return (DatabaseConnection*)((size_t)mock()); 32 | } 33 | 34 | static void test_connect_to_product_database(void **state) { 35 | (void) state; /* unused */ 36 | 37 | expect_string(connect_to_database, url, "products.abcd.org"); 38 | expect_value(connect_to_database, port, 322); 39 | will_return(connect_to_database, 0xDA7ABA53); 40 | assert_int_equal((size_t)connect_to_product_database(), 0xDA7ABA53); 41 | } 42 | 43 | /* This test will fail since the expected URL is different to the URL that is 44 | * passed to connect_to_database() by connect_to_product_database(). */ 45 | static void test_connect_to_product_database_bad_url(void **state) { 46 | (void) state; /* unused */ 47 | 48 | expect_string(connect_to_database, url, "products.abcd.com"); 49 | expect_value(connect_to_database, port, 322); 50 | will_return(connect_to_database, 0xDA7ABA53); 51 | assert_int_equal((size_t)connect_to_product_database(), 0xDA7ABA53); 52 | } 53 | 54 | /* This test will fail since the mock connect_to_database() will attempt to 55 | * retrieve a value for the parameter port which isn't specified by this 56 | * test function. */ 57 | static void test_connect_to_product_database_missing_parameter(void **state) { 58 | (void) state; /* unused */ 59 | 60 | expect_string(connect_to_database, url, "products.abcd.org"); 61 | will_return(connect_to_database, 0xDA7ABA53); 62 | assert_int_equal((size_t)connect_to_product_database(), 0xDA7ABA53); 63 | } 64 | 65 | int main(void) { 66 | const struct CMUnitTest tests[] = { 67 | cmocka_unit_test(test_connect_to_product_database), 68 | cmocka_unit_test(test_connect_to_product_database_bad_url), 69 | cmocka_unit_test(test_connect_to_product_database_missing_parameter), 70 | }; 71 | return cmocka_run_group_tests(tests, NULL, NULL); 72 | } 73 | -------------------------------------------------------------------------------- /protocol/platinum/core.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2019 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "logic/print.h" 22 | #include "lowlevel/platinum.h" 23 | #include "protocol/platinum.h" 24 | #include "protocol/crc.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | int 34 | corsairlink_platinum_device_id( 35 | struct corsair_device_info* dev, struct libusb_device_handle* handle, uint16_t* device_id ) 36 | { 37 | ( *device_id ) = 0xFF; 38 | return 0; 39 | } 40 | 41 | int 42 | corsairlink_platinum_name( 43 | struct corsair_device_info* dev, 44 | struct libusb_device_handle* handle, 45 | char* name, 46 | uint8_t name_size ) 47 | { 48 | snprintf( name, name_size, "%s", dev->name ); 49 | return 0; 50 | } 51 | 52 | int 53 | corsairlink_platinum_vendor( 54 | struct corsair_device_info* dev, 55 | struct libusb_device_handle* handle, 56 | char* name, 57 | uint8_t name_size ) 58 | { 59 | snprintf( name, name_size, "Corsair" ); 60 | return 0; 61 | } 62 | 63 | int 64 | corsairlink_platinum_product( 65 | struct corsair_device_info* dev, 66 | struct libusb_device_handle* handle, 67 | char* name, 68 | uint8_t name_size ) 69 | { 70 | snprintf( name, name_size, "%s", dev->name ); 71 | return 0; 72 | } 73 | 74 | int 75 | corsairlink_platinum_firmware_id( 76 | struct corsair_device_info* dev, 77 | struct libusb_device_handle* handle, 78 | char* firmware, 79 | uint8_t firmware_size ) 80 | { 81 | int rr; 82 | uint8_t response[0x40]; 83 | uint8_t commands[0x40]; 84 | memset( response, 0, sizeof( response ) ); 85 | memset( commands, 0, sizeof( commands ) ); 86 | 87 | commands[0x00] = 0x3F; 88 | commands[0x01] = 0x78; // Command ID 89 | 90 | commands[0x3F] = crc8ccitt(commands+1, 62); 91 | 92 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 93 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 94 | 95 | snprintf( 96 | firmware, firmware_size, "%d.%d.%d", 97 | ( response[2] ) >> 4, ( response[2] & 0xf ), response[3] ); 98 | 99 | return 0; 100 | } 101 | -------------------------------------------------------------------------------- /protocol/platinum/pump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2019 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "logic/print.h" 22 | #include "logic/options.h" 23 | #include "lowlevel/platinum.h" 24 | #include "protocol/platinum.h" 25 | #include "protocol/crc.h" 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | int 35 | corsairlink_platinum_pump_mode_read( 36 | struct corsair_device_info* dev, 37 | struct libusb_device_handle* handle, 38 | struct pump_control* ctrl ) 39 | { 40 | int rr; 41 | // uint8_t response[64]; 42 | // uint8_t commands[64]; 43 | // 44 | // memset( response, 0, sizeof( response ) ); 45 | // memset( commands, 0, sizeof( commands ) ); 46 | // 47 | // uint8_t ii = 0; 48 | // 49 | // commands[++ii] = CommandId++; 50 | // commands[++ii] = WriteOneByte; 51 | // commands[++ii] = FAN_Select; 52 | // commands[++ii] = ctrl->channel; 53 | // 54 | // commands[++ii] = CommandId++; 55 | // commands[++ii] = ReadOneByte; 56 | // commands[++ii] = FAN_Mode; 57 | // 58 | // commands[0] = ii; 59 | // 60 | // rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 61 | // rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 62 | 63 | ctrl->mode = 0x00; 64 | 65 | return rr; 66 | } 67 | 68 | int 69 | corsairlink_platinum_pump_speed( 70 | struct corsair_device_info* dev, 71 | struct libusb_device_handle* handle, 72 | struct pump_control* ctrl ) 73 | { 74 | int rr; 75 | uint8_t response[64]; 76 | uint8_t commands[64]; 77 | memset( response, 0, sizeof( response ) ); 78 | memset( commands, 0, sizeof( commands ) ); 79 | 80 | commands[0x00] = 0x3F; 81 | commands[0x01] = 0x78; 82 | 83 | commands[0x3F] = crc8ccitt(commands+1, 62); 84 | 85 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 86 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 87 | 88 | msg_debug2( "Speed: %02X %02X\n", response[0x1D], response[0x1E] ); 89 | msg_debug2( "Max Speed: %02X %02X\n", response[9], response[8] ); 90 | 91 | ctrl->speed = ( response[0x1E] << 8 ) + response[0x1D]; 92 | ctrl->max_speed = 0xFFFF; 93 | 94 | return rr; 95 | } 96 | -------------------------------------------------------------------------------- /protocol/commanderpro/temperature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "lowlevel/commanderpro.h" 22 | #include "logic/print.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | int 32 | corsairlink_commanderpro_tempsensorscount( 33 | struct corsair_device_info* dev, 34 | struct libusb_device_handle* handle, 35 | uint8_t* temperature_sensors_count ) 36 | { 37 | int rr = 0; 38 | 39 | uint8_t response[16]; 40 | uint8_t commands[64]; 41 | memset( response, 0, sizeof( response ) ); 42 | memset( commands, 0, sizeof( commands ) ); 43 | 44 | commands[0] = 0x10; 45 | 46 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 47 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 16 ); 48 | 49 | dump_packet( commands, sizeof( commands ) ); 50 | dump_packet( response, sizeof( response ) ); 51 | // msg_debug2( "%02X %02X %02X %02X\n", response[1], response[2], response[3], response[4] ); 52 | 53 | *( temperature_sensors_count ) = 4; 54 | // for (int ii = 1; ii <= 4; ++ii) 55 | // { 56 | // if (response[ii] == 0x01) 57 | // { 58 | // *(temperature_sensors_count)++; 59 | // } 60 | // } 61 | 62 | return rr; 63 | } 64 | 65 | int 66 | corsairlink_commanderpro_temperature( 67 | struct corsair_device_info* dev, 68 | struct libusb_device_handle* handle, 69 | uint8_t sensor_index, 70 | double* temperature ) 71 | { 72 | int rr; 73 | uint8_t response[16]; 74 | uint8_t commands[64]; 75 | memset( response, 0, sizeof( response ) ); 76 | memset( commands, 0, sizeof( commands ) ); 77 | 78 | commands[0] = 0x11; 79 | commands[1] = sensor_index; 80 | 81 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 82 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 16 ); 83 | 84 | uint16_t data; 85 | data = ( response[1] << 8 ) + response[2]; 86 | *( temperature ) = (double)data / 100; 87 | // snprintf(temperature, temperature_str_len, "%5.2f C", (double)data/100); 88 | 89 | dump_packet( commands, sizeof( commands ) ); 90 | dump_packet( response, sizeof( response ) ); 91 | return rr; 92 | } 93 | -------------------------------------------------------------------------------- /protocol/coolit/led.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "logic/options.h" 22 | #include "lowlevel/coolit.h" 23 | #include "protocol/coolit.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | int 33 | corsairlink_coolit_change_led( 34 | struct corsair_device_info* dev, struct libusb_device_handle* handle, struct led_control* ctrl ) 35 | { 36 | int rr; 37 | uint8_t response[64]; 38 | uint8_t commands[64]; 39 | memset( response, 0, sizeof( response ) ); 40 | memset( commands, 0, sizeof( commands ) ); 41 | 42 | uint8_t ii = 0; 43 | 44 | commands[++ii] = CommandId++; // Command ID 45 | commands[++ii] = WriteOneByte; // Command Opcode 46 | commands[++ii] = LED_SelectCurrent; // Command data... 47 | commands[++ii] = 0; 48 | 49 | commands[++ii] = CommandId++; // Command ID 50 | commands[++ii] = WriteOneByte; // Command Opcode 51 | commands[++ii] = LED_Mode; // Command data... 52 | commands[++ii] = 0x00; 53 | 54 | commands[++ii] = CommandId++; // Command ID 55 | commands[++ii] = WriteThreeBytes; // Command Opcode 56 | commands[++ii] = LED_CycleColors; // Command data... 57 | commands[++ii] = 0x0C; 58 | 59 | commands[++ii] = ctrl->led_colors[0].red; 60 | commands[++ii] = ctrl->led_colors[0].green; 61 | commands[++ii] = ctrl->led_colors[0].blue; 62 | 63 | commands[++ii] = ctrl->led_colors[0].red; 64 | commands[++ii] = ctrl->led_colors[0].green; 65 | commands[++ii] = ctrl->led_colors[0].blue; 66 | 67 | commands[++ii] = ctrl->led_colors[0].red; 68 | commands[++ii] = ctrl->led_colors[0].green; 69 | commands[++ii] = ctrl->led_colors[0].blue; 70 | 71 | commands[++ii] = ctrl->led_colors[0].red; 72 | commands[++ii] = ctrl->led_colors[0].green; 73 | commands[++ii] = ctrl->led_colors[0].blue; 74 | 75 | commands[0] = ii; // Length 76 | 77 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 78 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 79 | 80 | // fan_rpm = (long int) response[0]*16*16 + response[1]; 81 | // pump_rpm = (response[8]*16*16)+response[9]; 82 | // liquid_temp = (double) response[10] + (double) response[14]/10; 83 | 84 | return rr; 85 | } 86 | -------------------------------------------------------------------------------- /protocol/platinum/led.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2019 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "logic/options.h" 22 | #include "lowlevel/platinum.h" 23 | #include "protocol/platinum.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | int 33 | corsairlink_platinum_change_led( 34 | struct corsair_device_info* dev, struct libusb_device_handle* handle, struct led_control* ctrl ) 35 | { 36 | int rr; 37 | uint8_t response[64]; 38 | uint8_t commands[64]; 39 | memset( response, 0, sizeof( response ) ); 40 | memset( commands, 0, sizeof( commands ) ); 41 | 42 | uint8_t ii = 0; 43 | 44 | commands[++ii] = CommandId++; // Command ID 45 | commands[++ii] = WriteOneByte; // Command Opcode 46 | commands[++ii] = LED_SelectCurrent; // Command data... 47 | commands[++ii] = 0; 48 | 49 | commands[++ii] = CommandId++; // Command ID 50 | commands[++ii] = WriteOneByte; // Command Opcode 51 | commands[++ii] = LED_Mode; // Command data... 52 | commands[++ii] = 0x00; 53 | 54 | commands[++ii] = CommandId++; // Command ID 55 | commands[++ii] = WriteThreeBytes; // Command Opcode 56 | commands[++ii] = LED_CycleColors; // Command data... 57 | commands[++ii] = 0x0C; 58 | 59 | commands[++ii] = ctrl->led_colors[0].red; 60 | commands[++ii] = ctrl->led_colors[0].green; 61 | commands[++ii] = ctrl->led_colors[0].blue; 62 | 63 | commands[++ii] = ctrl->led_colors[0].red; 64 | commands[++ii] = ctrl->led_colors[0].green; 65 | commands[++ii] = ctrl->led_colors[0].blue; 66 | 67 | commands[++ii] = ctrl->led_colors[0].red; 68 | commands[++ii] = ctrl->led_colors[0].green; 69 | commands[++ii] = ctrl->led_colors[0].blue; 70 | 71 | commands[++ii] = ctrl->led_colors[0].red; 72 | commands[++ii] = ctrl->led_colors[0].green; 73 | commands[++ii] = ctrl->led_colors[0].blue; 74 | 75 | commands[0] = ii; // Length 76 | 77 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 78 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 79 | 80 | // fan_rpm = (long int) response[0]*16*16 + response[1]; 81 | // pump_rpm = (response[8]*16*16)+response[9]; 82 | // liquid_temp = (double) response[10] + (double) response[14]/10; 83 | 84 | return rr; 85 | } 86 | -------------------------------------------------------------------------------- /protocol/asetekpro/core.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file protocol/asetek/core.c 20 | * \brief Core Routines for RMi Series of Power Supplies 21 | */ 22 | #include "device.h" 23 | #include "driver.h" 24 | #include "lowlevel/asetek.h" 25 | #include "logic/print.h" 26 | #include "protocol/asetekpro.h" 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | int 36 | corsairlink_asetekpro_firmware_id( 37 | struct corsair_device_info* dev, 38 | struct libusb_device_handle* handle, 39 | char* firmware, 40 | uint8_t firmware_size ) 41 | { 42 | int rr; 43 | uint8_t response[64]; 44 | uint8_t commands[64]; 45 | memset( response, 0, sizeof( response ) ); 46 | memset( commands, 0, sizeof( commands ) ); 47 | 48 | commands[0] = AsetekProReadFirmwareVersion; // query firmware id 49 | 50 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 1 ); 51 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 7 ); 52 | 53 | msg_debug2( 54 | "%02X %02X %02X %02X %02X %02X %02X\n", response[0], response[1], response[2], response[3], 55 | response[4], response[5], response[6] ); 56 | 57 | // if (response[0] != 0xAA || response[1] != 0x12 58 | // || response[2] != 0x34 || response[3] != selector) 59 | // { 60 | // msg_debug2("Bad Response\n"); 61 | // } 62 | 63 | snprintf( 64 | firmware, firmware_size, "%d.%d.%d.%d", response[3], response[4], response[5], 65 | response[6] ); 66 | 67 | return rr; 68 | } 69 | 70 | int 71 | corsairlink_asetekpro_hardware_version( 72 | struct corsair_device_info* dev, 73 | struct libusb_device_handle* handle) 74 | 75 | { 76 | int rr; 77 | uint8_t response[64]; 78 | uint8_t commands[64]; 79 | memset( response, 0, sizeof( response ) ); 80 | memset( commands, 0, sizeof( commands ) ); 81 | 82 | commands[0] = AsetekProReadHardwareVersion; 83 | 84 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 1 ); 85 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 7 ); 86 | 87 | msg_debug( 88 | "hardware version returned: %02X %02X %02X %02X %02X %02X %02X\n", response[0], response[1], response[2], response[3], 89 | response[4], response[5], response[6] ); 90 | 91 | return rr; 92 | } 93 | -------------------------------------------------------------------------------- /tests/test_protocol_asetek.c: -------------------------------------------------------------------------------- 1 | /* test_protocol_asetek.c */ 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include "cmocka.h" 10 | #include "protocol/asetek.h" 11 | 12 | /* redefinitons/wrapping */ 13 | int __wrap_corsairlink_asetek_write( 14 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length) 15 | { 16 | check_expected(endpoint); 17 | check_expected(length); 18 | check_expected(data); 19 | return mock(); 20 | } 21 | 22 | int __wrap_corsairlink_asetek_read( 23 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length) 24 | { 25 | check_expected(endpoint); 26 | check_expected(data); 27 | check_expected(length); 28 | return mock(); 29 | } 30 | 31 | /* tests */ 32 | void test_corsairlink_asetek_firmware_id_failure(void **state) 33 | { 34 | (void) state; /* unused */ 35 | int ret; 36 | 37 | uint8_t commands[32] = {}; 38 | commands[0] = 0x20; 39 | 40 | uint8_t response[32] = {}; 41 | response[0x17] = 2; 42 | response[0x18] = 8; 43 | response[0x19] = 0; 44 | response[0x1A] = 0; 45 | 46 | expect_value(__wrap_corsairlink_asetek_write, endpoint, 0x02); 47 | expect_value(__wrap_corsairlink_asetek_write, data, commands); 48 | expect_value(__wrap_corsairlink_asetek_write, length, 32); 49 | will_return(__wrap_corsairlink_asetek_write, -1); 50 | 51 | expect_value(__wrap_corsairlink_asetek_read, endpoint, 0x82); 52 | expect_value(__wrap_corsairlink_asetek_read, data, response); 53 | expect_value(__wrap_corsairlink_asetek_read, length, 32); 54 | will_return(__wrap_corsairlink_asetek_read, -1); 55 | 56 | // ret = corsairlink_asetek_firmware_id(NULL, NULL, firmware_str, firmware_len); 57 | assert_int_equal(-1, ret); 58 | } 59 | 60 | void test_corsairlink_asetek_firmware_id_success(void **state) 61 | { 62 | (void) state; /* unused */ 63 | int ret; 64 | 65 | uint8_t commands[32] = {}; 66 | commands[0] = 0x20; 67 | 68 | uint8_t response[32] = {}; 69 | response[0x17] = 2; 70 | response[0x18] = 8; 71 | response[0x19] = 0; 72 | response[0x1A] = 0; 73 | 74 | expect_value(__wrap_corsairlink_asetek_write, endpoint, 0x02); 75 | expect_value(__wrap_corsairlink_asetek_write, data, commands); 76 | expect_value(__wrap_corsairlink_asetek_write, length, 32); 77 | will_return(__wrap_corsairlink_asetek_write, 0); 78 | 79 | expect_value(__wrap_corsairlink_asetek_read, endpoint, 0x82); 80 | expect_value(__wrap_corsairlink_asetek_read, data, response); 81 | expect_value(__wrap_corsairlink_asetek_read, length, 32); 82 | will_return(__wrap_corsairlink_asetek_read, 0); 83 | 84 | // ret = corsairlink_asetek_firmware_id(NULL, NULL, firmware_str, firmware_len); 85 | assert_int_equal(0, ret); 86 | } 87 | 88 | 89 | const struct CMUnitTest protocol_asetek_tests[] = { 90 | cmocka_unit_test(test_corsairlink_asetek_firmware_id_failure), 91 | cmocka_unit_test(test_corsairlink_asetek_firmware_id_success), 92 | }; 93 | 94 | 95 | int main(void) 96 | { 97 | return cmocka_run_group_tests(protocol_asetek_tests, NULL, NULL); 98 | } 99 | -------------------------------------------------------------------------------- /protocol/coolit/temperature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "device.h" 20 | #include "driver.h" 21 | #include "lowlevel/coolit.h" 22 | #include "protocol/coolit.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | int 32 | corsairlink_coolit_tempsensorscount( 33 | struct corsair_device_info* dev, 34 | struct libusb_device_handle* handle, 35 | uint8_t* temperature_sensors_count ) 36 | { 37 | int rr; 38 | uint8_t response[64]; 39 | uint8_t commands[64]; 40 | memset( response, 0, sizeof( response ) ); 41 | memset( commands, 0, sizeof( commands ) ); 42 | 43 | uint8_t ii = 0; 44 | 45 | commands[++ii] = CommandId++; // Command ID 46 | commands[++ii] = ReadOneByte; // Command Opcode 47 | commands[++ii] = TEMP_CountSensors; // Command data... 48 | 49 | commands[0] = ii; // Length 50 | 51 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 52 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 53 | 54 | *( temperature_sensors_count ) = response[2]; 55 | 56 | return rr; 57 | } 58 | 59 | int 60 | corsairlink_coolit_temperature( 61 | struct corsair_device_info* dev, 62 | struct libusb_device_handle* handle, 63 | uint8_t selector, 64 | double* temperature ) 65 | { 66 | int rr; 67 | uint8_t response[64]; 68 | uint8_t commands[64]; 69 | memset( response, 0, sizeof( response ) ); 70 | memset( commands, 0, sizeof( commands ) ); 71 | 72 | uint8_t ii = 0; 73 | 74 | commands[++ii] = CommandId++; // Command ID 75 | commands[++ii] = WriteOneByte; // Command Opcode 76 | commands[++ii] = TEMP_SelectActiveSensor; // Command data... 77 | commands[++ii] = selector; 78 | 79 | commands[++ii] = CommandId++; // Command ID 80 | commands[++ii] = ReadTwoBytes; // Command Opcode 81 | commands[++ii] = TEMP_Read; // Command data... 82 | 83 | commands[0] = ii; // Length 84 | 85 | rr = dev->lowlevel->write( handle, dev->write_endpoint, commands, 64 ); 86 | rr = dev->lowlevel->read( handle, dev->read_endpoint, response, 64 ); 87 | 88 | // *(temperature) = (response[5]<<8) + response[4]; 89 | *( temperature ) = (double)response[5] + ( (double)response[4] / 256 ); 90 | // snprintf(temperature, temperature_str_len, "%d.%d C", response[5], 91 | // response[4]); 92 | 93 | return rr; 94 | } 95 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/tests/test_ordering.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static void mock_test_a_called(void) 10 | { 11 | function_called(); 12 | } 13 | 14 | static void mock_test_b_called(void) 15 | { 16 | function_called(); 17 | } 18 | 19 | static void mock_test_c_called(void) 20 | { 21 | function_called(); 22 | } 23 | 24 | 25 | static void test_does_succeed_for_expected(void **state) 26 | { 27 | (void)state; 28 | expect_function_call(mock_test_a_called); 29 | expect_function_call(mock_test_a_called); 30 | 31 | mock_test_a_called(); 32 | mock_test_a_called(); 33 | } 34 | 35 | static void test_does_succeed_for_multiple_calls(void **state) 36 | { 37 | (void)state; 38 | expect_function_call(mock_test_a_called); 39 | expect_function_calls(mock_test_a_called, 2); 40 | expect_function_call(mock_test_a_called); 41 | 42 | mock_test_a_called(); 43 | mock_test_a_called(); 44 | mock_test_a_called(); 45 | mock_test_a_called(); 46 | } 47 | 48 | static void test_ordering_does_ignore_calls(void **state) 49 | { 50 | (void)state; 51 | 52 | ignore_function_calls(mock_test_a_called); 53 | 54 | mock_test_a_called(); 55 | mock_test_a_called(); 56 | mock_test_a_called(); 57 | } 58 | 59 | static void test_ordering_does_ignore_no_calls(void **state) 60 | { 61 | (void)state; 62 | ignore_function_calls(mock_test_a_called); 63 | } 64 | 65 | static void test_ordering_does_expect_at_least_one_call(void **state) 66 | { 67 | (void)state; 68 | expect_function_call_any(mock_test_a_called); 69 | 70 | mock_test_a_called(); 71 | mock_test_a_called(); 72 | mock_test_a_called(); 73 | } 74 | 75 | static void test_ordering_does_work_across_different_functions(void **state) 76 | { 77 | (void)state; 78 | expect_function_call(mock_test_a_called); 79 | expect_function_call(mock_test_b_called); 80 | expect_function_call(mock_test_a_called); 81 | 82 | mock_test_a_called(); 83 | mock_test_b_called(); 84 | mock_test_a_called(); 85 | } 86 | 87 | static void test_ordering_ignores_out_of_order_properly(void **state) 88 | { 89 | (void)state; 90 | ignore_function_calls(mock_test_a_called); 91 | ignore_function_calls(mock_test_b_called); 92 | expect_function_calls(mock_test_c_called, 2); 93 | 94 | 95 | mock_test_c_called(); 96 | mock_test_b_called(); 97 | mock_test_c_called(); 98 | } 99 | 100 | int main(void) { 101 | const struct CMUnitTest tests[] = { 102 | cmocka_unit_test(test_does_succeed_for_expected) 103 | ,cmocka_unit_test(test_does_succeed_for_multiple_calls) 104 | ,cmocka_unit_test(test_ordering_does_ignore_no_calls) 105 | ,cmocka_unit_test(test_ordering_does_ignore_calls) 106 | ,cmocka_unit_test(test_ordering_does_expect_at_least_one_call) 107 | ,cmocka_unit_test(test_ordering_does_work_across_different_functions) 108 | ,cmocka_unit_test(test_ordering_ignores_out_of_order_properly) 109 | }; 110 | 111 | return cmocka_run_group_tests(tests, NULL, NULL); 112 | } 113 | -------------------------------------------------------------------------------- /logic/options_pump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "logic/options.h" 20 | #include "logic/print.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | void 30 | pump_control_init( struct pump_control* settings ) 31 | { 32 | settings->mode = DEFAULT; 33 | } 34 | 35 | void 36 | pump_suboptions_parse( char* subopts, struct pump_control* settings ) 37 | { 38 | int opt, returnCode = 0, option_index = 0; 39 | char *value, *token; 40 | uint8_t ii = 0; 41 | 42 | while ( *subopts != '\0' ) 43 | { 44 | switch ( getsubopt( &subopts, pump_options, &value ) ) 45 | { 46 | case SUBOPTION_PUMP_MODE: 47 | sscanf( value, "%u", &settings->mode ); 48 | msg_debug( "PUMP Mode = %u\n", settings->mode ); 49 | break; 50 | 51 | case SUBOPTION_PUMP_PWM: 52 | sscanf( value, "%hhu", &settings->speed_pwm ); 53 | msg_debug( "PUMP PWM = %u\n", settings->speed_pwm ); 54 | break; 55 | 56 | case SUBOPTION_PUMP_RPM: 57 | sscanf( value, "%hu", &settings->speed_rpm ); 58 | msg_debug( "PUMP RPM = %u\n", settings->speed_rpm ); 59 | break; 60 | 61 | case SUBOPTION_PUMP_TEMPERATURES: 62 | ii = 0; 63 | token = strtok( value, ":" ); 64 | while ( token != NULL ) 65 | { 66 | if ( ii == 6 ) 67 | break; 68 | sscanf( token, "%hhu", &settings->table[ii].temperature ); 69 | msg_debug( "PUMP Temperature %u: %u\n", ii, settings->table[ii].temperature ); 70 | ++ii; 71 | token = strtok( NULL, ":" ); 72 | } 73 | break; 74 | 75 | case SUBOPTION_PUMP_SPEEDS: 76 | ii = 0; 77 | token = strtok( value, ":" ); 78 | while ( token != NULL ) 79 | { 80 | if ( ii == 6 ) 81 | break; 82 | sscanf( token, "%hhu", &settings->table[ii].speed ); 83 | msg_debug( "PUMP Speed %d: %u\n", ii, settings->table[ii].speed ); 84 | ++ii; 85 | token = strtok( NULL, ":" ); 86 | } 87 | break; 88 | 89 | default: 90 | /* Unknown suboption. */ 91 | msg_info( "Unknown suboption `%s'\n", value ); 92 | break; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/cmake/Modules/DefineCompilerFlags.cmake: -------------------------------------------------------------------------------- 1 | # define system dependent compiler flags 2 | 3 | include(CheckCCompilerFlag) 4 | include(CheckCCompilerFlagSSP) 5 | 6 | if (UNIX AND NOT WIN32) 7 | # 8 | # Define GNUCC compiler flags 9 | # 10 | if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)") 11 | 12 | # add -Wconversion ? 13 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -pedantic-errors") 14 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement") 15 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security") 16 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute -Wundef -Wstrict-prototypes") 17 | 18 | # with -fPIC 19 | check_c_compiler_flag("-fPIC" WITH_FPIC) 20 | if (WITH_FPIC) 21 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") 22 | endif (WITH_FPIC) 23 | 24 | check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR) 25 | if (WITH_STACK_PROTECTOR) 26 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector") 27 | endif (WITH_STACK_PROTECTOR) 28 | 29 | if (CMAKE_BUILD_TYPE) 30 | string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) 31 | if (CMAKE_BUILD_TYPE_LOWER MATCHES (release|relwithdebinfo|minsizerel)) 32 | check_c_compiler_flag("-Wp,-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE) 33 | if (WITH_FORTIFY_SOURCE) 34 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wp,-D_FORTIFY_SOURCE=2") 35 | endif (WITH_FORTIFY_SOURCE) 36 | endif() 37 | endif() 38 | 39 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE") 40 | endif (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)") 41 | 42 | # 43 | # Check for large filesystem support 44 | # 45 | if (CMAKE_SIZEOF_VOID_P MATCHES "8") 46 | # with large file support 47 | execute_process( 48 | COMMAND 49 | getconf LFS64_CFLAGS 50 | OUTPUT_VARIABLE 51 | _lfs_CFLAGS 52 | ERROR_QUIET 53 | OUTPUT_STRIP_TRAILING_WHITESPACE 54 | ) 55 | else (CMAKE_SIZEOF_VOID_P MATCHES "8") 56 | # with large file support 57 | execute_process( 58 | COMMAND 59 | getconf LFS_CFLAGS 60 | OUTPUT_VARIABLE 61 | _lfs_CFLAGS 62 | ERROR_QUIET 63 | OUTPUT_STRIP_TRAILING_WHITESPACE 64 | ) 65 | endif (CMAKE_SIZEOF_VOID_P MATCHES "8") 66 | if (_lfs_CFLAGS) 67 | string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}") 68 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_lfs_CFLAGS}") 69 | endif (_lfs_CFLAGS) 70 | 71 | endif (UNIX AND NOT WIN32) 72 | 73 | if (MSVC) 74 | # Use secure functions by defaualt and suppress warnings about 75 | #"deprecated" functions 76 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1") 77 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1") 78 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_NONSTDC_NO_WARNINGS=1 /D _CRT_SECURE_NO_WARNINGS=1") 79 | endif (MSVC) 80 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/example/customer_database_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | extern DatabaseConnection* connect_to_customer_database(void); 23 | extern unsigned int get_customer_id_by_name( 24 | DatabaseConnection * const connection, const char * const customer_name); 25 | 26 | /* Mock query database function. */ 27 | static unsigned int mock_query_database(DatabaseConnection* const connection, 28 | const char * const query_string, 29 | void *** const results) { 30 | (void) connection; /* unused */ 31 | (void) query_string; /* unused */ 32 | 33 | *results = (void **)mock_ptr_type(int *); 34 | return mock_ptr_type(int); 35 | } 36 | 37 | /* Mock of the connect to database function. */ 38 | DatabaseConnection* connect_to_database(const char * const database_url, 39 | const unsigned int port) { 40 | (void) database_url; /* unused */ 41 | (void) port; /* unused */ 42 | 43 | return (DatabaseConnection*)((size_t)mock()); 44 | } 45 | 46 | static void test_connect_to_customer_database(void **state) { 47 | (void) state; /* unused */ 48 | 49 | will_return(connect_to_database, 0x0DA7ABA53); 50 | 51 | assert_int_equal((size_t)connect_to_customer_database(), 0x0DA7ABA53); 52 | } 53 | 54 | /* This test fails as the mock function connect_to_database() will have no 55 | * value to return. */ 56 | #if 0 57 | static void fail_connect_to_customer_database(void **state) { 58 | (void) state; /* unused */ 59 | 60 | assert_true(connect_to_customer_database() == 61 | (DatabaseConnection*)0x0DA7ABA53); 62 | } 63 | #endif 64 | 65 | static void test_get_customer_id_by_name(void **state) { 66 | DatabaseConnection connection = { 67 | "somedatabase.somewhere.com", 12345678, mock_query_database 68 | }; 69 | /* Return a single customer ID when mock_query_database() is called. */ 70 | int customer_ids = 543; 71 | int rc; 72 | 73 | (void) state; /* unused */ 74 | 75 | will_return(mock_query_database, 76 | cast_ptr_to_largest_integral_type(&customer_ids)); 77 | will_return(mock_query_database, 1); 78 | 79 | rc = get_customer_id_by_name(&connection, "john doe"); 80 | assert_int_equal(rc, 543); 81 | } 82 | 83 | int main(void) { 84 | const struct CMUnitTest tests[] = { 85 | cmocka_unit_test(test_connect_to_customer_database), 86 | cmocka_unit_test(test_get_customer_id_by_name), 87 | }; 88 | return cmocka_run_group_tests(tests, NULL, NULL); 89 | } 90 | -------------------------------------------------------------------------------- /docs/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at audiohacked@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cmocka-library C) 2 | 3 | set(CMOCKA_PLATFORM_INCLUDE CACHE PATH "Path to include directory for cmocka_platform.h") 4 | 5 | set(CMOCKA_PUBLIC_INCLUDE_DIRS 6 | ${CMAKE_SOURCE_DIR}/include 7 | ${CMOCKA_PLATFORM_INCLUDE} 8 | CACHE INTERNAL "cmocka public include directories" 9 | ) 10 | 11 | set(CMOCKA_PRIVATE_INCLUDE_DIRS 12 | ${CMAKE_BINARY_DIR} 13 | ) 14 | 15 | set(CMOCKA_SHARED_LIBRARY 16 | cmocka_shared 17 | CACHE INTERNAL "cmocka shared library" 18 | ) 19 | 20 | if (WITH_STATIC_LIB) 21 | set(CMOCKA_STATIC_LIBRARY 22 | cmocka_static 23 | CACHE INTERNAL "cmocka static library" 24 | ) 25 | endif (WITH_STATIC_LIB) 26 | 27 | set(CMOCKA_LINK_LIBRARIES 28 | ${CMOCKA_REQUIRED_LIBRARIES} 29 | CACHE INTERNAL "cmocka link libraries" 30 | ) 31 | 32 | set(cmocka_SRCS 33 | cmocka.c 34 | ) 35 | 36 | if (WIN32) 37 | set(cmocka_SRCS 38 | ${cmocka_SRCS} 39 | cmocka.def 40 | ) 41 | endif (WIN32) 42 | 43 | include_directories( 44 | ${CMOCKA_PUBLIC_INCLUDE_DIRS} 45 | ${CMOCKA_PRIVATE_INCLUDE_DIRS} 46 | ) 47 | 48 | add_definitions(-DHAVE_CONFIG_H=1) 49 | if (CMOCKA_PLATFORM_INCLUDE) 50 | add_definitions(-DCMOCKA_PLATFORM_INCLUDE=1) 51 | endif() 52 | 53 | add_library(${CMOCKA_SHARED_LIBRARY} SHARED ${cmocka_SRCS}) 54 | 55 | target_link_libraries(${CMOCKA_SHARED_LIBRARY} ${CMOCKA_LINK_LIBRARIES}) 56 | set_target_properties( 57 | ${CMOCKA_SHARED_LIBRARY} 58 | PROPERTIES 59 | OUTPUT_NAME 60 | cmocka 61 | DEFINE_SYMBOL 62 | CMOCKA_EXPORTS 63 | ) 64 | 65 | if (NOT WIN32) 66 | set_target_properties( 67 | ${CMOCKA_SHARED_LIBRARY} 68 | PROPERTIES 69 | VERSION 70 | ${LIBRARY_VERSION} 71 | SOVERSION 72 | ${LIBRARY_SOVERSION} 73 | ) 74 | endif (NOT WIN32) 75 | 76 | install( 77 | TARGETS ${CMOCKA_SHARED_LIBRARY} 78 | RUNTIME DESTINATION ${BIN_INSTALL_DIR} 79 | LIBRARY DESTINATION ${LIB_INSTALL_DIR} 80 | ARCHIVE DESTINATION ${LIB_INSTALL_DIR} 81 | COMPONENT libraries 82 | ) 83 | 84 | if (WITH_STATIC_LIB) 85 | add_library(${CMOCKA_STATIC_LIBRARY} STATIC ${cmocka_SRCS}) 86 | 87 | set_target_properties( 88 | ${CMOCKA_STATIC_LIBRARY} 89 | PROPERTIES 90 | VERSION 91 | ${LIBRARY_VERSION} 92 | SOVERSION 93 | ${LIBRARY_SOVERSION} 94 | OUTPUT_NAME 95 | cmocka 96 | ) 97 | 98 | install( 99 | TARGETS ${CMOCKA_STATIC_LIBRARY} 100 | DESTINATION ${LIB_INSTALL_DIR} 101 | COMPONENT libraries 102 | ) 103 | endif (WITH_STATIC_LIB) 104 | 105 | if (POLICY CMP0026) 106 | cmake_policy(SET CMP0026 OLD) 107 | endif() 108 | 109 | # 110 | # In order to run tests we will need to set the approriate environment 111 | # variable so that the test program can locate its dependent DLL's. First 112 | # we want to know what directory our dependent DLL was installed into: 113 | # 114 | get_target_property(_cmocka_dir cmocka_shared LOCATION_${CMOCKA_BUILD_TYPE}) 115 | get_filename_component(_cmocka_path "${_cmocka_dir}" PATH) 116 | file(TO_NATIVE_PATH "${_cmocka_path}" _cmocka_path_native) 117 | 118 | set(CMOCKA_DLL_PATH "${_cmocka_path_native}" PARENT_SCOPE) 119 | -------------------------------------------------------------------------------- /drivers/commanderpro.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "driver.h" 20 | 21 | #include "device.h" 22 | #include "logic/print.h" 23 | #include "unsupported.h" 24 | #include "lowlevel/commanderpro.h" 25 | #include "protocol/commanderpro.h" 26 | 27 | struct corsair_lowlevel_driver corsairlink_lowlevel_commanderpro = { 28 | .init = corsairlink_commanderpro_init, 29 | .deinit = corsairlink_commanderpro_deinit, 30 | .read = corsairlink_commanderpro_read, 31 | .write = corsairlink_commanderpro_write, 32 | }; 33 | 34 | struct corsair_device_driver corsairlink_driver_commanderpro = { 35 | .name = corsairlink_commanderpro_name, 36 | .vendor = corsairlink_commanderpro_vendor, 37 | .product = corsairlink_commanderpro_product, 38 | .device_id = corsairlink_commanderpro_device_id, 39 | .fw_version = corsairlink_commanderpro_firmware_id, 40 | .temperature = 41 | { 42 | .read = corsairlink_commanderpro_temperature, 43 | .count = corsairlink_commanderpro_tempsensorscount, 44 | }, 45 | .led = 46 | { 47 | .static_color = corsairlink_unsupported_led, 48 | .blink = corsairlink_unsupported_led, 49 | .color_pulse = corsairlink_unsupported_led, 50 | .color_shift = corsairlink_unsupported_led, 51 | .rainbow = corsairlink_unsupported_led, 52 | .temperature = corsairlink_unsupported_led, 53 | }, 54 | .fan = 55 | { 56 | .count = corsairlink_commanderpro_fan_count, 57 | .speed = corsairlink_unsupported_fan, 58 | .print_mode = corsairlink_commanderpro_fan_print_mode, 59 | .profile = 60 | { 61 | .read_profile = corsairlink_commanderpro_fan_mode_read, 62 | .read_rpm = corsairlink_commanderpro_get_fan_speed_rpm, 63 | .read_pwm = corsairlink_commanderpro_get_fan_speed_pwm, 64 | .write_profile_custom = corsairlink_unsupported_fan, 65 | .write_profile_default = corsairlink_unsupported_fan, 66 | .write_profile_performance = corsairlink_unsupported_fan, 67 | .write_profile_balanced = corsairlink_unsupported_fan, 68 | .write_profile_quiet = corsairlink_unsupported_fan, 69 | .write_rpm = corsairlink_commanderpro_set_fan_speed_rpm, 70 | .write_pwm = corsairlink_commanderpro_set_fan_speed_pwm, 71 | .write_custom_curve = corsairlink_unsupported_fan, 72 | }, 73 | }, 74 | .power = 75 | { 76 | .voltage = corsairlink_commanderpro_voltage, 77 | }, 78 | }; 79 | -------------------------------------------------------------------------------- /extras/cmocka-1.1.1/INSTALL: -------------------------------------------------------------------------------- 1 | # How to build from source 2 | 3 | ## Requirements 4 | 5 | ### Common requirements 6 | 7 | In order to build cmocka, you need to install several components: 8 | 9 | - A C compiler 10 | - [CMake](http://www.cmake.org) >= 2.8.0. 11 | 12 | Note that these version numbers are version we know works correctly. If you 13 | build and run cmocka successfully with an older version, please let us know. 14 | 15 | ## Building 16 | First, you need to configure the compilation, using CMake. Go inside the 17 | `build` dir. Create it if it doesn't exist. 18 | 19 | GNU/Linux, MacOS X, MSYS/MinGW: 20 | 21 | cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug .. 22 | make 23 | 24 | On Windows you should choose a makefile gernerator with -G, for example: 25 | 26 | cmake -G "Visual Studio 12 2013" -DCMAKE_BUILD_TYPE=Debug /path/to/source 27 | 28 | You can also use the CMake GUI which is shipped with CMake. It will list all 29 | available generators for MSVC on Windows. 30 | 31 | ### CMake standard options 32 | Here is a list of the most interesting options provided out of the box by 33 | CMake. 34 | 35 | - CMAKE_BUILD_TYPE: The type of build (can be Debug Release MinSizeRel 36 | RelWithDebInfo) 37 | - CMAKE_INSTALL_PREFIX: The prefix to use when running make install (Default 38 | to /usr/local on GNU/Linux and MacOS X) 39 | - CMAKE_C_COMPILER: The path to the C compiler 40 | - CMAKE_CXX_COMPILER: The path to the C++ compiler 41 | 42 | ### CMake options defined for cmocka 43 | 44 | Options are defined in the following files: 45 | 46 | - DefineOptions.cmake 47 | 48 | They can be changed with the -D option: 49 | 50 | `cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=ON ..` 51 | 52 | ### Browsing/editing CMake options 53 | 54 | In addition to passing options on the command line, you can browse and edit 55 | CMake options using `cmakesetup` (Windows), `cmake-gui` or `ccmake` (GNU/Linux 56 | and MacOS X). 57 | 58 | - Go to the build dir 59 | - On Windows: run `cmakesetup` 60 | - On GNU/Linux and MacOS X: run `ccmake ..` 61 | 62 | ## Installing 63 | 64 | If you want to install cmocka after compilation run: 65 | 66 | make install 67 | 68 | ## Running 69 | 70 | The cmocka library can be found in the `build/src` directory. 71 | You can run the binaries in `build/examples/*` which is a 72 | are exsample tests. 73 | 74 | ## Testing 75 | 76 | As mention above you can turn on the unit tests and make it possible to easily 77 | execute them: 78 | 79 | `cmake -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=ON ..` 80 | 81 | After that you can simply call `make test` in the build directory or if you 82 | want more output simply call `ctest -V`. 83 | 84 | If you want to enable the generation of coverage files you can do this by 85 | using the following options: 86 | 87 | `cmake -DCMAKE_BUILD_TYPE=Profiling -DUNIT_TESTING=ON ..` 88 | 89 | After building it you will see that you have several coverage options in 90 | 91 | `make help` 92 | 93 | You should have `make ExperimentalCoverage` and running it will create 94 | coverage files. The result is stored in Testing directory. 95 | 96 | ## About this document 97 | 98 | This document is written using [Markdown][] syntax, making it possible to 99 | provide usable information in both plain text and HTML format. Whenever 100 | modifying this document please use [Markdown][] syntax. 101 | 102 | [markdown]: http://www.daringfireball.net/projects/markdown 103 | -------------------------------------------------------------------------------- /logic/options_fan.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | #include "logic/options.h" 20 | #include "logic/print.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | void 30 | fan_control_init( struct fan_control* settings ) 31 | { 32 | settings->channel = 0; 33 | settings->mode = 0; 34 | } 35 | 36 | void 37 | fan_suboptions_parse( char* subopts, struct fan_control* settings ) 38 | { 39 | int opt, returnCode = 0, option_index = 0; 40 | char *value, *token; 41 | uint8_t ii = 0; 42 | 43 | while ( *subopts != '\0' ) 44 | switch ( getsubopt( &subopts, fan_options, &value ) ) 45 | { 46 | case SUBOPTION_FAN_CHANNEL: 47 | sscanf( value, "%hhu", &settings->channel ); 48 | msg_debug( "FAN Channel = %u\n", settings->channel ); 49 | break; 50 | 51 | case SUBOPTION_FAN_MODE: 52 | sscanf( value, "%u", &settings->mode ); 53 | msg_debug( "FAN Mode = %u\n", settings->mode ); 54 | break; 55 | 56 | case SUBOPTION_FAN_PWM: 57 | sscanf( value, "%hhu", &settings->speed_pwm ); 58 | msg_debug( "FAN PWM = %u\n", settings->speed_pwm ); 59 | break; 60 | 61 | case SUBOPTION_FAN_RPM: 62 | sscanf( value, "%hu", &settings->speed_rpm ); 63 | msg_debug( "FAN RPM = %u\n", settings->speed_rpm ); 64 | break; 65 | 66 | case SUBOPTION_FAN_TEMPERATURES: 67 | ii = 0; 68 | token = strtok( value, ":" ); 69 | while ( token != NULL ) 70 | { 71 | if ( ii == 7 ) 72 | break; 73 | sscanf( token, "%hhu", &settings->table[ii].temperature ); 74 | msg_debug( "FAN Temperature %u: %u\n", ii, settings->table[ii].temperature ); 75 | ++ii; 76 | token = strtok( NULL, ":" ); 77 | } 78 | break; 79 | 80 | case SUBOPTION_FAN_SPEEDS: 81 | ii = 0; 82 | token = strtok( value, ":" ); 83 | while ( token != NULL ) 84 | { 85 | if ( ii == 7 ) 86 | break; 87 | sscanf( token, "%hhu", &settings->table[ii].speed ); 88 | msg_debug( "FAN Speed %d: %u\n", ii, settings->table[ii].speed ); 89 | ++ii; 90 | token = strtok( NULL, ":" ); 91 | } 92 | break; 93 | 94 | default: 95 | /* Unknown suboption. */ 96 | msg_info( "Unknown suboption `%s'\n", value ); 97 | break; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /lowlevel/coolit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OpenCorsairLink. 3 | * Copyright (C) 2017-2020 Sean Nelson 4 | 5 | * OpenCorsairLink is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * any later version. 9 | 10 | * OpenCorsairLink is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenCorsairLink. If not, see . 17 | */ 18 | 19 | /*! \file lowlevel/coolit.c 20 | * \brief Lowlevel Routines for CoolIT USB HID based devices 21 | */ 22 | #include "lowlevel/coolit.h" 23 | 24 | #include 25 | #include 26 | 27 | #define HID_SET_REPORT 0x09 28 | #define HID_GET_REPORT 0x01 29 | #define HID_REPORT_TYPE_INPUT 0x01 30 | #define HID_REPORT_TYPE_OUTPUT 0x02 31 | #define HID_REPORT_TYPE_FEATURE 0x03 32 | #define TIMEOUT_DEFAULT 1000 33 | #define INTERFACE_NUMBER 0 34 | #define INTERRUPT_IN_ENDPOINT 0x81 35 | 36 | // Values for bmRequestType in the Setup transaction's Data packet. 37 | static const int CONTROL_REQUEST_TYPE_IN = 38 | LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE; 39 | static const int CONTROL_REQUEST_TYPE_OUT = 40 | LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE; 41 | 42 | /*! USB HID Init routine 43 | * USB HID Init routine is empty 44 | * @param[in] handle for the data 45 | * @param[in] device endpoint for the data 46 | * @return 0 47 | */ 48 | int 49 | corsairlink_coolit_init( struct libusb_device_handle* dev_handle, uint8_t endpoint ) 50 | { 51 | return 0; 52 | } 53 | 54 | /*! USB HID De-Init routine 55 | * USB HID De-Init routine is empty 56 | * @param[in] handle for the data 57 | * @param[in] device endpoint for the data 58 | * @return 0 59 | */ 60 | int 61 | corsairlink_coolit_deinit( struct libusb_device_handle* dev_handle, uint8_t endpoint ) 62 | { 63 | return 0; 64 | } 65 | 66 | /*! USB HID Lowlevel Write 67 | * USB HID Lowlevel Write uses a control transfer 68 | * @param[in] handle for the data 69 | * @param[in] device endpoint for the data 70 | * @param[in] data to send 71 | * @param[in] length of data to send, in bytes 72 | * @return 0 73 | */ 74 | int 75 | corsairlink_coolit_write( 76 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ) 77 | { 78 | int bytes_transferred; 79 | int rr; 80 | 81 | rr = libusb_control_transfer( 82 | dev_handle, CONTROL_REQUEST_TYPE_OUT, HID_SET_REPORT, /** HID Set_Report */ 83 | ( HID_REPORT_TYPE_OUTPUT << 8 ) | 0x00, INTERFACE_NUMBER, data, length, TIMEOUT_DEFAULT ); 84 | 85 | return rr; 86 | } 87 | 88 | /*! USB HID Lowlevel Read 89 | * USB HID Lowlevel Write uses a control transfer 90 | * @param[in] handle for the data 91 | * @param[in] device endpoint for the data 92 | * @param[out] data received 93 | * @param[in] length of data to received, in bytes 94 | * @return 0 95 | */ 96 | int 97 | corsairlink_coolit_read( 98 | struct libusb_device_handle* dev_handle, uint8_t endpoint, uint8_t* data, int length ) 99 | { 100 | int bytes_transferred; 101 | int rr; 102 | 103 | rr = libusb_interrupt_transfer( 104 | dev_handle, endpoint, data, length, &bytes_transferred, TIMEOUT_DEFAULT ); 105 | 106 | return rr; 107 | } 108 | --------------------------------------------------------------------------------