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

2 vues (au cours des 30 derniers jours)
Issopui
Issopui le 25 Jan 2016
Commenté : Walter Roberson le 14 Avr 2016
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

Réponses (2)

Walter Roberson
Walter Roberson le 27 Jan 2016

Issopui
Issopui le 28 Jan 2016
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 commentaires
Issopui
Issopui le 12 Avr 2016
Modifié(e) : Walter Roberson le 14 Avr 2016
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 le 14 Avr 2016
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?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by