如何在 OSX 上使用 4mb 波特率和 FTDI?

How to use baud rate 4mb with FTDI on OSX?

Apple 的 FTDI 驱动程序可以使用 4mb (B4000000) 的波特率吗?还是FTDI的VCP驱动更好?

最高 B230400 的速度在 termios.h (*) 中定义,每个速度都定义为与其速度匹配的整数(与 Linux 不同)。然而,简单的 hack #define B4000000 4000000 不起作用。

我记得大约 5 年前(在 Apple 提供驱动程序之前)使用 FTDI 的 VCP 驱动程序和 hacking FTDIUSBSerialDriver.kext/Contents/Info.plist 使 FTDI 能够使用 4mb 以达到 "allowed" 速度之一(如 B2400 ) 被驱动程序别名为 4mb。这仍然是推荐的方法吗? (我想这需要禁用 kext 安全性,sudo nvram kext-dev-mode=1。)

我正在使用这样的波特率,其中 serBaudRate 类似于 B2400 或(理想情况下)B4000000

if ((fd = open(serPortName, O_RDWR)) < 0)   { perror("aborting"); return; }
tcgetattr(fd, &tty);                            /* get attributes */
cfsetospeed(&tty, (speed_t) serBaudRate);       /* output speed */
cfsetispeed(&tty, (speed_t) serBaudRate);       /* input speed */
tcsetattr(fd, TCSANOW, &tty);                   /* set attributes */

(*) 完整路径是 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/termios.h

I remember being able to use 4mb with FTDI around 5 years ago (before Apple provided a driver) using FTDI's VCP driver and hacking FTDIUSBSerialDriver.kext/Contents/Info.plist to make one of the "allowed" speeds (like B2400) be aliased to 4mb by the driver. Is this still the recommended method? (I suppose this would require disabling kext security, with sudo nvram kext-dev-mode=1.)

我怀疑这是唯一的方法。 Apple 驱动程序非常基础(几年前它甚至不支持 CTS/RTS 信号)而且我看不到任何指定非标准波特率的方法。看起来 FTDI Info.plist 仍然支持那些波特率配置选项。