Why do I fail to communicate with an external device using "serialport" in a script but not in the command window?
1 回表示 (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2021 年 9 月 15 日
編集済み: MathWorks Support Team
2023 年 7 月 21 日
I am using the "serialport" command to connect to my external device like an Arduino board. The code doesn't work when I try to run it as script, but works when I run them line by line in the Command Window. Why is that?
採用された回答
MathWorks Support Team
2023 年 7 月 21 日
編集済み: MathWorks Support Team
2023 年 7 月 21 日
Please try to add in a "pause(5)" after the object creation and see if it helps. The device might need some time to be in the correct state before you send data to it.
Running a command from a script and Command Window should give the same result. The only difference in your two executions of your code is the time between executions of each line.
0 件のコメント
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!