A Pattern to Serialize a Simulink Bus.

9 views (last 30 days)
Petri
Petri on 10 Oct 2012
Answered: Fabiano Silva on 1 Aug 2016
Hi there,
I have the mother of Simulink busses. It contains other nested busses and just to make stuff interessting some arrays of busses. Ultimately I would like to send the buss over a UDP link.
My question is, "Is the a generic pattern to convert busses to a character stream?" Would I would not like is to change some blocks every time I change the bus definition or use S-functions or a MATLAB-function block.
For extra browny points the edianess of the data being streamed should be considered.
Thanx Petri

Answers (2)

Kaustubha Govind
Kaustubha Govind on 10 Oct 2012
This may not work for you since you seem to have a non-virtual bus, but I just wanted to throw it out there. If you could convert your nonvirtual bus to a virtual bus, you might be able to utilize the Bus To Vector block. (Note: You mentioned using arrays of buses - these cannot be virtual AFAIK)
  2 Comments
Petri
Petri on 10 Oct 2012
Hi Kaustubha,
Your right, my bus is non-virtual. I have tried something in that direction.
I use a Signal Conversion block to convert non-virtual to virtual, then that is connected to a Bus To Vector. Here all matrices have to converted to vectors otherwise signal sizes can not be propigated. However I can't seems to get around the issues that IBus to Vector block input port cannot accept mixed data types. I've we can resolve that then I have a solution.
Thanx Petri
Kaustubha Govind
Kaustubha Govind on 10 Oct 2012
Petri: Perhaps you should use Data Type Conversion blocks to convert your bus elements to be all of the same type? There is no concept of a Simulink vector/matrix having mixed types (like cell-arrays in MATLAB).

Sign in to comment.


Fabiano Silva
Fabiano Silva on 1 Aug 2016
Hi Petri, I had a similar problem and couldn't find a way to serialize a Simulink non-virtual bus. My solution was extract the signals from the bus with a Bus Selector and then use a Byte Pack block to serialize them. I think it's not the better way to serialize the information in the bus, but it's working well.

Categories

Find more on Interactive Model Editing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!