Bạn có thể xác định kết hợp các bit để tạo cấu hình của riêng mình (chẵn lẻ, dừng bit & bit dữ liệu).
conn.controlTransfer(0x40, 0x04, 0x0008, 0, null, 0, 0);
1 tham số - 0x40 - yêu cầu để thiết lập hoặc lấy dữ liệu điều khiển
#define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40
tham số thứ 2 - 0x04 - loại dữ liệu được thiết lập hoặc lấy
#define FTDI_SIO_RESET 0 /* Reset the port */
#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */
#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modern status register */
#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
tham số thứ ba - 0x0008 - dữ liệu bit 8, chẵn lẻ không, dừng bit 1, tx off - Dữ liệu thực tế có được truyền đi hay không.
Tham số thứ ba là một dữ liệu 16 bit có thể được hình thành từ các hằng số định nghĩa dưới đây:
Bits 0 to 7 -- Number of data bits
Bits 8 to 10 -- Parity
0 = None
1 = Odd
2 = Even
3 = Mark
4 = Space
Bits 11 to 13 -- Stop Bits
0 = 1
1 = 1.5
2 = 2
Bit 14
1 = TX ON (break)
0 = TX OFF (normal state)
Bit15 -- Reserved
#define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA
#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
#define FTDI_SIO_SET_BREAK (0x1 << 14)
Đối với tốc độ truyền:
* Value Baud Rate speed
* 0×2710 300
* 0×1388 600
* 0x09C4 1200
* 0x04E2 2400
* 0×0271 4800
* 0×4138 9600
* 0x80D0 14400
* 0x809C 19200
* 0xC04E 38400
* 0×0034 57600
* 0x001A 115200
* 0x000D 230400
* 0×4006 460800
* 0×8003 921600
*/
Vui lòng tham khảo các liên kết dưới đây để biết thêm chi tiết:
http://read.pudn.com/downloads181/sourcecode/embed/842049/usb/serial/ftdi_sio.h__.htm
http://www.mev.co.uk/pages/Support/USB-Baud-Spoof.html
plz cập nhật nó, nếu bạn đã tìm thấy câu trả lời ..... – yokks