无法将 I2C 设备从 Linux 虚拟机连接到 FT232H

Unable to interface I2C device to FT232H from Linux Virtual Machine

我正在尝试连接一个通过 I2C 通信发送和接收数据的传感器。我已将传感器与 FT232H USB 转 I2C 转换器连接,并将其插入 PC。

我得到 dmesg 输出如下 -

[  518.172735] usb 1-3: new full-speed USB device number 4 using xhci_hcd
[  518.306677] usb 1-3: New USB device found, idVendor=0403, idProduct=6001
[  518.306686] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  518.306689] usb 1-3: Product: FT232R USB UART
[  518.306692] usb 1-3: Manufacturer: FTDI
[  518.306695] usb 1-3: SerialNumber: AK04P01W
[  518.309382] ftdi_sio 1-3:1.0: FTDI USB Serial Device converter detected
[  518.309442] usb 1-3: Detected FT232RL
[  518.309445] usb 1-3: Number of endpoints 2
[  518.309448] usb 1-3: Endpoint 1 MaxPacketSize 64
[  518.309450] usb 1-3: Endpoint 2 MaxPacketSize 64
[  518.309453] usb 1-3: Setting MaxPacketSize 64
[  518.309771] usb 1-3: FTDI USB Serial Device converter now attached to ttyUSB0

我得到了 /dev/ttyUSB0 设备。

我有 运行 下面给出的基于 python 的示例应用程序 link -

https://learn.adafruit.com/adafruit-ft232h-breakout/i2c

我使用的代码片段如下 -

import Adafruit_GPIO.FT232H as FT232H

# Temporarily disable FTDI serial drivers.
FT232H.use_FT232H()

# Find the first FT232H device.
ft232h = FT232H.FT232H()

# Create an I2C device at address 0x70.
i2c = FT232H.I2CDevice(ft232h, 0x70)

但是,它总是卡在下一行 -

ft232h = FT232H.FT232H()

我无法退出功能。

我也遵循了下面给出的步骤 link -

https://unix.stackexchange.com/questions/340789/enabling-i2c-on-debian-i2cdetect-doesnt-show-device

在上面的link中,它显示了一个例子如下 -

所以比如读取版本,需要从寄存器00读取01字节,默认芯片地址为E0,LSB为R/W位,所以改为您使用 E1 作为地址,USB-I2C 适配器所需的命令是 55。因此您通过串行发送的完整序列是 55 E1 00 01,然后您将读取一个字节作为答案。

我不知道如何 select 以下数据的值 -

  1. USB 所需的命令 - I2C 适配器。我们如何得出结论 "Required Command for the adapter"

FT232H vs. FT232R are two different chips. The FT232R does not contain the "MPSSE engine", and therefore cannot be used with 3rd-party code examples nor with the FTDI appnote 255 依赖 MPSSE 实现 i2c 主功能。