Serial port is not available in GUI but it actually available in my pc
6 次查看(过去 30 天)
显示 更早的评论
Hi,
I wish to have simple GUI communicate serially with microcontroller (PIC) through UART. When press button1 in GUI, LED1 will light up. Press button2, LED2 will light up. I use USB to RS232 converter. In my computer management, under the port category, it shows USB-to-RS232 converter port (COM14). So I use COM14 in my GUI. Unfortunately, it shows an error when I run them. "??? Error using ==> serial.fopen at 72 Port: COM14 is not available. Available ports: COM5, COM12." Why COM14 is not available? But it shows in my computer management. when I use instrfind command, the following information I get:
>> instrfind
Instrument Object Array
Index: Type: Status: Name:
1 serial open Serial-COM14
2 serial closed Serial-COM14
3 serial closed Serial-COM14
4 serial closed Serial-COM14
What does it mean? why COM14 is open then closed? Thank you.
0 个评论
回答(3 个)
Walter Roberson
2011-6-15
Did you turn on the device after you started MATLAB? USB devices have to be fully connected before you start MATLAB or else you will not be able to use them.
If the problem continues, try
fclose(instrfind)
and then try to find the port.
2 个评论
Walter Roberson
2011-6-15
Just before the fopen(s), try adding
instrfind
You should expect to see one occurrence of COM1 (corresponding to its use in s) and anything else is Odd.
Yeoh
2011-6-16
5 个评论
Walter Roberson
2015-5-4
With regards to finding the COM port, see http://www.mathworks.com/help/matlab/matlab_external/overview-of-the-serial-port.html and look down to "Finding Serial Port Information for Your Platform"
Ankit Desai
2011-6-15
There are a few things that you might want to check:
- Make sure the port is not used in any other application (such as hyperterminal, another instance of MATLAB etc.). If the port is used by any such application, it will not show up in MATLAB.
- If an object is created in MATLAB but not deleted and cleared correctly - it will not show up in subsequent attempt of using it.
From the output of instrfind, it appears that a serial object for COM14 was created but not cleaned up correctly (it is still available in the memory, which is why instrfind is finding it). Which means as per point 2 above, it will not be available when you try to create another object using the same port.
You might want to check the code to find all the places where you create a serial object and make sure that you are not trying to create multiple objects to the same port. You should use the same object for all your serial communication to that port.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 ActiveX 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!