Closed AAsyunkin-se closed 4 years ago
PyFtdi attempts to find the closest achievable speed with the detected hardware and its internal divider/multiplier capabilities. It does not mean, however, that the device is able to work with this frequency. So 8.6 Mbps will be configured as 8727273 bps in the FTDI device, but the FTDI HW is likely to be unable to accurately clock the data at this baudrate.
I would refrain from using a standard FTDI chip above 6Mbps in UART mode anyway. See https://eblot.github.io/pyftdi/api/uart.html#limitations: 8 Mbps does not appear to be a reliable baudrate with my devices.
Ah! Thanks for the link, I somehow overlooked it. There are successful implementations using FT232H but not using pyftdi, but QT. In particular https://github.com/hydrabus/hydrafw/wiki/HydraFW-HYDRANFC-guide#sniffer-iso14443a-with-unique-hard-real-time-infinite-trace-mode - here transmitter works at 8.4MBaud and FT232H is set to receive at 8MBaud. How it work is beyond my understanding as serial port in QT is opened at 6300000 baud! So the background question is how pyftdi is internally different to QT, performance-wise.
It would be greate to observe the USB communication QT does. The baudrate selection is only a matter of a single register setting, nothing more. However, as FTDI chip never document their chip, this has to be reverse-engineered - maybe QT team got access to some NDA. Does QT use libftdi or the Linux kernel code?
I don't believe QT does anything beyond working with a virtual COM port that FTDI driver provides - here is this particular project https://github.com/hydrabus/hydratool Benjamin, the author of this and HydraFW projects, did some measurements by oscilloscope and discovered that 6300000 in settings is in fact 8000000 in reality.. His findings are similar to yours and they hardly correlate to whatever is documented by FTDI. Oh, well..
I've compared the divisor values that PyFtdi generates and the one the Linux kernel generates, and they do match for all the baudrate values I've tested.
I've updated the doc but the conclusion is that:
TL;DR: 6 Mbps seems the safe upper bound.
It does not seem related to PyFtdi, but is a FTDI HW limitation.
Thanks for your additional research Emmanuel!
Hi, a quick question please.
I open the FTDI serial port like so: port = pyftdi.serialext.serial_for_url('ftdi:///1', baudrate=8600000, timeout=2)
And 'next allowed' as per console output is 8727273 bps. However, FTDI spec says only 8M and 12M is supported. Will it actually use that speed? Or will it downgrade that to 8M?
Thanks!