QR encoder Day 4
Todays mission
To find the edge cases and test yesterdays code more fully.
In order to find the edge cases I am going to first make a small amendment to yesterdays code.
In order to make sure that a message will fit into a QR code it will be necessary to check that the message fits into at least a version 40 QR code. In qrc.getSizeNumber() it is possible if the message wont fit into a normal container to step up and ask for a version 41 code (too big for a version 40 code). This is obviously wrong, and needs to raise a value error.
Maybe this should raise the error before it sets the size, but ill keep this in mind if problems are caused later.
I will need to comment this out for finding the edge cases.
This is a separate test which opens up a file, and makes a message. It progressively makes the message longer in a loop. If the message, when encoded makes a larger version QR code than the one previously then this will trigger the line to be written in the sizetestdata.txt file.
This test yields the following information in a text file:
msg of length 1 generates a version 1 code msg of length 59 generates a version 2 code msg of length 102 generates a version 3 code msg of length 164 generates a version 4 code msg of length 236 generates a version 5 code msg of length 318 generates a version 6 code msg of length 409 generates a version 7 code msg of length 467 generates a version 8 code msg of length 577 generates a version 9 code msg of length 697 generates a version 10 code msg of length 826 generates a version 11 code msg of length 965 generates a version 12 code msg of length 1114 generates a version 13 code msg of length 1273 generates a version 14 code msg of length 1393 generates a version 15 code msg of length 1568 generates a version 16 code msg of length 1755 generates a version 17 code msg of length 2000 generates a version 18 code msg of length 2158 generates a version 19 code msg of length 2374 generates a version 20 code msg of length 2600 generates a version 21 code msg of length 2770 generates a version 22 code msg of length 3015 generates a version 23 code msg of length 3269 generates a version 24 code msg of length 3533 generates a version 25 code msg of length 3807 generates a version 26 code msg of length 4090 generates a version 27 code msg of length 4382 generates a version 28 code msg of length 4606 generates a version 29 code msg of length 4918 generates a version 30 code msg of length 5239 generates a version 31 code msg of length 5570 generates a version 32 code msg of length 5911 generates a version 33 code msg of length 6262 generates a version 34 code msg of length 6622 generates a version 35 code msg of length 6898 generates a version 36 code msg of length 7277 generates a version 37 code msg of length 7666 generates a version 38 code msg of length 8064 generates a version 39 code msg of length 8472 generates a version 40 code msg of length 8890 generates a version 41 code
Two things are interesting straight away. Firstly the smallest message size that requires a version 1 QR code is a message with a single digit - This is good, this means that the lower limit for the first one is ok.
However referring to the original specification (http://raidenii.net/files/datasheets/misc/qr_code.pdf) Section 7.1d states that the maximum number of numeric data that can be encoded is 7089 characters, which should mean that a ver 41 (too large for ver 40) should appear as 7090 characters.
Tommorrow I will need to re read the specification to check if I am reading this wrongly, or if this is a mis- implementation.
Comments
Post a Comment