How come I can't interrupt a function execution immediately using Ctrl+C ?

조회 수: 3 (최근 30일)
Alexandre
Alexandre 2023년 2월 8일
댓글: Kirthi 2023년 2월 14일
Hi,
I'm using modbus function and when I initiate a connection with a bad IP address, I get an error as expected but it takes 15 seconds each time and there is no way to interrupt it faster, not even with Ctrl+C. I dug into modbus function and found a private method simply called 'connect'. The delay is all here and there's no timeout parameter. Is there a way to change its timeout parameter so it waits 2 seconds instead or at least interrupt its execution?
Thanks.

답변 (1개)

Kirthi
Kirthi 2023년 2월 9일
Hello Alexandre,
I can answer your issue of Ctrl+C not working.
Go to Model settings => Simulation Target => Advanced parameters. Now check if the 'Break on Ctrl-C' option is enabled or not.
Break on Ctrl+C will not work if this option isn't checked.
Hope this helps !
  댓글 수: 2
Alexandre
Alexandre 2023년 2월 9일
Hi Kirthi,
This option is checked and I use it all the time. It just seems that the function that is executing is so deep in Matlab environment that I can't interrupt it. Modbus function tries to establish connection during 20 seconds and there is nothing I can do about it which is unusual.
Parameters 'Timeout' and 'NumRetries' have not effect.These commands both takes 20 seconds before showing the expected connection error.
modbusObj = modbus('tcpip', '10.1.1.2', 502);
modbusObj = modbus('tcpip', '10.1.1.2', 502,'Timeout',1,'NumRetries',1);
Several open source master Modbus testers (such as QModMaster) tells in about a second if you can't connect to a Modbus slave. How come MATLAB takes 20 seconds and there is nothing I can do about it?
Thank you.
Kirthi
Kirthi 2023년 2월 14일
Hi Alexandre,
I understand your concern but there is no way you can change the time delay in execution of "modbus" function. However, we might consider resolving this in our future releases.
Thank you.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by