概述
打开串口时出现错误:
MATLAB:serial:fopen:opfailed
打开失败: Port: COM1 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
错误提示中已经说明了使用‘instrfind’去检查串口对象是否在运行(被占用)。
在matlab命令行输入instrfind,可以看到:
Index: Type: Status: Name:
1 serial open Serial-COM1
2 serial closed Serial-COM1
3 serial closed Serial-COM1
4 serial closed Serial-COM1
5 serial closed Serial-COM1
6 serial closed Serial-COM1
7 serial open Serial-COM2
8 serial closed Serial-COM1
9 serial closed Serial-COM1
10 serial closed Serial-COM1
11 serial closed Serial-COM1
12 serial closed Serial-COM1
13 serial closed Serial-COM1
14 serial closed Serial-COM1
15 serial closed Serial-COM1
16 serial closed Serial-COM1
index为1那行中COM1已经被打开了。在代码中打开串口前加一行代码:fclose(instrfind); 用意是把已经打开的串口关闭,此时再运行代码,就可以成功打开串口了。
最后
以上就是坦率水壶为你收集整理的matlab 串口读取失败,matlab 串口通讯中出现“COMXX is not available.”错误的解决方法...的全部内容,希望文章能够帮你解决matlab 串口读取失败,matlab 串口通讯中出现“COMXX is not available.”错误的解决方法...所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复