讨论
需要真实物理连接
- 同一台电脑,两个串口相连,测试通信,使用何种物理通信线来相连?链接、链接、链接
- 设想是,利用同一个电脑上两个串口,一个vm-host,一个host,两者通信,vm启动程序,host启动串口助手,这种情况,需要真实的物理接线。
- 一个linux串口(不是vm,而是真实host),一块单片机,连接(跟实际开一样,但跟测试不一样)
不需要真实物理连接
一个串口
- http://blog.csdn.net/wdq347/article/details/39498037vbox一个串口,主机管道。(vbox测试,win-host,vbox不可使用功管道)
两个串口
- http://www.51testing.com/html/79/n-861579.htmlvm下创建两个串口,通过相同的命名管道实现通信。(vm已测试,挺方便的)
- http://blog.csdn.net/kimherojae/article/details/44653183在win下使用软件,虚拟出两个端口并”桥接“,然后启动监控软件,vm同样创建两个串口,然后使用“主机设备”连接win下虚拟端口,实现通信。(测试,也是最终采用的方案,实际撒开发也是这个场景)
- 推荐了这两个软件http://blog.qdac.cc/?p=3373
综上:有两个方案是比较好的
- 虚拟+监控(实际需要,按应用程序功能编写测试即可),两个串口,收发都行
- 实物链接,单片机+vm-host,一个串口,收发都行
基本操作
适用工具
串口信息查询
- 查看串口是否可用,可以对串口发送数据比如对com1口,echo lyjie126 > /dev/ttyS0
- 查看串口名称使用 ls -l /dev/ttyS* 一般情况下串口的名称全部在dev下面,如果你没有外插串口卡的话默认是dev下的ttyS* ,一般ttyS0对应com1,ttyS1对应com2,当然也不一定是必然的;
- 查看串口驱动:cat /proc/tty/drivers/serial
- 查看串口设备:dmesg | grep ttyS*
- 列出usb设备:lsusb
调试
思考过程
- VM-host的“连接”,最终为了建立“串口连接“
- Linux串口调试终端minicom, [工具]minicom
- 查看串口设备或usb转串口设备(dmesg|grep tty)
- 检测串口是否可用(echo/cat配合)
结果
- 因为采用了虚拟串口,所以,关闭vbox-linux后出错,只能每次调试serial时才重新将所需serial添加进去。最终直接编写一个reboot脚本,很可惜,vbox现在重启非常慢。