From: Steven_Lord on


"weiling " <wwl1982_787(a)hotmail.com> wrote in message
news:i3opka$hf0$1(a)fred.mathworks.com...
> "us " <us(a)neurol.unizh.ch> wrote in message
> <i3ootp$2vg$1(a)fred.mathworks.com>...
>> "weiling " <wwl1982_787(a)hotmail.com> wrote in message
>> <i3oom9$hjo$1(a)fred.mathworks.com>...
>> > "weiling " <wwl1982_787(a)hotmail.com> wrote in message
>> > <i3omqa$i3d$1(a)fred.mathworks.com>...
>> > > i want to create tcp/ip communication between matlab and another
>> > > instrument.
>> > > now i can see with netstat -a, that tcp/ip is estabilished.
>> > > but in the side of matlab, i can not run fread.
>> > >
>> > > code of matlab:
>> > > t=tcpip('192.168.1.2',12323)
>> > > fopen=(t)
>> > > fwrite(t,'test')
>> > > freade(t, 10)
>> > > after long time wait come a warning: The specified amount of data was
>> > > not returned within the Timeout period.
>> > >
>> > > i have tried char(fread(t,t.BytesAvailable))
>> > > ??? Error using ==> icinterface.fread at 163
>> > > SIZE must be greater than 0.
>> > >
>> > >
>> > > does anyone have ideas? where is the problem?
>> > > thx!
>> >
>> >
>> > i can send data from matlab to another instrument.
>> > wenn i run fwrite and then fprintf, i can see the data on the another
>> > instrument.
>> > but why can i not see the data on the matlab use fread?
>>
>> what happens if you decrease the amount of data FREAD has to read(?)...
>>
>> us
>
> always Warning: The specified amount of data was not returned within the
> Timeout period.

Perhaps this is a silly question, but is your instrument actually sending
any data? Just because you've opened a connection between MATLAB and the
instrument doesn't mean that there's any data being sent. Think about a
telephone call where neither person speaks.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: weiling on
"Steven_Lord" <slord(a)mathworks.com> wrote in message <i3ovj9$8pn$1(a)fred.mathworks.com>...
>
>
> "weiling " <wwl1982_787(a)hotmail.com> wrote in message
> news:i3opka$hf0$1(a)fred.mathworks.com...
> > "us " <us(a)neurol.unizh.ch> wrote in message
> > <i3ootp$2vg$1(a)fred.mathworks.com>...
> >> "weiling " <wwl1982_787(a)hotmail.com> wrote in message
> >> <i3oom9$hjo$1(a)fred.mathworks.com>...
> >> > "weiling " <wwl1982_787(a)hotmail.com> wrote in message
> >> > <i3omqa$i3d$1(a)fred.mathworks.com>...
> >> > > i want to create tcp/ip communication between matlab and another
> >> > > instrument.
> >> > > now i can see with netstat -a, that tcp/ip is estabilished.
> >> > > but in the side of matlab, i can not run fread.
> >> > >
> >> > > code of matlab:
> >> > > t=tcpip('192.168.1.2',12323)
> >> > > fopen=(t)
> >> > > fwrite(t,'test')
> >> > > freade(t, 10)
> >> > > after long time wait come a warning: The specified amount of data was
> >> > > not returned within the Timeout period.
> >> > >
> >> > > i have tried char(fread(t,t.BytesAvailable))
> >> > > ??? Error using ==> icinterface.fread at 163
> >> > > SIZE must be greater than 0.
> >> > >
> >> > >
> >> > > does anyone have ideas? where is the problem?
> >> > > thx!
> >> >
> >> >
> >> > i can send data from matlab to another instrument.
> >> > wenn i run fwrite and then fprintf, i can see the data on the another
> >> > instrument.
> >> > but why can i not see the data on the matlab use fread?
> >>
> >> what happens if you decrease the amount of data FREAD has to read(?)...
> >>
> >> us
> >
> > always Warning: The specified amount of data was not returned within the
> > Timeout period.
>
> Perhaps this is a silly question, but is your instrument actually sending
> any data? Just because you've opened a connection between MATLAB and the
> instrument doesn't mean that there's any data being sent. Think about a
> telephone call where neither person speaks.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


but can you tell me, how can i send data from a instrument to matlab.
because i think matlab can only as tcp client, is it correct?
how can matlab get data from a instrument?
From: weiling on
"Steven_Lord" <slord(a)mathworks.com> wrote in message <i3ovj9$8pn$1(a)fred.mathworks.com>...
>
>
> "weiling " <wwl1982_787(a)hotmail.com> wrote in message
> news:i3opka$hf0$1(a)fred.mathworks.com...
> > "us " <us(a)neurol.unizh.ch> wrote in message
> > <i3ootp$2vg$1(a)fred.mathworks.com>...
> >> "weiling " <wwl1982_787(a)hotmail.com> wrote in message
> >> <i3oom9$hjo$1(a)fred.mathworks.com>...
> >> > "weiling " <wwl1982_787(a)hotmail.com> wrote in message
> >> > <i3omqa$i3d$1(a)fred.mathworks.com>...
> >> > > i want to create tcp/ip communication between matlab and another
> >> > > instrument.
> >> > > now i can see with netstat -a, that tcp/ip is estabilished.
> >> > > but in the side of matlab, i can not run fread.
> >> > >
> >> > > code of matlab:
> >> > > t=tcpip('192.168.1.2',12323)
> >> > > fopen=(t)
> >> > > fwrite(t,'test')
> >> > > freade(t, 10)
> >> > > after long time wait come a warning: The specified amount of data was
> >> > > not returned within the Timeout period.
> >> > >
> >> > > i have tried char(fread(t,t.BytesAvailable))
> >> > > ??? Error using ==> icinterface.fread at 163
> >> > > SIZE must be greater than 0.
> >> > >
> >> > >
> >> > > does anyone have ideas? where is the problem?
> >> > > thx!
> >> >
> >> >
> >> > i can send data from matlab to another instrument.
> >> > wenn i run fwrite and then fprintf, i can see the data on the another
> >> > instrument.
> >> > but why can i not see the data on the matlab use fread?
> >>
> >> what happens if you decrease the amount of data FREAD has to read(?)...
> >>
> >> us
> >
> > always Warning: The specified amount of data was not returned within the
> > Timeout period.
>
> Perhaps this is a silly question, but is your instrument actually sending
> any data? Just because you've opened a connection between MATLAB and the
> instrument doesn't mean that there's any data being sent. Think about a
> telephone call where neither person speaks.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com



thank you! i have solved this problem.