• 大小: 11KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-06
  • 语言: Matlab
  • 标签: 串口  MATLAB  

资源简介

MATLAB实现GUI实现串口通讯 十六进制通讯

资源截图

代码片段和文件信息

function varargout = zhengshi(varargin)
gui_Singleton = 1;
gui_State = struct(‘gui_Name‘       mfilename ...
    ‘gui_Singleton‘  gui_Singleton ...
    ‘gui_OpeningFcn‘ @zhengshi_OpeningFcn ...
    ‘gui_OutputFcn‘  @zhengshi_OutputFcn ...
    ‘gui_LayoutFcn‘  []  ...
    ‘gui_Callback‘   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State varargin{:});
else
    gui_mainfcn(gui_State varargin{:});
end

function zhengshi_OpeningFcn(hobject eventdata handles varargin)
handles.output = hobject;
javaframe = get(hobject‘Javaframe‘);
javaframe.setFigureIcon(javax.swing.ImageIcon(‘icon.jpg‘));
guidata(hobject handles);

function varargout = zhengshi_OutputFcn(hobject eventdata handles)
varargout{1} = handles.output;

function com_Callback(hobject eventdata handles)

function com_CreateFcn(hobject eventdata handles)
if ispc && isequal(get(hobject‘BackgroundColor‘) get(0‘defaultUicontrolBackgroundColor‘))
    set(hobject‘BackgroundColor‘‘white‘);
end

function rate_Callback(hobject eventdata handles)

function rate_CreateFcn(hobject eventdata handles)
if ispc && isequal(get(hobject‘BackgroundColor‘) get(0‘defaultUicontrolBackgroundColor‘))
    set(hobject‘BackgroundColor‘‘white‘);
end

function jiaoyan_Callback(hobject eventdata handles)

function jiaoyan_CreateFcn(hobject eventdata handles)
if ispc && isequal(get(hobject‘BackgroundColor‘) get(0‘defaultUicontrolBackgroundColor‘))
    set(hobject‘BackgroundColor‘‘white‘);
end

function data_bits_Callback(hobject eventdata handles)

function data_bits_CreateFcn(hobject eventdata handles)
if ispc && isequal(get(hobject‘BackgroundColor‘) get(0‘defaultUicontrolBackgroundColor‘))
    set(hobject‘BackgroundColor‘‘white‘);
end

function stop_bits_Callback(hobject eventdata handles)

function stop_bits_CreateFcn(hobject eventdata handles)
if ispc && isequal(get(hobject‘BackgroundColor‘) get(0‘defaultUicontrolBackgroundColor‘))
    set(hobject‘BackgroundColor‘‘white‘);
end

function start_serial_Callback(hobject eventdata handles)
global scom
if get(hobject‘value‘)
    com_n=sprintf(‘com%d‘get(handles.com‘value‘));
    rates=[300 600 1200 2400 4800 9600 19200 38400 43000 56000 57600 115200];
    baud_rate=rates(get(handles.rate‘value‘));
    switch get(handles.jiaoyan‘value‘)
        case 1
            jiaoyan=‘none‘;
        case 2
            jiaoyan=‘odd‘;
        case 3
            jiaoyan=‘even‘;
    end
    data_bits=5+get(handles.data_bits‘value‘);
    stop_bits=get(handles.stop_bits‘value‘);
    scom=serial(com_n);
    set(scom‘BaudRate‘baud_rate‘Parity‘jiaoyan‘DataBits‘...
        data_bits‘StopBits‘stop_bits‘BytesAvailableFcnCount‘100...
        ‘BytesAvailableFcnMode‘‘byte‘‘BytesAvailableFcn‘{@byteshandles}...
        ‘TimerPeriod‘0

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6838  2012-05-14 18:34  my code\zhengshi.asv

     文件       7174  2012-05-14 16:26  my code\zhengshi.fig

     文件       6896  2012-05-14 18:46  my code\zhengshi.m

     文件       3584  2012-05-14 16:26  my code\zhengshi_activex1

     目录          0  2012-05-14 18:48  my code

----------- ---------  ---------- -----  ----

                24492                    5


评论

共有 条评论