question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QR Code Model 1 vs Model 2 Incorrect Printing

See original GitHub issue

I’ve noticed that QRCode Model 1 is not readable. And Model 2 looks to be Model 1 when visually comparing the printed code with a Model 1 code printed via this pre ESC-POS implementation:

String text = "test";

printerBuffer[0] = 0x1d;
printerBuffer[1] = 0x28;
printerBuffer[2] = 0x6b;
printerBuffer[3] = 4;
printerBuffer[4] = 0;
printerBuffer[5] = 0x31;
printerBuffer[6] = 0x41;
printerBuffer[7] = 0x49; // 0x49 - model 1 / 0x50 - model 2
printerBuffer[8] = 0x00;
serialPort.Write(printerBuffer, 0, 9);

printerBuffer[0] = 0x1d;
printerBuffer[1] = 0x28;
printerBuffer[2] = 0x6b;
printerBuffer[3] = 3;
printerBuffer[4] = 0;
printerBuffer[5] = 0x31;
printerBuffer[6] = 0x45;
printerBuffer[7] = 0x33; // 0x33 - Error correction level H (30% recovery capacity)
serialPort.Write(printerBuffer, 0, 8);

int len = 3 + text.Length;

printerBuffer[0] = 0x1d;
printerBuffer[1] = 0x28;
printerBuffer[2] = 0x6b;
printerBuffer[3] = (byte)(len % 256);
printerBuffer[4] = (byte)(len / 256);
printerBuffer[5] = 0x31;
printerBuffer[6] = 0x50;
printerBuffer[7] = 0x30;

char[] strChars = text.ToCharArray();
for (int i = 0; i < text.Length; i++) {
    printerBuffer[8 + i] = (byte)strChars[i];
}
serialPort.Write(printerBuffer, 0, 8 + text.Length);

printerBuffer[0] = 0x1d;
printerBuffer[1] = 0x28;
printerBuffer[2] = 0x6b;
printerBuffer[3] = 3;
printerBuffer[4] = 0;
printerBuffer[5] = 0x31;
printerBuffer[6] = 0x51;
printerBuffer[7] = 0x30;
serialPort.Write(printerBuffer, 0, 8);

This is the equivalent ESC-POS call:

printer.Write(E.Print2DCode(TwoDimensionCodeType.QRCODE_MODEL2, text, Size2DCode.SMALL, CorrectionLevel2DCode.PERCENT_30));

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
igorocamposcommented, Sep 30, 2020

Please read some more about this in #79

1reaction
neon-devcommented, Aug 28, 2020

Don’t trust this legacy code I posted too much. It was never used in production and I just inherited the project, so no guarantees for correctness. Now that you say it, to me it looks like the byte stream is incorrect and 0x49 should in fact be 49 / 0x31, since all other codes for commands I’ve seen were decimals.

I cannot test anything right now, so the only thing I can assure is that codes with QRCODE_MODEL1 failed to scan but QRCODE_MODEL2 can be scanned successfully. Whoever else has access to a printer should verify first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

QR Code Model 1 and Model 2 | QRcode.com
QR Code Model 1 Model 2​​ QR Codes that are printed on a curved surface or whose reading images are distorted due to...
Read more >
9 Reasons Why Your QR Code is Not Working
This happens when you download QR Codes in an incorrect format and resize them- which can lead to a blurred QR Code. A...
Read more >
Common QR Code Scanning Problems and How to Fix Them
Typical QR Code scanning problems & their solutions; #1 Not enough space around the border; #2 Design color mismatch; #3 Hidden by material ......
Read more >
6 reasons why your QR code is not working
1. Do not invert QR Code Colors · 2. Give your QR Code colors enough contrast · 3. Don't create blurry QR Codes...
Read more >
Unable to Scan QR Code? Here's How to Fix a QR Code.
If a QR code won't scan or doesn't work, we got you. Here's a rundown of common QR code issues that leave folks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found