VCTLabs / cp210x-program

EEPROM tool for Silabs CP210x USB-Serial adapter
GNU Lesser General Public License v2.1
53 stars 21 forks source link

Fails to read ini config files #9

Open twischer opened 3 years ago

twischer commented 3 years ago
./cp210x-program -I testdata/cp2102-orig.ini --write-cp210x

Traceback (most recent call last): File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 239, in main() File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 235, in main options.action(options) File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 169, in write_cp210x values = valuefile.read_file(input_file(options.ini_input)) File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/cp210x/valuefile.py", line 87, in read_file cp.readfp(fp) File "/usr/lib/python3.9/configparser.py", line 763, in readfp self.read_file(fp, source=filename) File "/usr/lib/python3.9/configparser.py", line 718, in read_file self._read(f, source) File "/usr/lib/python3.9/configparser.py", line 1093, in _read raise DuplicateOptionError(sectname, optname, configparser.DuplicateOptionError: While reading from 'testdata/cp2102-orig.ini' [line 15]: option '1500000' in section 'baudrate table' already exists

SJLC commented 3 years ago

It looks like those 1500000 lines got accidentally duplicated, and probably an earlier version of configparser was less picky

SJLC commented 3 years ago

Try loading the latest version of the example config

twischer commented 3 years ago

Looks better thanks. But it is failing at another point, now.

$ ./cp210x-program -I testdata/cp2102-orig.ini --write-cp210x
Traceback (most recent call last):
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 239, in <module>
    main()
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 235, in main
    options.action(options)
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 173, in write_cp210x
    dev.set_values(values)
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/cp210x/cp210x.py", line 358, in set_values
    getattr(self, "set_" + name) (value)
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/cp210x/cp210x.py", line 312, in set_product_string
    self._set_config_string(REG_PRODUCT_STRING, product_string,
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/cp210x/cp210x.py", line 217, in _set_config_string
    self._set_config(value, data=chr(desc_size) + "\x03" + encoded)
TypeError: can only concatenate str (not "bytes") to str
SJLC commented 3 years ago

Just merged a pull request to fix this error; want to try again?

twischer commented 3 years ago

Even better but not final

$ ./cp210x-program -I testdata/cp2102-orig.ini --write-cp210x
Traceback (most recent call last):
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 239, in <module>
    main()
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 235, in main
    options.action(options)
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/./cp210x-program", line 173, in write_cp210x
    dev.set_values(values)
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/cp210x/cp210x.py", line 358, in set_values
    getattr(self, "set_" + name) (value)
  File "/home/timo/Beschreibungen/HOWTOs/usb2serial/cp210x-program/cp210x/cp210x.py", line 261, in set_baudrate_table
    assert len(baudrates) == SIZE_BAUDRATES
AssertionError

But anyway already thanks a lot for the tool and your fast support.

sarnold commented 2 years ago

possibly better so far on the packaging branch:

$ source .tox/py38/bin/activate
(py38) $ ./cp210x-program -I testdata/cp2102-orig.ini --write-cp210x
No devices found

BUT, there's stll a bug in there somewhere, ie, the duplicate baud line is still generated.

sarnold commented 2 years ago

@twischer Can you try again on latest master? I still don't have a legacy cp2102 (or 3) device for testing, so if you can give it spin that would be super helpful! :penguin: