How to properly handle objects within level-2 Simulink S-Functions

I'm attempting to use a level-2 S function to handle serial read/write to and from a device.
I need some help with two things:
  1. How do I handle dialogue parameter inputs? I'd like to input the specified com port.
  2. How can I create a serialport object that persists throughout an entire simulation? I'd like to avoid opening and closing the commport each iteration.
Thanks!

 採用された回答

Jan Houska
Jan Houska 2023 年 4 月 18 日

1 投票

Hi Zach,
while this does not directly answer your question, have you tried to use the Packet Input/Output or Stream Input/Output blocks with the Serial Port driver? These blocks from the Simulink Desktop Real-Time product library should be able to handle reading/writing serial port devices out of the box, with no programming necessary.
Jan

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

製品

リリース

R2023a

質問済み:

2023 年 4 月 14 日

回答済み:

2023 年 4 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by