资源描述:
《matlab读取图像并用串口发送.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、functionvarargout=serial_communication2(varargin)gui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@serial_communication2_OpeningFcn,...'gui_OutputFcn',@serial_communication2_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',
2、[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});endfunctionserial_communication2_OpeningFcn(hObject,eventdata,handles,varargin)handles.output=h
3、Object;warning('off');javaFrame=get(hObject,'JavaFrame');javaFrame.setFigureIcon(javax.swing.ImageIcon('icon.jpg'));%%初始化参数hasData=false;%表征串口是否接收到数据isShow=false;%表征是否正在进行数据显示,即是否正在执行函数dataDispisStopDisp=false;%表征是否按下了【停止显示】按钮isHexDisp=false;%表征是否勾选了【十六进制显示】isHexSend=false;%表征是否勾选了
4、【十六进制发送】numRec=0;%接收字符计数numSend=0;%发送字符计数strRec='';%已接收的字符串%%将上述参数作为应用数据,存入窗口对象内setappdata(hObject,'hasData',hasData);setappdata(hObject,'strRec',strRec);setappdata(hObject,'numRec',numRec);setappdata(hObject,'numSend',numSend);setappdata(hObject,'isShow',isShow);setappdata(hObject
5、,'isStopDisp',isStopDisp);setappdata(hObject,'isHexDisp',isHexDisp);setappdata(hObject,'isHexSend',isHexSend);guidata(hObject,handles);functionvarargout=serial_communication2_OutputFcn(hObject,eventdata,handles)varargout{1}=handles.output;functioncom_Callback(hObject,~,handles)func
6、tioncom_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionrate_Callback(hObject,eventdata,handles)functionrate_CreateFcn(hObject,eventdata,handles)ifispc&&ise
7、qual(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionjiaoyan_Callback(hObject,eventdata,handles)functionjiaoyan_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaul
8、tUicontrolBackgroundColor'