[BUG] QR Code Wizard

When you go to small sizes of BAR codes, then the size should be matched to the raster of the printer. A QR code that has pixels of 2x2 on the printer can be much more readable then a QR code which maps to 2.723X2.723 pixels on the raster of the printer.

1 Like

Hi

I’ve tried reinstalling a Windows 10 computer and getting the same result. Tell my friend, he is the one who recommends KiCad, since he soon has to make a large series of PCBs with QR codes (my design is a small series), he has tested it on his computer and gets the same bug. He has also performed a clean installation on another computer, with Windows 10 Pro from a device created with Media Tool (updated today), KiCad downloaded from the official website and latest version, without installing Python or other software and gets the same result, the program freezes for several minutes until it closes.

I don’t know what else to try to see if we can find the error.

Thanks !

I think I’m very close.
I had a look at the source code at:
/usr/share/kicad/scripting/plugins/qrcode_footprint_wizard.py

And though my Python knowledge is minimal, the script is only 179 lines and Python is relatively readable. First I found, line 107 weird, where it did the “border” routine even if the border was 0, but that turned out to be a dud. Weird thing was that I did manage to get it to generate a new QR code, which motivated me to do more experimentation.

After further experimentation, it turns out that if you set “Qr Pixel Width” to “1”, or another integer (= whole number), then generation of QR code works on my machine. If I set it to a non-integer, then the Footprint Wizard crashes.

You can apparently resize an existing QR code, but during generation of a new QR code, the script fails if the size is a floating point number.
So if you want a QR code with pixel size of 0.5mm then:

  1. Set: “Qr Pixel Width” to 1mm.
  2. Change “Contents” string.
  3. Set: “Qr Pixel Width” to 0.5mm.

Can someone please confirm?
(Or even better: fix this in those 179 lines of Python. I get a bit lost there).

1 Like

Nice work @paulvdh ! my scriptt has this date included on line 16

C:\Program Files\KiCad_v5_1_6\share\kicad\scripting\plugins\qrcode_footprint_wizard.py

last change: 2017, Jan 4.

is it the same for yours ?

EDIT: That is also the latest version in Gitlab
https://gitlab.com/kicad/code/kicad-footprint-wizards/-/blob/master/qrcode_footprint_wizard.py

EDIT: @kid @paulvdh does your UI shows ‘,’ as decimal separator or ‘.’ ? Can it be problems with the locale?

EDIT: YES! I changed the kicad language to German an then the “Qr Pixel Width” is shown as ‘0,5’, now I can reproduce the error!

Yep, same date.
So it just crashes on dot versus comma in a text string. Gosh. Smells like a lack of exception handling…
I hate meddling with locale stuff, so I mostly ignore it. I usually set my PC to US-English, which should use dots, but KiCad won’t let me enter dots.

Then I set KiCad to “Dutch” via:
KiCad / Preferences / Set Language / Dutch which does use commas, and it still only lets me enter commas and crashes.
KiCad’s policy is to allow either dots or comma’s as decimal separator.
I have not checked if this is alread being handled in the big V6 update.

Then I tried some other of the Footprint wizards and 3 of them thow an exception at the moment: S-DIP, SOIC and BGA.

Just this week I switched to (yet) another PC, that may have something to do with it.

Tried them all:
S-DIP:
image

SOIC: Same: "TypeError: super(type, obj): obj must be an instance or subtype of type.
QFP: No error.
BGA: Same: "TypeError: super(type, obj): obj must be an instance or subtype of type.
QFN: No error.
QR: No error on first run, but …
Touch Slider: No error.
Circular Pad Array: No error.
Micromatch SMD: No error.
Barcode US-39: No error.
FPC(SMT connector): No error.
ZIP: No error.
ZOIC: No error.

@John_Pateman Yes, try those steps before I discovered that KiCad had a QR generation plugin, because the footprint it generated was not recognized by a QR reader, I tried several parameters.

@paulvdh Yeah ! Making those changes works correctly. Great, you’re a hacker!

Including this ( .replace(',', '.') ) somewhere in the plugin?

Thanks !

The problem is tha if your PC locale is English but you set kicad in another language where the decimal separator is a comma, then kicad takes care that you can only use commas. I set kicad’s language to English for this reason and because I’ve encountered this bug before…

1 Like
commit f7b30bf39721467bb787101e31a11103933d67ff (HEAD -> master, origin/master, origin/HEAD)
Author: jean-pierre charras <jp.charras@wanadoo.fr>
Date:   Tue Sep 8 18:19:28 2020 +0200

    FOOTPRINT_WIZARD_FRAME::ParametersUpdated(): fix a reentering issue
    On wxWidgets 3.0.5, in some cases calling ReCreateParameterList() generates
    a EVT_GRID_CMD_CELL_CHANGED that call ParametersUpdated() and creating
    an infinite loop
    Note also it happens **only for languages using a comma** instead of a point
    for floating point separator
    It does not happen on wxWidgets 3.1.4

EDIT: “master” means the fix is for 5.99. We’ll see if this will included for 5.1.

2 Likes

Amazed by the quick fix.
Until this trickles through, us lowly users can not do much more then change the default on line 32 in the QR code script to a whole number:

This would 2 small things:

  1. It works with “default” settings.
  2. If a user changes the width, and then it crashes, the user may get a clue that it has something to do with that parameter.

It was taken into 5.1 branch, too.

1 Like

My phone reads KiCad QR codes.
Getting the screen colours right to be read is the challenge

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.