How can I receive and display data using TCP\IP client

9 次查看(过去 30 天)
Hello there, I have a Simunlink model with the TCP\IP client blockset. I would like to modify the client in a way that I can display the data from the server. My project has to be in such as way that once the communication is established both end can send and receive data. Regards

回答(2 个)

Walter Roberson
Walter Roberson 2016-1-27

Issopui
Issopui 2016-1-28
Hi Walter,
Thanks for the help. I'm sorry for my duplicated question I have deleted the other one. Actually I don't have the intrument control toolbox. That's why I have to manage with the S-function block. I have only seen a client be used to send the data only is there a way to modify it to be able to receive a data from the server? I mean as soon as there is a connection it can not only send the data but also receive it from the server. Regards,
  8 个评论
Issopui
Issopui 2016-4-12
编辑:Walter Roberson 2016-4-14
Hello again,
This is what I tried to do after going through some examples:
/* Outputs of the Sfunction */
static void mdlOutputs(SimStruct *Sim, int_T timed)
{
int_T itim;
InputRealPtrsType pointers = ssGetInputPortRealSignalPtrs(Sim, 0);
int_T nuSam = ssGetInputPortWidth(Sim, 0);
// Writing the data on the output port
real_T *y = ssGetOutputPortRealSignal(Sim,0);
int_T DataIn = ssGetOutputPortWidth(Sim, 0);
int_T myMessage = ssGetOutputPortWidth(Sim, 0);
int_T fp = ssGetOutputPortWidth(Sim, 0);
for (int i = 0; i < DataIn/sizeof(float); i++){
y[i]= myMessage.fp[i];
}
The error message now read:
Building with 'Microsoft Windows SDK 7.1 (C++)'.
Error using mex
client64sr.cpp
C:\Users\MfeIss\Documents\Simp_Client\client64sr.cpp(109) : warning
C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of
data
C:\Users\MfeIss\Documents\Simp_Client\client64sr.cpp(229) : error C2228:
left of '.fp' must have class/struct/union
type is 'int_T'
Pleease guys any help will be appreciated.
Many thanks
Walter Roberson
Walter Roberson 2016-4-14
Why are you taking the output port width of the same thing multiple times? If you had varied the 0 to something else I might have understood.
You made myMessage a number which is just the width of some port, but you are trying to access a "fp" field of that width. Perhaps you need another ssGetOutputPortRealSignal or something similar?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Development Computer Setup 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by