adafruit / Adafruit_Adalink

Python wrapper for Segger's J-Link Commander & STMicro STLink V2 to flash various ARM MCUs
MIT License
125 stars 33 forks source link

TypeError: cannot use a string pattern on a bytes-like object #30

Open Gimpel-K67 opened 3 years ago

Gimpel-K67 commented 3 years ago

First big thanks for the tool it saved me a lot of work.

System Linux Ububntu 20.04 Programmer stlink-V2-1 Pyhton 3.8.2

When I try to run the code and it checks the open ocd version I get the TypeError. I managed to solve the issues my self and want so share the solution.

The problem was that python interpreted the shell output as bytlike. But the version checking in your script works with string operation. So I added output = output.decode('UTF-8') before the re.search() function in the stlink.py file. This way the output is converted to an string and the rest of the script works like a charm.

As an improvement I suggest that the the programmer the user want to use should be the argument for the -p option. My problem was that I only own an ST NUCLEO with integrated stlink-V2-1. So I had to search through your script to change the source code manually. Since open ocd supports a lot of different programmer this would add a lot of improvement to the tool.