是否可以在Apple的FTDI驅動程序中使用4mb的波特率(B4000000)?或者FTDI的VCP驅動程序更好?如何在OSX上使用波特率爲4mb的FTDI?
速度高達B230400在termios.h(*)中定義,每個速度被定義爲匹配其速度的整數(與Linux不同)。但是,簡單的破解#define B4000000 4000000
不起作用。
我記得在5年前(在蘋果提供了一個驅動程序之前)使用4MB的FTDI,使用FTDI的VCP驅動程序,並且盜號FTDIUSBSerialDriver.kext/Contents/Info.plist
使其中一個「允許」速度(如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