找回密码
 注册
关于网站域名变更的通知
查看: 546|回复: 1
打印 上一主题 下一主题

MATLAB串口开关问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2020-8-4 14:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
先描述下问题现象:
; s1 ^7 p$ @0 |9 x( H, A$ j4 k5 o        正常打开关闭一次串口后,再次打开串口提示:2 ?! z, j( Q8 ~1 j' y5 C1 [
       打开失败: Cannot connect to the COM31port. Possible reasons are another application is connected to the port or the port does not exist. 出错 MSerialV1>pbOpenAndClose_Callback(line 122)    fopen(s);6 A! j& b8 n' n1 w$ J

/ p; L; z# ]/ W确认该串口没有在其它程序中使用!# @+ }$ A( G+ S  s$ `$ d1 O* u7 I+ e

; [1 x$ _5 n7 B) A) {3 [0 O! T3 O4 g以下是程序代码
& a3 k  ?+ b6 |0 A4 o' |5 q  s& ]5 K( w8 l9 O& Z3 H- X) o8 x3 J! c. A
set(handles.pmComPort,'String',seriallist);
" K3 ?, {8 Q; c! W1 O* j( IindexCom = get(handles.pmComPort,'Value');
. i& j  h! {6 W& Q: OstrCom = get(handles.pmComPort,'String');
" j" n1 P- V; z8 uif indexCom > 1: A; x! s$ }$ I8 l
    comPort = strCom(indexCom);, O, L% J- Z* _4 `$ V& V4 r
else1 m* J9 C( |/ _6 k# j
    comPort = strCom;   
* C) Q0 T. ^/ F% l' ~end
& K; u$ D" Y% }. H& O6 m* Y4 ?8 D! Rs = serial(comPort);6 h! ?) ^5 K4 u5 N# b
if handles.pbOpenAndClose.String == "打开"
0 m' H$ g0 z; h: m# B+ P! E5 W    handles.pbOpenAndClose.String = "关闭";1 l8 q4 Z7 E# G% o" M
    handles.pbOpenAndClose.BackgroundColor = 'g';
5 A5 O6 a4 n  X3 f    fopen(s);   
5 ^; O0 s! |% L' Felse
0 k8 _' {; n8 H4 J6 D    handles.pbOpenAndClose.String = "打开";% W* a! T* u% z* O9 r# S
    handles.pbOpenAndClose.BackgroundColor = 'r';# i1 k$ [0 ?1 X" `
    fclose(s);9 u/ b7 n( K& C' W: s& f. y5 w
    delete(s);: o) ~/ w% Y9 X. Z  {
    clear s;# d$ O, D) X' ?2 Q
end+ A: g" f7 ]& O, J

该用户从未签到

2#
发表于 2020-8-4 15:51 | 只看该作者
试试过程中用指令能否正常退出串口,关闭串口
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-11-24 21:21 , Processed in 0.156250 second(s), 23 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表