Commit c1088c5f authored by Gallacchi Mattia's avatar Gallacchi Mattia
Browse files

Fix dll copy


Add read_register

Signed-off-by: default avatarmattia.gallacchi <mattia.gallacchi@he-arc.ch>
parent 126941d1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ if (UNIX)
    include_directories(${I2C_INCLUDE_DIR})
elseif(WIN32)
    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/MCP2221_DLL/unmanaged/dll)
    set(MCP_DLL "${CMAKE_CURRENT_SOURCE_DIR}/MCP2221_DLL/unmanaged/dll/mcp2221_dll_um_x64.dll" CACHE INTERNAL "Path to MCP2221 DLL")
endif()

include_directories(lib)
+10 −1
Original line number Diff line number Diff line
@@ -123,8 +123,17 @@ namespace MCP2221A {

    void I2CMaster::read_register(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data, size_t length)
    {
        // Windows implementation to read register
        try {
            send(slave_addr, &reg_addr, 1);
        } catch (const I2CMasterException &e) {
            throw I2CMasterException("Failed to write register address before reading: " + std::string(e.what()));
        }

        try {
            receive(slave_addr, data, length);
        } catch (const I2CMasterException &e) {
            throw I2CMasterException("Failed to read register data: " + std::string(e.what()));
        }
    }

    std::vector<int> I2CMaster::get_slaves_addresses(bool force_scan)