Clear Filters
Clear Filters

How to define a callback function to receive TCP/IP data stream in MATLAB GUI?

3 views (last 30 days)
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

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!