在 Linux 初始化脚本中使用 STDIN
我目前正在开发一个需要读取键盘输入的嵌入式系统(实际上 - 它需要读取键盘模拟的条形码扫描仪)。
我使用 SheevaPlug 和 Debian Squeeze 作为硬件部分,并且使用一个非常基本的 init 脚本来启动负责执行业务逻辑的 python 程序。
正是该脚本需要读取键盘输入。
我们已经开发了基本上是全功能计算机的开发版本,带有屏幕和其他东西,它工作得相当不错 - 但它并不是真的可以接受 - 但在这里我并没有真正理解出了什么问题(尽管我承认我有点预期如此)。
所以我想知道当 init 启动它时如何以某种方式将键盘连接到我的脚本的 STDIN。
或者,如果有人知道一个 python 库,它可以让我完全绕过问题并直接从 input/eventX 读取,我会很感兴趣。
提前致谢
I'm currently working on an embedded system that needs to read keyboard input (Actually - it needs to read a keyboard-emulated barcode scanner).
I'm using a SheevaPlug with Debian Squeeze for the hardware part, and I'm using a pretty basic init script that fires a python program that's in charge of doing the business logic.
It's that script that needs to read keyboard input.
We've worked on development versions that were basically full featured computers, with a screen and stuff, and it worked pretty OK - but it's not really acceptable -, but here I don't really grasp what's wrong (Although I admit that I kinda expected it).
So I'd like to know how it would be possible to somehow connect the keyboard to my script's STDIN when init starts it.
Alternatively, I'd be interested if someone knows a python library that would allow me to bypass the problem entirely and read directly from input/eventX.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这个(但要小心,可以更改 /dev/input/event0 来代替重新插入多个 USB HID 设备):
try this (but be carefull /dev/input/event0 can be changed in place of repluging multiple USB HID-devices):