通过 Python 访问 Panatone Huey

发布于 2024-09-26 16:21:59 字数 1207 浏览 5 评论 0原文

我有一个 Panatone Huey,一个显示器校准探针(连接到显示器的设备,它可以为您提供颜色读数) - 我想用 Python 从该设备获取读数。

以前从未编写过这样的设备驱动程序,我不知道从哪里开始。

我发现有两个与 Heuy 交互的开源 C/C++ 项目 - ArgyllCMSmcalib

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 via subprocess
  • Create a C-based Python module around huey.c or huey.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风追烟花雨 2024-10-03 16:21:59

鉴于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文