📄 receive.m
字号:
function receive(functionName, message, port)
%RECEIVE
%This function registers a function to receive all incoming messages of
%a message type through certain PC ports. If no ports are specified, all existing ports are used.
%
%Usage:
% receive(function, message, port);
%
% function: the string or function handle of a function, eg. 'myfunction'
% message: a subclass of net.tinyos.message.Message
% port: a socket, eg. 'localhost:9000' or a serial port, eg. 'COM1'
global COMM
if nargin<3
port=COMM.sockets;
end
if iscell(port)
for i=1:length(port)
receive(functionName, message, port{i});
end
return
end
if ~ischar(port) | ~ischar(functionName) | ~isjava(message)
disp(['usage: receive(''myFunction'', net.tinyos.oscope.OscopeMsg'')']);
disp([' receive(''myFunction'', net.tinyos.oscope.OscopeMsg'', ''COM1'')']);
return
end
moteIF=connect(port);
%check for doubles
TF = strcmpi(COMM.functions, functionName) & strcmpi(COMM.messageTypes, message.getClass.toString.toCharArray');
moteIFs = [COMM.dataSource{TF}];
for i=1:length(moteIFs)
if moteIFs(i)==moteIF return; end
end
mml = net.tinyos.matlab.MatlabMessageListener;
mml.registerMessageListener(functionName);
moteIF.registerListener(message, mml);
COMM.functions{end+1}=functionName;
COMM.messageTypes{end+1}=message.getClass.toString.toCharArray';
COMM.dataSource{end+1}=moteIF;
COMM.messageListener{end+1}=mml;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -