ubuntu 用minicom 将2个usb转串口,希望在开机的时候自启程序串口通信,但是这两个串口先后随机?

落雁西南 2016-09-30 04:35:02
用minicom 将usb转串口与arduino板通信,ttyUSB0 波特率115200与arduino板1通信,ttyUSB1 波特率9600与arduino板2通信.希望在开机自启程序与这2个arduino通信。但是在测试时发现本来希望ttyUSB0连接arduino板1,有时候却是ttyUSB0连接arduino板2的。也就是说这两个串口是随机的。有什么办法可以固定?
...全文
310 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
落雁西南 2017-04-17
  • 打赏
  • 举报
回复
额,回来填个坑,没人回我自己回。最近发现当下的linux设备大部分都是用的udev规则,通过添加udev规则可以根据idVendor和idProduct给同种设备的设备文件创建链接文件,通过链接文件可以指向固定串口设备(如果有两个设备是一样的,这两参数基本也是一样的,还需要其他参数来区别)。也可以通过udev规则修改串口设备的所有者和属组及权限。
落雁西南 2016-10-04
  • 打赏
  • 举报
回复
引用 1 楼 shingoscar 的回复:
那就不要直接连dev里的设备,开机后先根据型号创建连接到固定的文件,然后程序和这些文件通讯
能具体点吗,不知道具体怎么 操作
Poopaye 2016-10-01
  • 打赏
  • 举报
回复
那就不要直接连dev里的设备,开机后先根据型号创建连接到固定的文件,然后程序和这些文件通讯
Install driver for USB-UART bridge converter on Linux Ubuntu12.04 UbuntuUSB串口芯片驱动程序安装,支持cp210x,pl2303等 Reference: Fixing the cp210x open - Unable to enable UART Error When you plugin your USB-UART converter, and run "> ls /dev/tty*", if you don't see the /dev/ttyUSB0 (or similar), your Linux does not detect your USB-UART device. We need to install the driver for your device. Here we use Ubuntu12.04, and Updated the source to 3.2.0 version. If there is difference about version Number from your OS platform, please try to modify it into yours. 1.Download the Linux Source Code Open a terminal and execute the following commands. Note that your version of Linux may differ slightly -- adjust accordingly. $ cd ~ $ sudo apt-get install build-essential linux-source $ cp /usr/src/linux-source-3.2.0.tar.bz2 . $ bunzip2 linux-source-3.2.0.tar.bz2 $ tar xf linux-source-3.2.0.tar $ cd ~/linux-source-3.2.0 2.Recompile and Reinstall the cp210x Driver From within a terminal, execute: $ cd ~/linux-source-3.2.0 $ make oldconfig $ make prepare $ make scripts $ cp /usr/src/linux-headers-3.2.0-34-generic-pae/Module.symvers . Here, I have the "3.2.0-29" version also, I launched the command above, but not the below: "cp /usr/src/linux-headers-3.2.0-29-generic-pae/Module.symvers ." Recompile and Reinstall the cp210x Driver Here, We can actually install many kinds of USB-UART converter drivers. We take cp210x as the example. From within a terminal, execute: $ make M=drivers/usb/serial $ sudo mv /lib/modules/$(uname -r)/kernel/drivers/usb/serial/cp210x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/cp210x.ko.old $ sudo cp drivers/usb/serial/cp210x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ $ sudo modprobe -r cp210x $ sudo modprobe cp210x Reboot Linux system. Run Terminal: $ ls /dev/tty* The we can see the device is detected by Linux Host OS: 【技术】UbuntuUSB串口芯片驱动程序安装cp210x,pl2303 Reference: http://pharos.ece.utexas.edu/wiki/index.php/Fixing_the_cp210x_open_-_Unable_to_enable_UART_Error_-_04/17/2011 Then, We can configure the minicom to communicate with our target board. ====================================================== Here is an example of configure the parameters of minicom for TLL6527M PAL board: I just copied it here hardly without any font editing. Sorry about that. Serial Communications from Host-PC to TLL6527M Target Hardware The TLL System Design Environment (SDE) running on the host PC comes pre-configured with the required settings for serial-UART communications between the host PC and the TLL6527M base module. Generally, for use with TLL6527M the settings need not to be changed (Note: From the SDE OS version 0.3.2, the serial terminal program Minicom is set to open /dev/ttyUSB0 with the needed configuration as mentioned above.). To start serial communication from host to the TLL6527M, open the serial communication terminal program Minicom. Just open a terminal window on your Linux SDE running on the host PC and type the command "minicom" at the command prompt on your host PC terminal console. The TLL6527M on power-up is set by default to the following serial-UART communication settings: Bits per second = 115200 Data bits = 8 Parity = None Stop Bits = 1 Flow control = None Make sure that the TLL6527M's USB-UART port has been mapped to a ttyUSBx device node in the /dev folder on the host PC SDE. See following example: 【技术】UbuntuUSB串口芯片驱动程序安装cp210x,pl2303 Now make sure that this "ttyUSBx" is set as the destination port, baud rate is 115200, and 8N1 mode for minicom, by running the command 'minicom -s'. Note that running the "minicom -s" command as a normal user will only apply the settings for the current session. In order to make the settings permanent, these commands need to be run with root privileges.See example below: 【技术】UbuntuUSB串口芯片驱动程序安装cp210x,pl2303 The following window will appear on your host PC terminal window: 【技术】UbuntuUSB串口芯片驱动程序安装cp210x,pl2303 Go to ‘Serial port setup’, following screen will appear, make sure that serial device is set to ‘/dev/ttyUSB0’ and bps/par/bits is set to 115200 8N1: 【技术】UbuntuUSB串口芯片驱动程序安装cp210x,pl2303 Now go back to the main menu and choose ‘save setup as dfl’. This will save the configuration settings and from next time onwards user can directly run ‘minicom’ command without the option ‘–s’ and it will load settings from the saved file. 【技术】UbuntuUSB串口芯片驱动程序安装cp210x,pl2303 RESET the target by using the SDE's TLL6527M reset utility or by pressing the RESET button on the target. Following messages will be displayed on the terminal. By default, U-Boot is setup to automatically start booting the OS after waiting for a few seconds for the user to interrupt the automatic launch by pressing any key. So to stop U-Boot from loading uClinux and provide U-Boot command prompt, just hit any key. (This is assuming TLL6527M is flashed with u-boot and uClinux. TLL6527Ms are pre-flashed with firmware before shipping).

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧