필터 지우기
필터 지우기

serialport - how to reopen port after handle was lost

조회 수: 7 (최근 30일)
Lukas Mayer
Lukas Mayer 2021년 12월 14일
답변: kate_w 2023년 4월 26일
During replacing serial with serialport, I cannot open the port again after the handle was lost (e.g. because it was used in a function that terminated with an error).
I seem to be able to reset the port and reopen with serialport by using clear all but that cannot be it!? Isn't there something that works like delete(instrfind) for the older serial function?
In other words: what would i need between line 2 and line 3 if I lost the variable s:
clear all;
s=serialport('COM9',115200);
t=serialport('COM9',115200);
Error using serialport (line 116)
Unable to connect to the serialport device at port 'COM9'. Verify that a device is connected to the port, the port is not in use, and all serialport input arguments and parameter
values are supported by the device.
See related documentation for troubleshooting steps.
Please help!

답변 (1개)

kate_w
kate_w 2023년 4월 26일
I found something that might help:
delete(instrfind({'Port'},{'COM9'}));

카테고리

Help CenterFile Exchange에서 Serial and USB Communication에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by