How to define a callback function to receive TCP/IP data stream in MATLAB GUI?
2 次查看(过去 30 天)
显示 更早的评论
I wrote the following simple GUI to do that but still the callback function does not run at all
function com_test_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to com_test (see VARARGIN)
handles.t_rzm = tcpip('169.254.181.51', 51000);
set(handles.t_rzm,'ByteOrder','littleEndian');
fopen(handles.t_rzm);
handles.t_rzm.BytesAvailableFcn = @RXDATA;
% Choose default command line output for com_test
handles.output = hObject;
% the remote computer is sending the data
% Update handles structure
guidata(hObject, handles);
function RXDATA(hObject, eventdata, handles) % The callback function supposed to get data
% handles = guidata(hObject);
disp('yes')
dum_PB_Callback(handles.dum_PB,event,dat)
guidata(handles.dum_PB,handles) %%function ends
guidata(hObject, handles);
I also defined a dummy push button to trigger the RXDATA function but it does not help.
% --- Executes on button press in dum_PB. (Dummy Push Button)
function dum_PB_Callback(hObject, eventdata, handles)
% hObject handle to dum_PB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('dum_PB_Callback')
% if handles.UserData.sync==1
handles.t_rzm.BytesAvailableFcn = @RXDATA;
% end
guidata(hObject,handles) %%dummy button function ends
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!