Clear Filters
Clear Filters

What is the proper way to use Stream Input and Stream Output blocks simultaneously?

8 views (last 30 days)
I'm attempting to run a hardware-in-the-loop simulation using Simulink Real-Time Desktop in Kernel mode. I am using a Stream Input block to read data over a serial comm port from a microcontroller, executing a control law, then sending a command over serial using the Stream Output block.
The problem I'm running into is that the Stream Input block seems to always occupy the comm port, meaning that I'm unable to send data back to the microcontroller. I've tried using atomic subsystems, and modifying the task priority / execution order but it hasn't helped.
Is there a good way to ensure that the Stream Input and Stream Output blocks behave well together?
Thanks.

Answers (1)

Jan Houska
Jan Houska on 2 May 2023
Hi Zach,
to use both Stream Input and Stream Output blocks with one serial port, you configure the serial port in one of the blocks - you set the desired baud rate, parity, etc. This will cause the port to be added to the "Installed boards" list. Then, in the other block, you just select the port from this list and the block will share the port, using the same settings.
I'm not sure what you mean by "always occupy the comm port". If you mean that you are unable to configure the block again, perhaps with different settings, that's expected. You cannot have two blocks using the same hardware, each with different settings. To ensure the settings match, you need to share the hardware as described above. If you mean something else, please explain.
Good Luck, Jan

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!