|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
先描述下问题现象:; e) `$ \6 W: U! A
正常打开关闭一次串口后,再次打开串口提示:. K. S" F. {/ l. [5 J
打开失败: 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);
7 b8 Z9 U. T( x. H7 \! T A9 B8 y8 g* i$ D6 f+ G6 X, V+ i
确认该串口没有在其它程序中使用!: K6 @2 p! k+ V
& U5 v. c4 c, [6 ]( @以下是程序代码- j1 @' b0 X5 X& z$ W# L3 z
. k) l& d* y7 d' Q+ G, c: Qset(handles.pmComPort,'String',seriallist);
, ?; x" F; f: y: kindexCom = get(handles.pmComPort,'Value');
) ~ \- ^( }- g9 lstrCom = get(handles.pmComPort,'String');
" b6 z. K9 g4 l! A1 _( M3 c j" Rif indexCom > 1
5 }6 T/ u- A+ g comPort = strCom(indexCom);
1 S% C+ i2 @5 t+ r6 n) @else$ L) ~. {; ~+ _& } H; z4 K
comPort = strCom;
; I0 w$ k. h8 {8 Z9 `% _+ Mend: @! M8 A) A5 s+ T0 d \, M' u; q
s = serial(comPort);: P( ?7 X6 j& X
if handles.pbOpenAndClose.String == "打开"9 [/ o0 }- t7 g2 \5 A) |9 F
handles.pbOpenAndClose.String = "关闭";5 ]5 C# S! g; {; T$ S
handles.pbOpenAndClose.BackgroundColor = 'g';# f5 K+ C7 K& v" j J. V6 a
fopen(s);
% f, d! s$ m/ [. Lelse
" h8 ?) n. k$ \3 E handles.pbOpenAndClose.String = "打开";& L& a1 l" R0 L$ W9 Q" `2 p
handles.pbOpenAndClose.BackgroundColor = 'r';
9 o; X! t3 \3 h/ ? fclose(s);
7 [# {+ A. c" ?7 F9 U delete(s);% d Y6 X. u+ c) w! [ V
clear s;( A3 K; o. }3 `: q0 d! M7 h& R
end1 [8 p1 Q1 F8 u
|
|