Hello, I am trying to connect a device through a serial port using the below code
%Set the below parameters
port = 'COM3';Baud_Rate = 9600;Data_Bits = 8;Stop_Bits = 1;%Default for Parity & Flow Control are none.
S = serial('COM3','BaudRate',Baud_Rate,'DataBits',Data_Bits,'StopBits',Stop_Bits);fopen(S)fscanf(S)
The problem is: 1. I keep getting the following error
Error using serial/fopen (line 72)Open failed: Port: COM3 is not available. No ports areavailable.Use INSTRFIND to determine if other instrument objects areconnected to the requested device. instrfind Instrument Object Array Index: Type: Status: Name: 1 serial closed Serial-COM4 2 serial closed Serial-PORT 3 serial closed Serial-COM4 4 serial closed Serial-COM4 5 serial closed Serial-COM4 6 serial closed Serial-COM4 7 serial closed Serial-COM4 8 serial closed Serial-COM4 9 serial open Serial-COM4 10 serial closed Serial-COM4 11 serial open Serial-COM6 12 serial closed Serial-COM6 13 serial closed Serial-COM6 14 serial open Serial-COM3 15 serial closed Serial-COM3 16 serial closed Serial-COM3 17 serial closed Serial-COM3 18 serial closed Serial-COM3 19 serial closed Serial-COM3 20 serial closed Serial-COM3 21 serial closed Serial-COM3 22 serial closed Serial-COM3 23 serial closed Serial-COM3 24 serial closed Serial-COM3 25 serial closed Serial-COM3
2. The same serial port connects when I use alternative software such as MakerPlot or PuTTy.
At this point I have gone through a lot of the forums and have tried instrfindall, clearing MATLAB and running it again, I have double checked that I have the right port, and have also made sure that the alternative software does not have the port open, making it unavailable for MATLAB. No matter what I do or which port I use, I can't seem to get any port to open with MATLAB.
Any help you might be able to provide me would be greatly appreciated.
Thanks!
Best Answer