通过 Python 访问 Panatone Huey
我有一个 Panatone Huey,一个显示器校准探针(连接到显示器的设备,它可以为您提供颜色读数) - 我想用 Python 从该设备获取读数。
以前从未编写过这样的设备驱动程序,我不知道从哪里开始。
我发现有两个与 Heuy 交互的开源 C/C++ 项目 - ArgyllCMS 和 mcalib。
ArgyllCMS 附带一个 spotread
命令,该命令可从设备返回读数,尽管它仅充当交互式命令行工具,因此通过 subprocess
运行它不会(轻松)工作。
ArgyllCMS 用于与设备通信的代码位于 spectro/huey.c< /a>
没有尝试过(只是在写这个问题时才发现的),但是 mcalib 包含的代码少得多,主要只是 heuy.cpp - 然而它有大量的 FIXME
注释和不完整的方法,而且代码似乎是自动生成(无用的变量名)
似乎有三个选项:
- 修改
spotread
使其在没有任何交互式提示的情况下工作,通过subprocess
调用它 - 创建一个基于 C 的 Python 模块 < code>huey.c 或
huey.cpp
- 使用类似 PyUSB
由于对 Python 更加熟悉,我很想使用 PyUSB,但这会比使用 Python C API 包装现有代码需要更多工作吗?在这两种 C 实现中是否有一些明显的东西在 PyUSB 中不容易实现?
I have a Panatone Huey, a monitor calibration probe (device you attach to the monitor, and it gives you colour readings) - I want to get readings from the device in Python.
Having never written such a device driver before, I'm not sure where to start.
I've found are two open-source C/C++ projects that interface with the Heuy - ArgyllCMS and mcalib.
ArgyllCMS comes with a spotread
command which returns readings from the device, although it only functions as an interactive command line tool, so running it via subprocess
will not (easily) work.
The code ArgyllCMS uses to communicate with the device is in spectro/huey.c
Not tried it (only just found it while writing this question), but mcalib contains much less code, mainly just heuy.cpp - however it has a worrying number of FIXME
comments and incomplete methods, and the code appears to have been automatically generated (unhelpful variable names)
There seems to be three options:
- Modify
spotread
to work without any interactive prompts, call it viasubprocess
- Create a C-based Python module around
huey.c
orhuey.cpp
- Re-implement the interface using something like PyUSB
Being much more familiar with Python, I'm tempted to use PyUSB, but will this be substantially more work than wrapping existing code with the Python C API? Is there anything obvious in either of the C implementations that will not be easily doable in PyUSB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
鉴于
spotread
的存在,最简单(尽管可能不是最好)的方法是使用 期望。它允许您与其他命令行程序交互。Given the existence of
spotread
the easiest (though perhaps not the best) way to proceed would be to use pexpect. It allows you to interact with other command-line programs.