Dongle is working, I can see data with my oscilloscope, and windows program was able to control light. How can one turn light ON/OFF with IOW24-DG + LW14-02MOD?
Here is my code so far:
Code: Select all
void IOWarrior::iowkit_connect()
{
    // Open device
    devHandle = IowKitOpenDevice();
    if (devHandle == NULL) {
        qWarning() << "Failed to open device";
        return;
    }
    // Get number of IOWs in system
    ULONG numIows = IowKitGetNumDevs();
    qDebug() << "found " << numIows << "devices";
    devHandle = IowKitGetDeviceHandle(1);
    PWCHAR snt[9];
    DWORD pid;
    IowKitGetSerialNumber(devHandle, *snt);
    pid = IowKitGetProductId(devHandle);
    IowKitSetWriteTimeout(devHandle, 1000);
    IOWsetIOWtoI2Cmode();
}
void IOWarrior::IOWsetIOWtoI2Cmode() {
    IOWKIT_SPECIAL_REPORT report;
    //sets IOW to I2C mode
    report = {
        0x01, // report ID = 1
        {
            0x01, // enable I2C mode
            0x00, // all flags 0 (Bit 7   - Disable Pull Ups (1 = disable) - IOW24 only (for 3.3V operation)
            //                    Bit 6   - Use Sensibus Protocol (1 = enable)
            //                    Bit 5:0 - unused, write zero
            0x00, // max timeout of 256x500 microsec (=0.128 sec)
            0x00, // must be zero
            0x00, // must be zero
            0x00, // must be zero
            0x00 //  must be zero
        }
    };
    ULONG ikw = IowKitWrite(devHandle, IOW_PIPE_SPECIAL_MODE, (PCHAR)&report, IOWKIT_SPECIAL_REPORT_SIZE);
}
void IOWarrior::IOWwriteData() {
    IOWKIT_SPECIAL_REPORT report;
    report.ReportID = 0x02;
    report.Bytes[0] = 0xC3; // flags
    report.Bytes[1] = 0x23; // LW14_I2CADR, I2C slave Addr
    report.Bytes[2] = 0x00; // LW14_CC_OFF // LW14_CC_MAX_LEVEL = 0x05
    report.Bytes[3] = 0x00;
    report.Bytes[4] = 0x00;
    report.Bytes[5] = 0x00;
    report.Bytes[6] = 0x00;
    auto ikw = IowKitWrite(devHandle, IOW_PIPE_SPECIAL_MODE, (PCHAR)&report, IOWKIT_SPECIAL_REPORT_SIZE);
    qDebug() << "Res: " << ikw; // always returns '8'
}
main() {
    iowkit_connect();
    IOWwriteData(); // <- I can see data coming out from I2C with oscilloscope, but nothing on DALI bus
}