简体   繁体   English

适用于OpenWrt的Python Evdev绑定

[英]Python Evdev binding for OpenWrt

Good day, 美好的一天,

I'm a student and I would just like to ask for a minute of your time. 我是一名学生,我想请您抽出一点时间。 I'm working on a barcode reader connected via USB port to a board name Arduino Yun. 我正在研究通过USB端口连接到板名称Arduino Yun的条形码读取器。 This board runs a version of embedded linux derived from OpenWrt using a microprocessor named Atheros AR9331 该开发板使用名为Atheros AR9331的微处理器运行从OpenWrt派生的嵌入式Linux版本。

I would like to ask you, what's necessary to make the Python Evdev binding (python-evdev.readthedocs.org/en/latest/), to be able to run in this type of MIPS microarchitecture? 我想问你,要使Evdev绑定(python-evdev.readthedocs.org/en/latest/)能够在这种类型的MIPS微体系结构中运行,有什么必要? At the momento, it's only for Ubuntu and ArchLinux. 目前,它仅适用于Ubuntu和ArchLinux。 I'm kind of guessing that cross compilation would be needed, or the indication of the usage of a specific C compiler inside this linux. 我有点猜测可能需要交叉编译,或者表明在此linux中使用特定C编译器的指示。
The current python version supported for OpenWrt is 2.7.3 I already know , if you compile C code in your PC, the resulting executable will only run in this type of architecture. 我已经知道OpenWrt支持的当前python版本是2.7.3,如果在PC中编译C代码,则生成的可执行文件将仅在这种类型的体系结构上运行。 If you use that compiled program inside the microprocessor, it wont work. 如果您在微处理器内部使用该编译程序,它将无法正常工作。 I've used this binding without trouble within ubuntu in my PC. 我在PC的ubuntu中使用该绑定时没有遇到任何麻烦。 I followed the instructions, python setup.py install, with a previous installation of setuptools, and it worked just fine. 我按照python setup.py install的说明进行了安装,之前安装了setuptools,它工作得很好。

But regarding OpenWrt, this was not the case. 但是对于OpenWrt,情况并非如此。

The python script I'm using requires this library within the first line of code in order to reach the data from the device (it works like a keyboard /dev/input/event0): 我正在使用的python脚本在代码的第一行中需要此库,以便从设备获取数据(它的工作方式类似于键盘/ dev / input / event0):

#!/usr/bin/env python

from evdev import InputDevice, ecodes, list_devices

from select import select

I've seen suggestions of copying the entire library inside the arduino, and run the script inside the same folder. 我已经看到了将整个库复制到arduino中并在同一文件夹中运行脚本的建议。 But it doesn't work, since the evdev module has files created with the architecture of the PC and not the MIPS. 但这是行不通的,因为evdev模块具有使用PC而非MIPS的体系结构创建的文件。

So, what are the messages displayed for the error? 那么,针对该错误显示的消息是什么? If you run python setup.py install in Openwrt to try to install the evdev binding, this appears on screen: 如果您在Openwrt中运行python setup.py install尝试安装evdev绑定,它将显示在屏幕上:

File "setup.py", line 10, in <module> from setuptools.command.develop import develop ImportError: No module named setuptools.command.develop from setuptools.command.develop import develop File "setup.py", line 10, in <module> from setuptools.command.develop import develop ImportError: No module named setuptools.command.develop

It's obvious from here that you need the module aforementioned. 从这里显而易见,您需要上述模块。 So, I tried to install it with this script (pypi.python.org/pypi/setuptools): 因此,我尝试使用此脚本(pypi.python.org/pypi/setuptools)安装它:

python ez_setup.py

And the output shows this: Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.zip Traceback (most recent call last): File "ez_setup.py", line 332, in <module> sys.exit(main()) File "ez_setup.py", line 327, in main downloader_factory=options.downloader_factory, File "ez_setup.py", line 287, in download_setuptools downloader(url, saveto) File "ez_setup.py", line 209, in download_file_curl _clean_check(cmd, target) File "ez_setup.py", line 169, in _clean_check subprocess.check_call(cmd) File "/usr/lib/python2.7/subprocess.py", line 511, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['curl', ' https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.zip ', '--silent', '--output', '/mnt/sda1/evdev-0.4.6/setuptools-11.3.1.zip']' returned non-zero exit status 60 输出显示如下: Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.zip Traceback(最近一次调用为last): File "ez_setup.py", line 332, in <module> sys.exit(主()) File "ez_setup.py", line 327, in main downloader_factory = options.downloader_factory, File "ez_setup.py", line 287, in download_setuptools下载器(URL,saveto) File "ez_setup.py", line 209, in download_file_curl _clean_check(cmd,target)中File "ez_setup.py", line 209, in download_file_curl File "ez_setup.py", line 169, in _clean_check (cmd)中File "ez_setup.py", line 169, in _clean_check File "/usr/lib/python2.7/subprocess.py", line 511, in check_call引发CalledProcessError(retcode,cmd) subprocess.CalledProcessError: Command '['curl',进程。CalledProcessError subprocess.CalledProcessError: Command '['curl', ' https subprocess.CalledProcessError: Command '['curl', //pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.zip' ,'--silent','--output','/mnt/sda1/evdev-0.4.6/setuptools-11.3.1.zip']'返回非零退出状态60

I pressume this output is due to the fact that pypi doesn't exist for the python 2.7.3 in OpenWrt , only for newer versions and other architectures. 我认为此输出是由于以下事实:pypi对于OpenWrt中的python 2.7.3不存在,仅适用于较新的版本和其他体系结构。 Evedv binding is requiring the setuptools module in order to make things easier and standard, but if the binding is not supported for the target architecture, what's needed to be able to use it anyways? Evedv绑定需要setuptools模块才能使事情变得简单和标准,但是如果目标体系结构不支持该绑定,则无论如何都需要使用它?

Thanks for your time, 谢谢你的时间,

Good day everyone, 今天是个好日子,

The solution was provided by Georgi Valkov. 该解决方案由Georgi Valkov提供。 He is the creator of the python-evdev binding. 他是python-evdev绑定的创建者。 I contacted him directly, and he was so kind that he cross compiled a version for the OpenWrt / Yun . 我直接与他联系,他非常友善,因此他为OpenWrt / Yun交叉编译了一个版本。

You can install the package using the openwrt package manager - opkg. 您可以使用openwrt软件包管理器-opkg安装该软件包。 The installation process is along the lines of: 安装过程大致如下:

$ opkg update
$ opkg install /path/to/python-evdev_0.4.7-1_ar71xx.ipk

To verify that the install was successful: 要验证安装是否成功:

$ opkg files python-evdev
/usr/lib/python2.7/site-packages/evdev-0.4.7-py2.7.egg-info
/usr/lib/python2.7/site-packages/evdev/genecodes.py
/usr/lib/python2.7/site-packages/evdev/ff.py
/usr/lib/python2.7/site-packages/evdev/_input.so
/usr/lib/python2.7/site-packages/evdev/device.py
/usr/lib/python2.7/site-packages/evdev/events.py
/usr/lib/python2.7/site-packages/evdev/__init__.py
/usr/lib/python2.7/site-packages/evdev/ecodes.py
/usr/lib/python2.7/site-packages/evdev/_ecodes.so
/usr/lib/python2.7/site-packages/evdev/util.py
/usr/lib/python2.7/site-packages/evdev/uinput.py
/usr/lib/python2.7/site-packages/evdev/_uinput.so

This works just fine. 这样很好。 Thanks. 谢谢。

PS. PS。 If someone needs the file, please contact me. 如果有人需要该文件,请与我联系。 Georgi sent me this address, but I didn't download the file from there because he sent it to me over email. Georgi给我发送了这个地址,但是我没有从那里下载文件,因为他是通过电子邮件发送给我的。 https://github.com/gvalkov/openwrt-packages-yun/blob/master/lang/python-evdev/Makefile https://github.com/gvalkov/openwrt-packages-yun/blob/master/lang/python-evdev/Makefile

In the output, you can see that curl returned the status code 60. According to man curl 在输出中,你可以看到, curl返回的状态码60.根据man curl

60 Peer certificate cannot be authenticated with known CA certifi‐ cates. 60对等证书不能使用已知的CA证书进行身份验证。

According to the setuptools page, you can instead use python ez_setup.py --insecure but obviously do that at your own risk. 根据setuptools页面,您可以改用python ez_setup.py --insecure但这样做显然需要您自担风险。 Alternatively you could do what the advanced instructions say and manually download the setuptools tarball, verify its md5 hash yourself, and install it using its setup.py . 或者,您可以执行高级说明中所述的内容,并手动下载setuptools tarball,亲自验证其md5哈希值,然后使用setup.py安装它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM