Coder Social home page Coder Social logo

2D Barcodes (QR-Codes) about barcode-server HOT 3 CLOSED

oezgan avatar oezgan commented on May 31, 2024
2D Barcodes (QR-Codes)

from barcode-server.

Comments (3)

markusressel avatar markusressel commented on May 31, 2024

Hey @oezgan, glad barcode-server is useful.
Did you try just removing the _KP from the startswith?

Current:

elif event.keycode.startswith("KEY_KP"):
  if len(event.keycode) == 7:
    character = event.keycode[-1]

New:

elif event.keycode.startswith("KEY_"):
  if len(event.keycode) == 7:
    character = event.keycode[-1]

Maybe this works with more than I had anticipated.
I am not that familiar with keyboard keycode bindings and stuff. If this doesn't work, we can just use your code, looks find to me :)

from barcode-server.

oezgan avatar oezgan commented on May 31, 2024

Hey @markusressel
I am afraid my changes are not that simple :-)
first of all I moved the elifs one indent out such that they are part of the outer if...
elif event.keycode == "KEY_SPACE": character = ' ' elif event.keycode.startswith("KEY_KP"): if len(event.keycode) == 7: character = event.keycode[-1] elif event.keycode == "KEY_ASTERISK": character = '*'
and I removed all the KPs from the keycodes example:
Current:
KEY_KPEQUAL
New:
KEY_EQUAL

this solves the mentioned keycode problem.

I also created a dictionary with the US_EN keyboard mappings
US_EN_UPPER_DICT = { "``": "~", "1":"!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&", "8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ",": "<", ".": ">", "/": "?", ";": ":", "'": "\"", "\\": "|", "[": "{", "]": "{" }

at the end of the _on_key_event method I added the following:

if self._shift or self._caps:
character = character.upper()
if character in US_EN_UPPER_DICT.keys():
character = US_EN_UPPER_DICT[character]

this solves the problem that the barcode scanner delivers the $ sign with SHIFT+4
at least my barcode scanner delivers that with this combination. On my research (googling) I found out that almost all barcode readers (1D or 2D) deliver the characters as keyboard keypresses so this seems to make sense.
As I said I am not a coder (anymore) and I do not know much about keycodes and mappings either.
I believe though creating a dictionaries for ASCII Keycodes and then map them directly is the better way to go.
I will try that out if I find the time...
Also I believe a dev.grab() before the loop will grant exclusive access to the scanner device...

So here is my dilemma:

  • Should I modify your server for reading CovPass QR Codes into a DB with the now working hot fix of mine ?
    or
  • Should I modify the keyevent handler and then modify the server into a QR code server for CovPass

:-) I also need time for this of course...
Anyway for now it works for me

from barcode-server.

markusressel avatar markusressel commented on May 31, 2024

@oezgan Sorry I forgot to answer this after merging.

Yes, I started this project because I wanted to read simple 2D barcodes, numbers only.
However, there is no reason to not support other types of barcodes as well.
As long as its only keypresses, it should be fairly straight forward to support other inputs.
I have not done any testing on this myself though, and probably wont in the near future, since I currently have no personal use case for this.

About the "grabbing": barcode-server already does this, but I suppose there are cases where it doesn't work as expected.

Not sure about storing scanned items into a DB, barcode-server was meant more as a relay than a database interface.
I don't want the burden of integrating a multitude of different database protocols into a simple barcode-server.
If that is a functionality you need, then I would suggest using another service application or writing one yourself, that receives the barcodes sent by barcode-server (via one of the supported methods) and stores then stores them into a DB and/or handles them otherwise. node-red would probably be an option here (although I don't use or like the project).

from barcode-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.