简体   繁体   English

USB <>串行通信在Linux上不起作用

[英]USB<>serial communication not working on linux

I'm currently working on a project in which I have to communicate with a custom-made sonar board over an USB<>Serial connection with cts/rts hardware flow control at a baud rate of 4,499,456. 我目前在一个项目中,必须通过USB <>串行连接与cts / rts硬件流控制的USB <>串行声纳板通信,波特率为4499456。 MATLAB code for sending and receiving data is already available and fully tested on Windows. 用于发送和接收数据的MATLAB代码已经可用,并且已在Windows上进行了全面测试。

The problem occurs when trying to execute the MATLAB code on linux (Ubuntu 14.10/15.04). 尝试在Linux(Ubuntu 14.10 / 15.04)上执行MATLAB代码时,会发生问题。 Both the commands for toggling the LED on the board (write) as well as receiving information (read) are not working. 切换板上LED的命令(写)和接收信息的命令(读)都无效。 Python ports of the MATLAB code using the pyserial and pylibftdi library do allow writing, but also hang on receiving data. 使用pyserial和pylibftdi库的MATLAB代码的Python端口确实允许写入,但也挂在接收数据上。

Does anyone have any idea as to why it does work on Windows but not Ubuntu? 有谁知道为什么它可以在Windows上运行但不能在Ubuntu上运行吗? Maybe a driver issue? 可能是驾驶员问题? Or something having to do with cts/rts on Linux? 还是与Linux上的cts / rts有关?

lsusb output lsusb输出

Bus 002 Device 004: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC

dmesg output dmesg输出

[11906.209231] usb 2-3: new high-speed USB device number 5 using ehci-pci
[11906.346701] usb 2-3: New USB device found, idVendor=0403, idProduct=6014
[11906.346713] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[11906.346720] usb 2-3: Product: USB <-> Serial Converter
[11906.346725] usb 2-3: Manufacturer: FTDI
[11906.346730] usb 2-3: SerialNumber: FT69T4N
[11906.351716] ftdi_sio 2-3:1.0: FTDI USB Serial Device converter detected
[11906.351800] usb 2-3: Detected FT232H
[11906.352234] usb 2-3: FTDI USB Serial Device converter now attached to ttyUSB1

Edit: Just logging my progress in case somebody encounters the same issue. 编辑:只是记录我的进度,以防有人遇到相同的问题。 The problem seems to lie in the baudrate; 问题似乎在于波特率。 changing it to 115200 allows reading from the device, but messes up sending data to it. 将其更改为115200可以读取设备,但会给它发送数据造成混乱。

Apparently the FTDI driver doesn't work to well with very high/non-standard baudrates. 显然,FTDI驱动程序不适用于非常高/非标准的波特率。 I ended up solving this by using a baudrate of 3,000,000 我最终使用3,000,000的波特率解决了这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM