1
votes

I'd like to have a block in simulink that serves as a tcp server. Ideally the simulation would block when it hits this block, wait until data was transfered to it by the client, and than pass that data out to be used in that step of the simulation. I'd also like the connection to persist across function calls, if possible.

I got this to work in Matlab pretty easily, using the myConnectionObject=tcpip(.) and fread(..) functions. So I figured I could just initialize the connection in the workspace, wrap my freads() into a MATLAB function block in Simulink and I'd be on my way.

However, I'm having trouble getting the tcpip connection object into the function to be visible in Simulink so I can use it with fread(). Passing it through a "From Workspace" block gives an "Unsupported input format..." error.

Thanks,

1

1 Answers

0
votes

The Matlab Function block is great for quick simple mathematical functions, but when it comes to initialization or some cleanup at the end of a simulation, a s function is the right tool. With Start and Terminate you got your places to setup and close down the server within the block.