how to do Real time data collection via lan?

hi all,
I am doing an project based on real time data collection via lan. though we have toolboxes and blocksets for doing this. since, i supposed to do it with m-file. anyhow, i tried it well. but, getting some errors and warnings. it will be very helpful, if you some experts suggest me a right way.
and my code is,
interfaceObject=tcpip('192.168.1.1',80); %this is my server IP address.
figureHandle = figure('NumberTitle','off',...
'Name','Live Data Stream Plot',...
'Color',[0 0 0],...
'CloseRequestFcn',{@localCloseFigure,interfaceObject});
axesHandle = axes('Parent',figureHandle,...
'YGrid','on',...
'YColor',[0.9725 0.9725 0.9725],...
'XGrid','on',...
'XColor',[0.9725 0.9725 0.9725],...
'Color',[0 0 0]);
xlabel(axesHandle,'Number of Samples');
ylabel(axesHandle,'Value');
hold on;
plotHandle = plot(axesHandle,0,'-y','LineWidth',1);
bytesToRead = 500;
interfaceObject.BytesAvailableFcn = {@localReadAndPlot,plotHandle,bytesToRead};
interfaceObject.BytesAvailableFcnMode = 'byte';
interfaceObject.BytesAvailableFcnCount = bytesToRead;
fopen(interfaceObject);
pause(3);
snapnow;
function localReadAndPlot(interfaceObject,~,figureHandle,bytesToRead)% herr, this function is not supporting. how sholud i do then?
data = fread(interfaceObject,bytesToRead);
function localCloseFigure(figureHandle,~,interfaceObject)% here also...
fclose(interfaceObject);
delete(interfaceObject);
clear interfaceObject;
delete(figureHandle);

3 comentarios

Titus Edelhofer
Titus Edelhofer el 26 de Jul. de 2012
Please edit your question to show the code as code (e.g. by indenting the first line by two spaces or using the code buttons). Otherwise it's hardly readable.
Walter Roberson
Walter Roberson el 29 de Jul. de 2012
What errors and warnings are you getting?
Walter Roberson
Walter Roberson el 30 de Jul. de 2012
Thank you for reformatting, but you still need to tell us what errors and warnings you are getting. For example, how do you know that "herr, this function is not supporting" ?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Types en Centro de ayuda y File Exchange.

Preguntada:

el 26 de Jul. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by