bloguetronica / cp2130-conf

CP2130 Configurator (cp2130-conf) is an application that can be used to configure CP2130 devices, including VID, PID, as well as other descriptors. Most importantly, the application allows you to configure pin functions and states.
GNU General Public License v3.0
1 stars 1 forks source link

Device disconnects after writing a new serial number with non-ASCII characters #1

Closed samuelfmlourenco closed 2 years ago

samuelfmlourenco commented 2 years ago

The device is not found after pressing "Write", but only when odd characters were inserted in the serial number field. The application writes the serial number correctly, which can be confirmed by accessing the device again. However, the serial number is not being passed correctly, when reopening the device after reset. This is most likely a conversion issue, because CP2130::open() can only handle ASCII serial strings, which are normally provided by CP2130::listDevices() when opening or reopening the device manually from the device selection window.

Moreover, CP2130::listDevices() returns a string where the odd characters were substituted by "?", and that string is accepted by CP2130::open(). The solution (yet to be tested) requires manipulating the string being passed, so as to replace odd characters with "?".

samuelfmlourenco commented 2 years ago

In file "configuratorwindow.cpp", line 364:

serialstr_ = editedConfig_.serial;

Should be replaced with:

serialstr_ = editedConfig_.serial.toLatin1();

Function should be rewritten to:

// Writes the serial descriptor to the CP2130 OTP ROM
void ConfiguratorWindow::writeSerialDesc()
{
    int errcnt = 0;
    QString errstr;
    cp2130_.writeSerialDesc(editedConfig_.serial, errcnt, errstr);
    opCheck(tr("write-serial-desc-op"), errcnt, errstr);  // The string "write-serial-desc-op" should be translated to "Write serial descriptor"
    if (!configerr_) {
        serialstr_ = editedConfig_.serial.toLatin1();  // If the previous operation was successful, it is safe to assume that the serial string changed to the new value (the conversion to ASCII was implemented in version 1.1 as a patch)
    }
    requiresReset_ = true;
}

This solution was confirmed to be working and will be implemented in the next release.

samuelfmlourenco commented 2 years ago

Applied fix in version 1.1.