It is my understanding that you are trying to send Variable size data signals over the serial send block, Unfortunately, the Serial Send block does not currently support inputs with variable size . The input data size is set upon compilation time, and will not change during execution. Though there are a few few workarounds, you can follow either of the following.
- Set all of the command sizes to the max command size and pad the shorter commands with some sort of null character that the hardware will ignore, this solution depends on the hardware.
- Avoid the Simulink Serial blocks and instead open a serial object through Stateflow with the MATLAB functions, and then write the data as necessary using "fwrite" (This method requires additional MATLAB programming skills, and is prone to error if "fclose" is not correctly called).
- Alternatively, you can use the Simulink Serial blocks. You can encapsulate the Serial Send block in a Function Call block with one input. Then, in the Stateflow chart, create two parallel states: one for the controller, and one for a serial interface. The controller adds data into a buffer, and the serial interface reads the buffer and sends data out one at a time along with an output event to activate the Serial Send block.
Kiran Felix Robert