Structure output from s-function getting memcopy'ed one element at a time when connecting to bus port

I have an s-function that is outputting an address to a struct, which matches my bus defination for the output port.
But inside mdlOuputs, its memcpy'ing the elements of the struct one at a time, instead of just copying the struct to the bus in a single memcpy.
Is there some setting I missed so that it just does a single memcpy instead of dozens of memcpy (for efficiency and speed reasons)?
Also, bit fields. I know busses dont support packed bit fields, but again, its trying to copy individual elements, which fails because you cant get the address of bit field in a struct. I figured it would just copy the 16 bits at once.
I havent tried a union to try and trick LCT into treating it like an unsigned short int, but it would be moot if as per above, I could get the mdlOutputs to be effiicient with its memcpy to the buss.
All ideas and thoughts are welcome
--SK

1 Comment

Simulink organizes bus data a certain way in memory which may not have the same layout as the corresponding C struct ... for example padding could be different. As a result, the only way to ensure the data in the bus gets placed in the proper location in the C structure is an element-by-element copy.
Thanks.
Mark.

Sign in to comment.

Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products

Asked:

on 17 Sep 2020

Commented:

on 13 Oct 2020

Community Treasure Hunt

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

Start Hunting!