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

Runtime error when switching from 'M' error correction to 'H' #8

Closed
zepplock opened this issue Nov 24, 2015 · 4 comments
Closed

Runtime error when switching from 'M' error correction to 'H' #8

zepplock opened this issue Nov 24, 2015 · 4 comments
Labels

Comments

@zepplock
Copy link

If I switch code encode(Bin, 'M'). to encode(Bin, 'H'). in qrcode.erl.

I get this:

** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in :qrcode_matrix.encode_bits0/2
        (qrcode) src/qrcode_matrix.erl:169: :qrcode_matrix.encode_bits0([:d, :d, :d, :d, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1], <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 0::size(1)>>)
        (qrcode) src/qrcode_matrix.erl:164: :qrcode_matrix.encode_bits/3
        (qrcode) src/qrcode_matrix.erl:53: :qrcode_matrix.finalize/5
        (qrcode) src/qrcode.erl:43: :qrcode.encode/2
        (qrcode) src/qrcode_png.erl:50: :qrcode_png.run/1
        (shoqr) web/controllers/v1/session_controller.ex:46: Shoqr.V1.SessionController.show_qr/2
        (shoqr) web/controllers/v1/session_controller.ex:11: Shoqr.V1.SessionController.phoenix_controller_pipeline/2
        (shoqr) lib/phoenix/router.ex:265: Shoqr.Router.dispatch/2
        (shoqr) web/router.ex:11: Shoqr.Router.do_call/2
        (shoqr) lib/shoqr/endpoint.ex:11: Shoqr.Endpoint.phoenix_pipeline/1
        (shoqr) lib/plug/debugger.ex:90: Shoqr.Endpoint."call (overridable 3)"/2
        (shoqr) lib/phoenix/endpoint/render_errors.ex:34: Shoqr.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Note that switching to L or Q works fine.

@komone
Copy link
Owner

komone commented Dec 20, 2015

Root cause is incomplete padding of data for error correction blocks in qrcode module

@zepplock
Copy link
Author

Thanks for looking into this Steve!

komone added a commit that referenced this issue Dec 21, 2015
Resolves incomplete padding on multi-ecc blocks resulting in atoms in
final bitmap
Should cope with all circumstances.
Also exposes encode/2
@komone
Copy link
Owner

komone commented Dec 21, 2015

Vlad -- do you have tests you could apply? -- I think this copes with all circumstances and passes my local testing

@zepplock
Copy link
Author

This is issue is fixed. I can compile and generate QRs under all correction codes. Can be closed.

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

No branches or pull requests

2 participants