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

조회 수: 10 (최근 30일)
Issopui
Issopui 2016년 1월 25일
댓글: Walter Roberson 2016년 4월 14일
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