修改python USB设备驱动程序仅使用vendor_id和product_id,不包括BCD

发布于 2024-08-26 23:13:15 字数 850 浏览 10 评论 0原文

我正在尝试修改 calibre(电子书管理程序)的 Android 设备驱动程序,以便它仅通过供应商 ID 和产品 ID 来识别设备,并排除 BCD。

该驱动程序是一个相当简单的 python 插件,目前设置为使用所有三个数字,但显然,当 Android 设备使用自定义 Android 版本(即 Nexus One 的 CyanogenMod)时,它会更改 BCD,因此 calibre 停止识别它。

当前的代码如下所示,带有一个简单的供应商 ID 列表,然后允许使用产品 ID 和 BCD:

VENDOR_ID   = {
        0x0bb4 : { 0x0c02 : [0x100], 0x0c01 : [0x100]},
        0x22b8 : { 0x41d9 : [0x216]},
        0x18d1 : { 0x4e11 : [0x0100], 0x4e12: [0x0100]},
        0x04e8 : { 0x681d : [0x0222]},
        }

我特别想更改的行是:

0x18d1 : { 0x4e11 : [0x0100], 0x4e12: [0x0100]},

这是用于识别 Nexus One 的行。我的 N1 运行 CyanogenMod 5.0.5,具有 BCD 0x226,我不想将其添加到列表中,而是希望从识别过程中消除 BCD,以便任何供应商 ID 为 0x18d1 且产品 ID 为 0x4e11 的设备或0x4e12 将被识别。定制的 Android ROM 没有进行足够的更改,因此细节并不重要。

该语法似乎需要将 BCD 放在括号中。

我如何编辑它以使其与该字段中的任何内容匹配?

I'm trying to modify the Android device driver for calibre (an e-book management program) so that it identifies devices by only vendor id and product id, and excludes BCD.

The driver is a fairly simply python plugin, and is currently set up to use all three numbers, but apparently, when Android devices use custom Android builds (ie CyanogenMod for the Nexus One), it changes the BCD so calibre stops recognizing it.

The current code looks like this, with a simple list of vendor id's, that then have allowed product id's and BCD's with them:

VENDOR_ID   = {
        0x0bb4 : { 0x0c02 : [0x100], 0x0c01 : [0x100]},
        0x22b8 : { 0x41d9 : [0x216]},
        0x18d1 : { 0x4e11 : [0x0100], 0x4e12: [0x0100]},
        0x04e8 : { 0x681d : [0x0222]},
        }

The line I'm specifically trying to change is:

0x18d1 : { 0x4e11 : [0x0100], 0x4e12: [0x0100]},

Which is, the line for identifying a Nexus One. My N1, running CyanogenMod 5.0.5, has the BCD 0x226, and rather than just adding it to the list, I'd prefer to eliminate the BCD from the recognition process, so that any device with vendor id 0x18d1 and product id 0x4e11 or 0x4e12 would be recognized. The custom Android rom doesn't change enough for the specifics to matter.

The syntax seems to require the BCD in brackets.

How can I edit this so that it matches anything in that field?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

压抑⊿情绪 2024-09-02 23:13:15

这是一种数据结构,它本身并不“匹配”任何东西。更改必须发生在使用该数据结构进行匹配的代码中。您对数据结构本身所做的任何事情都不会意味着“匹配所有”,除非匹配代码可以识别某种标志。

That is a data structure, it doesn't "match" anything per se. The change would have to happen in the code that uses that data structure to do the matching. Nothing you could do on the data structure itself would mean "match all" unless there's some kind of flag the matching code recognizes.

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