Effacer les filtres
Effacer les filtres

serialport - how to reopen port after handle was lost

7 vues (au cours des 30 derniers jours)
Lukas Mayer
Lukas Mayer le 14 Déc 2021
Réponse apportée : kate_w le 26 Avr 2023
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!

Réponses (1)

kate_w
kate_w le 26 Avr 2023
I found something that might help:
delete(instrfind({'Port'},{'COM9'}));

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by