-
Notifications
You must be signed in to change notification settings - Fork 29
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
QR reader with hidrwa0 and hidraw1 #29
Comments
hey @zapicoj not sure if you figured this out already but I'm also using this library with a QR reader that creates
|
Hi Tomas,
Thank you for replying to my comment. Indeed your answer is the solution to
my original question. I didn`t know that kind of syntax.
Appreciate very much your answer.;)
I resolved my issue on another way, using the RPi keyboard node.
Here is the copy of my function (I found it on internet), just in case you
want to know the details, you can import it into node red:
[
{
"id": "1aae99c8a6d9f0ad",
"type": "rpi-keyboard",
"z": "454171a247bb04bd",
"g": "85114a1a4ce0b3dc",
"name": "",
"x": 1120,
"y": 720,
"wires": [
[
"ea374af58172ab1e",
"1b508884ef16b3f2"
]
]
},
{
"id": "ea374af58172ab1e",
"type": "function",
"z": "454171a247bb04bd",
"g": "85114a1a4ce0b3dc",
"name": "read QR",
"func": "if (msg.payload != 28 && global.get(\"QR_flag\") ){\n
global.set(\"myQR\", global.get(\"myQR\") + msg.payload + \" \") //store
sequence's key until find \"enter\" key (28)\n}\nelse if (msg.payload == 28
&& global.get(\"QR_flag\")){\n global.set(\"myQR\", global.get(\"myQR\")
+ \"28\")\n global.set(\"QR_flag\", false)\n \n
setTimeout(function () {\n global.set(\"QR_flag\", true)\n },
3000);\n \n node.send([{ payload: decode_kbcode(global.get(\"myQR\"))
}])\n\n}\nreturn\n\n//************** function to convert sequence's key
into a string ***********************\nfunction decode_kbcode(kbcode) {\n
var cases = [\" 1234567890-= qwertyuiop[] asdfghjkl;'# zxcvbnm,./\",\n
' !\"£$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:@~ ZXCVBNM<>?'],\n
key = \"\",\n upper = 0;\n\n kbcode.split(\" \").forEach((code,
index) => {\n if (code == 28) {\n global.set(\"myQR\",
\"\");\n return ;\n }\n else if (code == 42) upper
= upper === 0 ? 1 : 0;\n else if ((upper + index) % 2 === 0) key +=
cases[upper].substr(code, 1);\n })\n return key\n}\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1290,
"y": 720,
"wires": [
[
"5cf9cab27cc30c30",
"eea5c45d33e80e81"
]
]
}
]
…On Tue, Nov 16, 2021 at 3:58 PM Tomás Migone ***@***.***> wrote:
hey @zapicoj <https://github.com/zapicoj> not sure if you figured this
out already but I'm also using this library with a QR reader that creates
hidraw0 and hidraw1. You can use the following syntax:
let lines = new KeyboardLines({ path: '/dev/hidraw1' })
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYETEU4N4TOF4OC2XMVMW3UMJWSTANCNFSM5DATRM3Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to force the library to read from hidraw1 ?
I'm using the library in a RPi4, node-red 2.05, with an Aibecy QR reader and it's working right, this device appears, in /dev, like hidraw0. The problem arise when I connect an MP2600 QR reader (has no brand on the box) in the place of the Aibecy. This new device shows two hidraws on the /dev. The hidraw0 and hidraw1. As per what I observed with cat /dev/hidraw1, it communicates through hidraw1. The hidraw0 is always in silence. I'm not able to read any data in node red. it seems like the library (node-red-stream) wait for data coming from hidraw0. This is why my question in line 1.
Appreciate any comment or work around to resolve the issue
kind regards.
zapicoj
The text was updated successfully, but these errors were encountered: