Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to read ini config files #9

Open
twischer opened this issue Jan 5, 2021 · 7 comments
Open

Fails to read ini config files #9

twischer opened this issue Jan 5, 2021 · 7 comments

Comments

@twischer
Copy link
Contributor

twischer commented Jan 5, 2021

./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
Copy link
Member

SJLC commented Jan 16, 2021

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

@SJLC
Copy link
Member

SJLC commented Jan 16, 2021

Try loading the latest version of the example config

@twischer
Copy link
Contributor Author

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
Copy link
Member

SJLC commented Jan 22, 2021

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

@twischer
Copy link
Contributor Author

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
Copy link
Member

sarnold commented Feb 23, 2022

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
Copy link
Member

sarnold commented Apr 11, 2022

@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! 🐧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants